+ Reply to Thread
Results 1 to 17 of 17

Issue with Solver Binary Constraints

  1. #1
    Registered User
    Join Date
    07-13-2018
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2016
    Posts
    4

    Issue with Solver Binary Constraints

    Hello!

    I have a portion of a homework problem I don't know how to resolve. In the problem, I have a set of five parts to be produced where A+B+C add up to one product with a demand of 7000, and A+D+E add up to another with a demand of 5000. They can be produced in my home factory at a lower cost per item but with a one-time set-up fee per type of item produced, or outsourced for a higher per item cost but with no set-up fee. The lesson demands that this be done with a linear programming model.

    Setting up everything but the one-time fee is no problem and Simplex LP will solve it with no issues. Once I try to factor in the one time fee, however, nothing works - I've tried setting up if/then statements reliant on >0 production in a particular item category, and I've set up binary constraints to do the same thing. As soon as that conditional "will I use the factory for that item and incur the fee or not" element is put into the spreadsheet in any way I know, Simplex LP won't play ball anymore.

    Parts A,B,C combine into a product, which I need 7000 of. Parts A,D,E also combine into a product I need 5000 of, so I need exactly 12000 of part A, 7000 of B and C, and 5000 of D and E. The 30000 is a time constraint in the same units(minutes) as the time-per-part is expressed in; this is the most time my home factory has to spare. The overall objective is to determine what amount of which parts should be made in the home factory or outsourced, minimizing the cost.

    I'm pretty sure I just don't understand the material very well, or I'm missing an entire concept somewhere. I've attached a screenshot of the spreadsheet as it's set up currently below. I definitely don't need anybody to do my homework for me or anything like that, but a nudge in the right direction would be amazing.

    Capture.PNG
    Last edited by NougatBike; 07-13-2018 at 03:57 PM.

  2. #2
    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: Issue with Solver Binary Constraints

    I think you better upload your sample file.

    There are a least one constrain you have not specified in your post i.e. F15 <= 30000, then I'm not sure about I3 = 7000 and I4 = 7000 and I5 = 5000 and I6 = 5000

    Is not the problem that you should produce 7000 and 5000 either at your home factory or it being being outsourced and solver should decide what should be produced where based on the lowest total cost for the total production of A+B+C and A+D+E.

    Alf

  3. #3
    Registered User
    Join Date
    07-13-2018
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Issue with Solver Binary Constraints

    Sorry, my mistake - I didn't realize I had left that out. Parts A,B,C combine into a product, which I need 7000 of. Parts A,D,E also combine into a product I need 5000 of. The 30000 is a time constraint in the same units(minutes) as the time-per-part is expressed in. The overall objective is to determine what amount of which parts should be made in the home factory or outsourced, minimizing the cost.

  4. #4
    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: Issue with Solver Binary Constraints

    Sorry, my mistake - I didn't realize I had left that out
    Well really you had not, my bad really as I didn't read you posting properly.

    So I set up a model, had to guesstimate a bit as not all was obvious. Not happy with the result because Solver complained about problem not being a proper linear one so I
    had to run it using the GRG-Nonlinear engine. Can't see why this problem in not linear.

    The second problem was setting up the constraint to make solver find the optimal solution. Analyzing the cost difference it was obvious that the lowest cost would be found
    by not buying sub component A, B and D but saw that the in-house time was a limiting factor so in the end I added the constraint that range F2:F4 = 1 to get the best lowest
    cost solution.

    Well there you are, I'll upload the modified file as it's not a 100 % solver found solution but when you get the right solution to this problem I would appreciate it if you
    could post that file in this thread.

    Alf
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-13-2018
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Issue with Solver Binary Constraints

    That's about what I was running into as well - it won't treat it as a linear problem no matter what I do. I think that's fine, though - if other people who are better at excel than me are running into the same issue, I'm now wondering if the problem itself is just poorly constructed/worded.

    Thank you very much for your help!

  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: Issue with Solver Binary Constraints

    Having another go at the problem and made a slightly different setup it now runs as a linear problem.

    Don't know why this made a difference but it does. Still setting values of 1 in the range F2:F4 bothers me, had a similar problem some time ago and got a solution
    using the "Evolutionary" engine in the solver set up. But this solution was not as optimal as the one I got when I used fixed values i.e. 1 in several cells.

    Oh well this solution gives same result i.e. 50575 as the min value in cell L2 even if the production / buy pattern is different.

    Alf
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-13-2018
    Location
    Phoenix, AZ
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: Issue with Solver Binary Constraints

    So I'm basically getting the same thing - between your work and me messing with it I've isolated that what solver particularly doesn't like is the "open" cells being considered variable cells if anything else in the problem is dependent on them, even without the binary constraint. Once you include them as variable cells, solver refuses to touch it. If they aren't variables and you just treat them as a manual on-off switch, it's fine then and it will do the problem. So I'm basically concluding that the problem isn't doable in the way they want me to do it, and I'm going to say as much in the assignment and see where that gets me. Thanks again!

  8. #8
    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: Issue with Solver Binary Constraints

    what solver particularly doesn't like is the "open" cells being considered variable cells
    Yes that seems to be the root of the problem. I've also tested the setup with the "OpenSolver" a much more powerful linear solver than the excel one. But also this solver can't cope with this problem.

    Still it does not tell problem is not linear but it ignores the range I2:I6 so all sub components gets bought nothing is produced in the home factory.

    Link for dowloding OpenSolver in case you are interested:

    https://opensolver.org/

    So using solver I do think that the "Evolutionary" solver engine may give you a solution to this problem but how good I don't know.

    The problem I solver by using the "Evolutionary" engine see file in post #4 and the much better solution when applying a bit of logic to the problem in post 6 where the problem can be solved as a Simplex linear problem.

    https://www.excelforum.com/excel-gen...ml#post4756303

    So normal solvers like excel's Simplex LP and the GRG is not up to tackle problems of this kind nor will the "OpenSolver" manage this. The "Evolutionary" engine may manage
    to do this but it's not sure that one gets the best possible solution.

    Alf

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Issue with Solver Binary Constraints

    ( deleted )

    I couldn't improve on Alf's solution.
    Last edited by shg; 07-14-2018 at 02:28 PM.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    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: Issue with Solver Binary Constraints

    Thanks for rep shg

    Alf

  11. #11
    Valued Forum Contributor Hydraulics's Avatar
    Join Date
    07-15-2018
    Location
    Udine - Italy
    MS-Off Ver
    Office 365
    Posts
    373

    Re: Issue with Solver Binary Constraints

    I hope it's not too late for your homework assignment. Since you are asking for hints I will not (yet) give you the final solution.

    First, the simplex algorithm can deal only with linear constraints. But in your formula expressing the built price you have the product of two variables: the binary one indicating the presence of fixed costs and the quantity to be produced. Your constraint should be in the form

    T = Fy + vx

    where y is binary, x continuous (integer, actually), and F and v are fixed and variable costs, respectively.

    However y and x are not independent from each other. y can be 1 only when x>0, otherwise it must be zero. This means we must add a constraint, that is usually expressed as

    x -My <= 0

    where M is a constant "large enough" not to interfere with already given constraints. In the last equation, if y is zero, x is forced to zero as well. And when y is 1, x remains bounded from the other conditions.

    As for remaining constraints on total quantities, I suggest you to express them as given (A+B+C = 7000 and A+B+E = 5000). Your assumptions on single amounts is incorrect.

    If you still need it, I will post the solution.

    (As a check, and if I'm not mistaken, the solution has a minimal cost of 4000)

  12. #12
    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: Issue with Solver Binary Constraints

    Hi Hydraulics

    I would like to see algorithmic solution so could you please post it.

    By the way did you realize that the deciding factor for solving this problem is the max time that the home factory can use in the production? Max time is set to 30000 minutes and the table in the uploaded file shows setup time for a part + a production time for that particular part

    a_home_work.jpg

    So F (fixed ) should be equal to setup time and v (variable) should be production time/unit

    Alf

  13. #13
    Valued Forum Contributor Hydraulics's Avatar
    Join Date
    07-15-2018
    Location
    Udine - Italy
    MS-Off Ver
    Office 365
    Posts
    373

    Re: Issue with Solver Binary Constraints

    Hi Alf,

    here is the solution. The solver is already set.

    Quote Originally Posted by Alf View Post
    [...]
    By the way did you realize that the deciding factor for solving this problem is the max time that the home factory can use in the production?
    [...]
    Well, not really. Time is a limiting factor (constraint) exactly as the demand that A+B+C = 7000.

    Set up is a one-time fee (a typical situation in these kind of problems).

    Quote Originally Posted by NougatBike View Post
    [...]
    In the problem, I have a set of five parts to be produced where A+B+C add up to one product with a demand of 7000, and A+D+E add up to another with a demand of 5000. They can be produced in my home factory at a lower cost per item but with a one-time set-up fee per type of item produced, or outsourced for a higher per item cost but with no set-up fee.
    [...]
    Outsourcing a piece means paying a variable cost, and nothing else.

    Producing it internally incurs in a set up fee, a variable cost and a time spent.
    Attached Files Attached Files

  14. #14
    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: Issue with Solver Binary Constraints

    Not sure you read properly what OP wrote in post #1. Well I didn't the first time But eventually I saw my error

    Parts A,B,C combine into a product, which I need 7000 of. Parts A,D,E also combine into a product I need 5000 of, so I need exactly 12000 of part A, 7000 of B and C, and 5000 of D and E.
    So the OP needs 12000 of A, 7000 of B and C and finally 5000 of D and E. For my solution I assumed the OP meant 7000 of B, 7000 of C, 5000 of D and also 5000 of E in order to make 7000 and 5000 combined units. If you can see his solver setup (try open it on a separate tab by right clicking on the image) on the posted image you will see that I3 = 7000, I4 = 7000, I5 = 5000 and I6 = 5000 so I thinks that confirms my assumption.

    Alf
    Last edited by Alf; 07-16-2018 at 09:28 AM.

  15. #15
    Valued Forum Contributor Hydraulics's Avatar
    Join Date
    07-15-2018
    Location
    Udine - Italy
    MS-Off Ver
    Office 365
    Posts
    373

    Re: Issue with Solver Binary Constraints

    Quote Originally Posted by Alf View Post
    Not sure you read properly what OP wrote in post #1. Well I didn't the first time But eventually I saw my error
    Alf, actually I did read. And I already pointed out in my first message that subsequent assumptions about single product quantities are incorrect.

    This is the original problem statement (and again, this is a rather common setup for these basic linear programming problems)

    Quote Originally Posted by NougatBike View Post
    In the problem, I have a set of five parts to be produced where A+B+C add up to one product with a demand of 7000, and A+D+E add up to another with a demand of 5000.
    A+B+C=7000
    and
    A+D+E =5000

    does not imply that

    Quote Originally Posted by Alf View Post
    So the OP needs 12000 of A, 7000 of B and C and finally 5000 of D and E.
    Do we agree?

  16. #16
    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: Issue with Solver Binary Constraints

    Do we agree?
    Don't think it matters if we agree or not, the issue here is what did the OP mean when he wrote

    Parts A,B,C combine into a product, which I need 7000 of. Parts A,D,E also combine into a product I need 5000 of, so I need exactly 12000 of part A, 7000 of B and C, and 5000 of D and E.
    and until he enters this discussion and settle this issue I see no point in discussing it.

    Alf

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Issue with Solver Binary Constraints

    A+B+C=7000
    and
    A+D+E =5000

    does not imply that the OP needs 12000 of A, 7000 of B and C and 5000 of D and E.
    I took it to mean exactly that, and would be surprised it it were otherwise.

+ 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 - binary variable constraints
    By garbage2100 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 05-10-2018, 04:53 PM
  2. Excel Solver binary constraints
    By jharaldson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-18-2014, 03:37 AM
  3. [SOLVED] Solver returns non binary answer in binary constrained cells
    By Tushar Mehta in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 09-07-2005, 12:05 AM
  4. Solver returns non binary answer in binary constrained cells
    By Tushar Mehta in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 09-06-2005, 09:05 AM
  5. Solver returns non binary answer in binary constrained cells
    By Navy Student in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  6. [SOLVED] Solver returns non binary answer in binary constrained cells
    By Navy Student in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] Solver returns non binary answer in binary constrained cells
    By Navy Student in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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