+ Reply to Thread
Results 1 to 8 of 8

Excel Solver: adding ratio as a constraint

  1. #1
    Registered User
    Join Date
    12-06-2015
    Location
    country
    MS-Off Ver
    2010
    Posts
    3

    Excel Solver: adding ratio as a constraint

    hi,
    Any help would be appreciated...

    What's the method to add a ratio constraint in Excel Solver when there are more than 2 variables?

    If I have 3 variables for a mixture to be made... Foo, bar, jar and looking to find the (min) optimized solution mix in Solver for each ingredient, with the following constraints:
    1) the total of all 3 ingredients <=1000 kg
    2) Foo>=300 kg; Rs 10/kg
    3) Bar>=200 kg; Rs 50/kg
    4) Jar>=100 kg; Rs 60/kg
    5) (and this is my problem) but the ratio of Jar to the rest of the ingredients is 1:4
    6) Obj Function: min total cost

    The part where I'm getting stuck is figuring out how to set up the constraint: "ratio of Jar must be in a 1:4 ratio in the optimized mix in Solver".

    Help?

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

    Re: Excel Solver: adding ratio as a constraint

    What are your "decision variables" (the values for the "by changing" field)? I would guess it is the amount of each ingredient, but I don't want to assume too much. Also, what, exactly do you mean by "the ratio of jar to the rest is 0.25"? 0.25=jar/(foo+bar) or 0.25=jar/(foo+bar+jar) or something else.

    You could add an additional "objective function" that computes the ratio of "jar" to "foo+bar" and then add a constraint for the cell that contains this secondary objective function =0.25 in Solver.

    If your ratio is something like the equations I have above, I would probably take jar out of the list of decision variables and make it a straight up calculated value. jar=0.25*(foo+bar) for example. Then, as foo and bar are adjusted, the ratio of jar to foo+bar will be fixed by this formula.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Excel Solver: adding ratio as a constraint

    Something like this perhaps?

    Alf
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-06-2015
    Location
    country
    MS-Off Ver
    2010
    Posts
    3

    Re: Excel Solver: adding ratio as a constraint

    @Alf: Thanks for the sample... I took a look a the solution and doesn't seem to be right -- Solver looks like its simply taking the 300 and 200 quantity and dropping it in along with the computed 125 figure. Also should not the 125 JAR output (D5) be 25% of the total 625? in D6 (which it is not)

    @MrShorty: Some more information after reading your post:
    Yes the decision variables are the amount of each ingredient.

    I'm not sure what the ratio part means, that's where I'm stumped The problem verbatim is this: "The mixture must contain at least 200 Kg of Bar, 300 Kg of Foo, 100 kg of Jar, and the ratio of Jar to the other two ingredients cannot exceed 1 to 4". "What is the amount of each ingredient needed to be put into the mixture that will meet all the requirements of the mix and minimize total cost."

    I've added a workbook for both your kind consideration.

    Thanks for the help.
    Attached Files Attached Files

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

    Re: Excel Solver: adding ratio as a constraint

    We are happy to help with homework where we can. Just recognize that we may not (probably should not) just do it for you.

    I might suggest that "what the ratio part means" is more of a math question than an Excel question. As far as the Excel side of the question, Alf has shown you how to do it.
    1) Calculate the desired constraint in a spreadsheet cell. (D10 in Alf's spreadsheet)
    2) Include a constraint in your solver model that tests that constraint. (D5=D10 in Alf's solver model).

    Alf assumed that your constraint was "jar must be equal to 1/4 of the sum of the other two ingredients", where you are now expressing the constraint as "cannot be greater than 1/4 of the sum of the other two ingredients". If I understand your question, the answer would be to change D10 to the formula you believe correctly expresses the desired ratio and to change the constraint to be D5 cannot be greater than D10.

  6. #6
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Excel Solver: adding ratio as a constraint

    Solver looks like its simply taking the 300 and 200 quantity
    Let me see if I can add a bit more to Mr Shorty's explanation of you problem.

    The "driving" force in solver is the "Object function". This is what you wish to achieve.

    In this case your "objective" is minimum cost so solver will use as little as it can of each components, the more a component costs the more solver will strive to minimise the use of the more expensive components.

    So solver must find the minimum cost for the mix but according to certain rules i.e. the constraint.

    And one constraint was that Foo should be equal or greater then 300, another one was that Bar should be equal or greater than 200 so of course solver have to use the minimum quantities of these two components and ad this to the smallest quantity of jar (objective minimum cost) to make the ratio
    of Jar to the rest of the ingredients is 1:4
    Alf

  7. #7
    Registered User
    Join Date
    12-06-2015
    Location
    country
    MS-Off Ver
    2010
    Posts
    3

    Re: Excel Solver: adding ratio as a constraint

    It was never my "objective function" to get you to do my homework. Thank you for NOT doing that for me.

    The reason for sending the workbook was just to give you a clearer understanding of the problem. My only issue was trying to figure out how to enter and manage the ratio constraints, and your last posts gave me the information needed, and so I was able to figure out the problem with all constraints satisfied. THANK YOU BOTH!!

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

    Re: Excel Solver: adding ratio as a constraint

    Happy to help.

+ 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. Excel Solver Constraint Help
    By BauceArj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2014, 08:47 PM
  2. EXCEL Solver: Constraint equals one of two values (0 or 100)?
    By davidmummery1989 in forum Excel General
    Replies: 1
    Last Post: 01-14-2014, 06:54 AM
  3. [SOLVED] Excel Solver Constraint Question
    By Verna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-19-2012, 04:33 PM
  4. Replies: 1
    Last Post: 07-07-2012, 03:13 PM
  5. Replies: 0
    Last Post: 07-03-2012, 12:15 PM
  6. Excel Solver- Ratio Constraint
    By Patriot393 in forum Excel General
    Replies: 1
    Last Post: 06-12-2011, 08:55 PM
  7. Excel Solver: Constraint Specification
    By tonisama in forum Excel General
    Replies: 6
    Last Post: 11-16-2010, 05:00 PM

Tags for this Thread

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