+ Reply to Thread
Results 1 to 14 of 14

Need to choose maximum values to selected sum

  1. #1
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Need to choose maximum values to selected sum

    Hello,
    I am trying and not succeeding with this case.. need your help please
    I am generating calculator for PV plant and I need to make inverter selection according to calculated power.
    For example, if calculated power is 75,1 kW, I need to find two different size inverters that would be closest to that 75,1 value. But those found values has to be maximum values.
    I have such inverter sizes:
    10
    12
    15
    17
    20
    30
    36
    40
    50
    My goal is to find nearest values to 75,1. So in this case it would be 50 and 20. It would be not good if excel suggest to chose lot of smaller values.. And I do not need to sum them. Those found values should be somewhere in other sheet, in separate cells, or in the same sheet but marked with X or something.
    Maybe anyone has similar example or could explain how could I reach that functionallity?
    WOuld aprecciate any help.
    Thanks in advance

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Need to choose maximum values to selected sum

    Solver seems like it should be able to do this. Set up is similar to a "subset sum" type of problem https://superuser.com/questions/2049...-a-given-total Set up the spreadsheet to calculate total power and the difference (absolute value or squared difference might be best) between total power and your target value. Then tell Solver to set this to a minimum by changing the inverters used subject to the constraint that you only use 2 inverters.

    It's probably not necessary for us to know because the overall strategy should work either way, but you say that you need the sum of inverters to be closest to 75.1 kW, then state that the solution you want is the 50+20=70. I notice that 40+36=76 is closer to 75.1 than 70 is. I probably just do not understand exactly what you mean by "closest to" in the context of the problem (perhaps it really means "closest to, but never greater than"?). It probably doesn't matter that I understand it, but just be sure that you are clear exactly what you mean by "closest to" as you set up the problem so that you get the solution you want.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Re: Need to choose maximum values to selected sum

    Hello. Thanks for response.
    (perhaps it really means "closest to, but never greater than"?) - yes, you are right. That is excatly what I have in mind.
    Solver is not good solutions in this situation I need to make reference to the cell, and with solver I can only write set value.
    The point is that according to the roof area, the power value in cell will change and according to that changed data in cell, inverters would automatically be chosen

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Need to choose maximum values to selected sum

    Solver is not good solutions in this situation I need to make reference to the cell, and with solver I can only write set value.
    I'm not sure I understand this concern. What about Solver forces you to write only a set value?

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Need to choose maximum values to selected sum

    I think the solver is very suitable for your needs. You only need to define what you want in a smart way.

    This quote is not smart:
    It would be not good if excel suggest to chose lot of smaller values
    Smart is for example: "In the solution there are max 2 values below 20".

    And so on.
    Last edited by HansDouwe; 11-23-2022 at 03:21 PM.

  6. #6
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Re: Need to choose maximum values to selected sum

    I mean that in Solver you need to write manually value. I would like to make something that when value in cell changes, automatically changes inverter quantity. As with Solver every time power value changes you need to write manually Value of.

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Need to choose maximum values to selected sum

    In the solver you should refer to values in cells. You only had to tell the tell the solver what you want to achieve and add constraints that apply to the problem
    Last edited by HansDouwe; 11-23-2022 at 04:09 PM.

  8. #8
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Re: Need to choose maximum values to selected sum

    Sorry, maybe then I do not understand Solver correctly. You mean that I can refer Value of to cell? I tried to search info about reffering Value of to cell, but could not find any answer

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Need to choose maximum values to selected sum

    I mean that in Solver you need to write manually value. I would like to make something that when value in cell changes, automatically changes inverter quantity. As with Solver every time power value changes you need to write manually Value of.
    Again, I'm not sure I understand this, though it could be because I am not sure exactly how you are setting up you Solver/spreadsheet model. I can see where some variations would require you to manually enter a new value in the "set target cell to a value" field of the Solver dialog, there are almost certainly other ways to set this up so you don't need to manually edit that field each time. For example, when I set up a Solver/spreadsheet model to find a target value, I don't enter that target value in the "to Value" field. I enter that value in a spreadsheet cell, add a simple =formula-target value cell to the spreadsheet, then tell Solver to set that to a value of 0. Any time I need to change the target value, I need only edit the target value cell in the spreadsheet. I need not make any manual edits to Solver.

    Can you explain how you are setting up your Solver/spreadsheet model that is requiring these undesirable manual edits, and explain changes you are allowed to make? As HansDuowe says, we can usually minimize edits/interactions with Solver/spreadsheet if we are a little smart and clever in designing the Solver/spreadsheet model.

  10. #10
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Re: Need to choose maximum values to selected sum

    I sent you a message with link, what example I used with Solver. Sorry I cannot post link here because of new account restrictions

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Need to choose maximum values to selected sum

    For others' benefit, link sent to me: https://www.extendoffice.com/documen...given-sum.html

    Your tutorial shows them wanting to find values that add up to 480, so they enter 480 into the "value of" field in Solver. This is where I would enter 480 into a cell in the spreadsheet (maybe B11 in their example), add another cell that computes the difference (maybe B12 =B11-B10), then tell Solver to find a value of 0. When I want to find a different target value, I enter my new target value into B11 and rerun Solver without further modification.

    For something like yours, where your target is "max value no larger than target," I would set up something similar (B10 is SUMPRODUCT() function, B11 is target value, B12 is B11-B10), then tell Solver to set B12 to a minimum (I think I have my signs right, if not, maximum), by changing decision variables, subject to the constraint that B12 is greater than or equal to 0 (less than or equal to 0 if my signs are backwards). Whenever my target value changes, I need only change the value in B11 and run Solver.

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,465

    Re: Need to choose maximum values to selected sum

    In the example of MtShorty you should also tell the solver that B12 should stay positive (or you need to minimize ABS(B11-B10)).

  13. #13
    Registered User
    Join Date
    11-22-2022
    Location
    london
    MS-Off Ver
    2017
    Posts
    6

    Re: Need to choose maximum values to selected sum

    Thank you very much for your help. I've tried to make with your explanations and it works fine.
    One last questions.Is it possible to find biggest values? For example, if I have target value 200, that it would choose not 4x50 or 2x50 and 1x100, but 2x100? I hope you understood what I mean

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Need to choose maximum values to selected sum

    The usual constraint to add for that is to have a some kind of "counting" function in the spreadsheet that counts how many numbers are used. In extended office's sample, this might be =SUM(B2:B9) then have a constraint in Solver that this cell must be less than or equal to a threshold (2 or 3 or whatever suits your fancy).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] From selected cell, choose a range
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-30-2019, 12:07 PM
  2. Choose the maximum value in the condition
    By luongthang1908 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-21-2016, 05:31 PM
  3. Replies: 7
    Last Post: 10-07-2015, 03:01 PM
  4. [SOLVED] Choose maximum value out of a number of values that match certain criterias from an array
    By Alderdeiry Mohamed in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-02-2015, 10:11 AM
  5. How to choose a specific row among selected ones
    By ref in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2012, 01:35 PM
  6. Compare a value to a number of ranges and choose the maximum
    By Basq8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2011, 04:43 AM
  7. How to choose selected data in large list?
    By dev in forum Excel General
    Replies: 2
    Last Post: 09-01-2006, 09:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1