+ Reply to Thread
Results 1 to 20 of 20

Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

  1. #1
    Registered User
    Join Date
    08-31-2021
    Location
    Brazil
    MS-Off Ver
    365
    Posts
    2

    Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Hi,

    I am totally new to Solver in Excel (and far from a Excel ninja). I am importing some products from USA and I would like to know if Solver can solve this problem.

    The issue is, I want to have the best mix of products inside each box in order to reduce costs, respecting the following constrains:

    All boxes should be less than $50 to avoid import tax fee, which is 60%.
    Pay the cheaper price possible to delivery all goods to myself.

    As I can't post any link, I will upload a image. Screen Shot 2021-08-31 at 4.44.22 PM.png

    Thanks!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    The picture would reqiure rewriting into Excel to suggest possible solver solution. Please consider publishing a workbook as the attachment. See yellow banner above and .... just before posting scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.


    I expect that the variables will form a matrix 14 (as products number) by at least 16 (to avoid tax, with total value of $761.69 and single pack below $50 you need at least 16 packs). So we are probably above upper limit of available standard solver variables (which is around 200).

    In case solver fails because of too many variables, you can consider some other solutions like opensolver, or may be limit the number of items and packs to be completed by manually completing some packs before solver is applied. Probably the wise strategy would be to start from most expensive items (#4,5,9) so you will have 9 packs with single expensive item and "filled with less expensive" to fit total below $50 and weight almost a pound.

    60% tax is making the cost of the postage less important, but of course it would be better to use heavier packs in general case. But in your case, you have at least 16 packs and only 14.939 pounds. So keepeng all packs under a pound will end up with less than $320 for delivery. While 15 below 1 pound and one below 2 pound makes already almost $330 and so on.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    08-31-2021
    Location
    Brazil
    MS-Off Ver
    365
    Posts
    2

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Quote Originally Posted by Kaper View Post
    The picture would reqiure rewriting into Excel to suggest possible solver solution. Please consider publishing a workbook as the attachment. See yellow banner above and .... just before posting scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.


    I expect that the variables will form a matrix 14 (as products number) by at least 16 (to avoid tax, with total value of $761.69 and single pack below $50 you need at least 16 packs). So we are probably above upper limit of available standard solver variables (which is around 200).

    In case solver fails because of too many variables, you can consider some other solutions like opensolver, or may be limit the number of items and packs to be completed by manually completing some packs before solver is applied. Probably the wise strategy would be to start from most expensive items (#4,5,9) so you will have 9 packs with single expensive item and "filled with less expensive" to fit total below $50 and weight almost a pound.

    60% tax is making the cost of the postage less important, but of course it would be better to use heavier packs in general case. But in your case, you have at least 16 packs and only 14.939 pounds. So keepeng all packs under a pound will end up with less than $320 for delivery. While 15 below 1 pound and one below 2 pound makes already almost $330 and so on.

    Thanks a lot! I will try to understand all the information you gave me and still trying to learn through tutorials.

    I attached the spreadsheet, I tried it in the first post but did not work. Maybe it was because I did not use the "manage attachments".
    Attached Files Attached Files
    Last edited by AlexandreBS; 09-01-2021 at 12:20 PM.

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

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    It looks like you can use 16 boxes, all with a weight less than 1 pound.

    As Kaper wrote, there are too many variables for the standard Solver (I doubt it would find a solution, anyhow). You will need to install OpenSolver, a free add-in.

    HTH,

    Francesco
    Attached Files Attached Files
    Aim high or don't even try.
    ---------------------------------
    If your question has been answered, don't forget to mark the thread as SOLVED.
    If you find an answer helpful, click on the star icon at the bottom of the post.

  5. #5
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Hi Francesco

    Tried your solution but on my PC in ran for 120 seconds and then told me it could not find a proper solution (uploaded fractional value instead of integers). My setup looks
    like yours and OpenSolver found a solution after 1,96 seconds so I'm puzzled why your file did not run properly on my PC. Any ideas about that?

    Just to see fract costs I setup a small excel solver model but found all boxes could be shipped in four lots with weights from 3,61 to 3,87.

    Alf
    Last edited by Alf; 09-01-2021 at 03:52 PM.

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

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Quote Originally Posted by Alf View Post
    My setup looks like yours and OpenSolver found a solution after 1,96 seconds so I'm puzzled why your file did not run properly on my PC. Any ideas about that?
    Hi Alf,

    I think I was too optimistic with maximum solution time.

    Running again the model, the first time I got no solution, the second had to wait 100s, so I think it may be safe to set 300s.

    It seems to me you haven't added the constraint on max weight in your setup. It is quite taxing for the engine.

    HTH,

    Francesco

  7. #7
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    It seems to me you haven't added the constraint on max weight in your setup.
    So right you are and now I realize I've not understood the OP's request so I've deleted files and comments.
    Alf
    Last edited by Alf; 09-01-2021 at 04:32 PM.

  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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Checking my model I got a result for cost (50 or less) and weight (1 and less) if I increased the number of boxes to 18. Solution was found after 1.82 seconds. Testing with 17 boxes it took 48.1 seconds.
    Testing a setting with 16 boxes did not find a solution after a time setting of 950 seconds.

    I also did a test run with your file Francesco but on my PC it did not find a setting after 950 seconds so I guess this must be caused by a difference in PC / CPU.

    Alf

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    I have given macro code. It results in 16 boxes. It does not take any time, instant. This may be helpful until you get SOLVER help.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 09-02-2021 at 07:23 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

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

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    I don't know what happened to my file, Alf. When I tried to change it, OS gave me a funny error message I could not get rid of, and forced me to rebuild the model.

    Anyhow, it may not be a bad thing, since I have decided we should seek to minimize the sum of shipping costs and extra-fees, if a box has a value > 50$. The optimal number of boxes is found by OS.

    There are some bin vars, to chose the correct class, and some real vars (>0), to calculate the extra-fees. I have assumed that the fees are paid on the fraction of value that is over 50$.
    After a few runs, I have seen that OS will never fill a box up to more than 2 pounds, therefore I have removed some vars.

    The optimal solution is still 16 boxes, for a total cost of 303.68$ (all shipping costs), found in less than 3 minutes.

    HTH,

    Francesco
    Attached Files Attached Files

  11. #11
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    I also tested your new file, nice setup by the way. I did a number of runs with different max time settings. 600 s, 450 s and 900 s. All runs stopped on max time and said a solution was found but when I clicked the "OK" button was told that the solution was not optimal but it was loaded into the spreadsheet.

    Looking at the results I could not see any problem with them. All constraints was met. Checking the output from OpenSolver I found that it took my PC 566 seconds to reach the lowest amount 303,68 and that did not change during the 600 and 900 runs. I got the impression that OpenSolver was aiming for a result around 289??? But I'm not sure I read the output from OpenSolver right.

    The only difference was 450 second run where amount was only 304,82 but them my PC needed 566 second to reach its lowest value.

    Alf
    Last edited by Alf; 09-02-2021 at 03:19 PM.

  12. #12
    Registered User
    Join Date
    09-14-2018
    Location
    China
    MS-Off Ver
    Office 2010
    Posts
    41

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    I suggest applying the 0-1, 18.98, 1-2, 28.98...requirement in the solver setting.

  13. #13
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Quote Originally Posted by kvsrinivasamurthy View Post
    I have given macro code. It results in 16 boxes. ...
    but 4 of them weight more than 1 pound
    11 ITEM #5 , ITEM #14 , ITEM #3
    12 ITEM #3 , ITEM #3 , ITEM #8 , ITEM #8 , ITEM #8 , ITEM #10
    13 ITEM #10 , ITEM #10 , ITEM #10 , ITEM #10 , ITEM #6 , ITEM #6
    14 ITEM #6 , ITEM #6 , ITEM #6 , ITEM #6 , ITEM #6 , ITEM #6 , ITEM #1
    (box 12 even above 2 pounds)
    so the total cost is $50 more than possible best solution (16 boxes, each below $50 and each below 1 pound)

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    All boxes should be less than $50 to avoid import tax fee, which is 60%.
    Op's condition is Cost should be <$50
    Last edited by kvsrinivasamurthy; 09-03-2021 at 04:17 AM.

  15. #15
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    He did not explicit ask that every box should be equal to or less than 1 pound in weight but he asked for minimum costs. And freight cost must be at minimum as this can be influenced by the box weight.

    So if one could replace two 1 pound boxes with one 2 pound box for instance one would save the difference between 2*18.98 and 28.98 you could then save 8.98 but as model is set up to maximize box value this is not possible as all boxes are to close to their maximum value.

    So 16 boxes with weight equal to or less than 1 pound makes a freight cost of 303,68.

    Your solution makes 3 boxes above 1 pound and one box above 2 pounds. This makes a total freight cost of 353,68

    Alf
    Last edited by Alf; 09-03-2021 at 06:10 AM.

  16. #16
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    Let us wait for solver solution with 16 boxes with less than 1 pound.

  17. #17
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    It's already posted, check #post 10 where the file uploaded by Francesco meets all criteria bot weight and cost.

    Alf

  18. #18
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    @Alf
    Thank you

  19. #19
    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: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    You are welcome as I first made the same mistake as you. See post # 6 and 7-

    Alf

  20. #20
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Solver Excel Problem - How to create the optimal boxes mix to respect the constrains

    No problem. We learn something new.

+ 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] Excel Solver- Optimal Salary Lineup- Solver does not find optimal solution
    By Sleven369 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-07-2021, 04:04 PM
  2. Replies: 8
    Last Post: 12-30-2020, 04:12 AM
  3. [SOLVED] constrains in solver
    By elmasguapo in forum Excel General
    Replies: 3
    Last Post: 11-06-2015, 02:32 PM
  4. Markowitz Optimal Portfolio - Excel Solver problem
    By steve.nam in forum Excel General
    Replies: 1
    Last Post: 03-29-2015, 06:00 PM
  5. Excel Solver - Optimal Strategy
    By adodson in forum Excel General
    Replies: 7
    Last Post: 02-22-2015, 06:15 PM
  6. Optimal line up solver problem
    By Levon27 in forum Excel General
    Replies: 4
    Last Post: 06-27-2014, 09:05 PM
  7. Replies: 11
    Last Post: 10-30-2013, 02:11 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