+ Reply to Thread
Results 1 to 8 of 8

How can I make my formula linear to work with Solver?

  1. #1
    Registered User
    Join Date
    01-27-2020
    Location
    Tulsa,Ok
    MS-Off Ver
    365 ProPlus
    Posts
    17

    How can I make my formula linear to work with Solver?

    I'm trying to use solver to find the minimum cost but when I try and run it excel tells me my objective function isn't linear. Is it possible to make my total cost formula (cell B1) linear?
    Attached Files Attached Files

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

    Re: How can I make my formula linear to work with Solver?

    The Solver model in your uploaded sheet is full of Ref errors, so it is difficult to know exactly what your solver model was intended to be. I recommend that you upload a new sheet with your current solver model (without the errors) or explain the solver model you are trying to use.
    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
    01-27-2020
    Location
    Tulsa,Ok
    MS-Off Ver
    365 ProPlus
    Posts
    17

    Re: How can I make my formula linear to work with Solver?

    Here is the full model. Thank you in advance! I tried using the Grg nonlinear option in solver and it ran for 24hrs and still didn't have a solution. I've read it's faster if you can make your objective function linear but I don't know if that's possible.
    Attached Files Attached Files

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

    Re: How can I make my formula linear to work with Solver?

    I'm not an expert on these kind of things, so I'm not certain exactly what makes a model "linear". I believe that integer/binary constraints are significant source of "non-linearity", so that it may not be possible to coerce a model like this -- where you are using binary decision variables to choose products -- into a truly linear problem.

    A quick internet search found this page in Frontline's Solver tutorial: https://www.solver.com/hard-models This page and links branching off of that page talk about some of the things that make models easy or difficult to solve and the role of integer and binary constraints in making a model difficult to solve.

  5. #5
    Registered User
    Join Date
    01-27-2020
    Location
    Tulsa,Ok
    MS-Off Ver
    365 ProPlus
    Posts
    17

    Re: How can I make my formula linear to work with Solver?

    Thank you MrShorty, I've read most of these and many others and it makes my brain spin. I just don't understand enough of it to understand what they're talking about.

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

    Re: How can I make my formula linear to work with Solver?

    I can't help you there. I don't understand most of it either. I do know that optimization algorithms are an active area of research, that the algorithms are often not specific to any programming language (so this isn't just an Excel question), and that they can require significant effort to understand.

    The key point that I see is that it takes more time/effort to solve a problem with many integer/binary variables. Part of improving a given model is to minimize the number of integer/binary decision variables. I brainstorm some ideas below, but if you don't want to read it all, my suggestion is to reduce the number of binary decision variables in the model.

    Using something like a greedy algorithm (which may not give me a guaranteed optimum solution, but may help me understand the behavior of the system), I quickly check the limits of the model.

    1) I see that you want to order at least 1100 total tons (column O).
    2) I see that Vendor C has the highest average cost per ton.
    3) I see that Vendors C and D have the lowest minimum order.
    4) I see that Vendor B has the lowest average cost per ton (by far). Vendor B also has the highest minimum order.

    At this point, I might ask myself if it is cheaper to buy the entire order from Vendors C or D (where I don't have to purchase any extra) or to purchase the entire order from Vendor B and order enough extra to meet the minimum order. Assuming that the optimum solution will be to buy the entire order from one of the five vendors (and likely either Vendor D because of the low minimum order or Vendor B because of the low cost/ton), I have reduced my number of binary decision variables from 60 to 5. That should dramatically improve the time needed to find an optimum solution (I might not even need Solver to do it for me).

  7. #7
    Registered User
    Join Date
    05-08-2020
    Location
    Lublin, Poland
    MS-Off Ver
    2003, 2007, 2010, 2019 (home); 2002, 2007, 2016, 365 (work)
    Posts
    69

    Re: How can I make my formula linear to work with Solver?

    Quote Originally Posted by osugirl7 View Post
    Here is the full model. Thank you in advance! I tried using the Grg nonlinear option in solver and it ran for 24hrs and still didn't have a solution. I've read it's faster if you can make your objective function linear but I don't know if that's possible.
    I downloaded your file. The model looked very complicated at first glance but I dare to say it isn't that much.
    1. Non-linearity comes from SUMPRODUCT formulas like =SUMPRODUCT(U9:U20,AC9:AC20,V9:V20) in U1. It is caused by multiplication of variables whose Solver equivalents are U9:U20 and V9:V20, respectively. These are products like U9*V9, U10*V10 and so on. But you can omit V9:V20 in the formula. Why? Because of formulas in the column W like =U9-$BP$9*V9 and constraints W9:W20<=0. Those constraints force that if a binary-valued cell like V9 has a "zero" value, then U9 also must be zero. The contribution to the SUMPRODUCT result from U9*AC9*V9 is the same as from U9*AC9, namely zero. What if a binary-valued cell like V9 has a "one" value? Then U9 is positive (but it doesn't really matter) and again, U9*AC9*V9= U9*AC9 (because V9 is one). So you can replace =SUMPRODUCT(U9:U20,AC9:AC20,V9:V20) with =SUMPRODUCT(U9:U20,AC9:AC20) (as well as other analogical SUMPRODUCTs. You don't lose anything on acuraccy of the model, you gain linearity.
    2. I don't really know what binary variables are for in the model. I guess that each Qty in tons must be lower than 346.5. So why don't you just use constraints like U9:U20<=$BP$9? After investigating the formulas which refer to binary valued cells like V9:V20, it seems that they are referenced to in SUMPRODUCTs in row 1 and formulas labeled as "Fixed cost constr." and nowhere else. I can't see any fixed costs in the objective function (SUMPRODUCTs depend on costs/ton only).
    Last edited by PKowalik; 05-09-2020 at 06:07 AM.

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

    Re: How can I make my formula linear to work with Solver?

    Quote Originally Posted by osugirl7 View Post
    Here is the full model. Thank you in advance! I tried using the Grg nonlinear option in solver and it ran for 24hrs and still didn't have a solution. I've read it's faster if you can make your objective function linear but I don't know if that's possible.
    =SUMPRODUCT(AD9:AD20,AL9:AL20,AE9:AE20) two variable multiplies, this is not linear. You should set contraints to the binary variables using the Big M method to make sure the binary integers changes along with the other variables. You can search in the internet with keywords "Big M Method Integer programming".

+ 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. Solver: How to maximize a mark average (non-linear problem) in a linear way?
    By Sunday4th in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-07-2017, 07:42 AM
  2. Excel solver - Trouble with linear programming using solver excel
    By spicyscreamer in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-04-2017, 08:01 AM
  3. [SOLVED] Linear Equations Example - Solver
    By zanshin777 in forum Excel General
    Replies: 12
    Last Post: 10-03-2015, 10:39 AM
  4. Linear program using Excel Solver
    By natygrosso in forum Excel General
    Replies: 6
    Last Post: 07-02-2014, 09:00 PM
  5. [SOLVED] Excel Solver linear program
    By Johnford in forum Excel General
    Replies: 5
    Last Post: 10-25-2012, 02:40 AM
  6. non linear equations solver using VBA
    By mwalshe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2010, 11:10 AM
  7. [SOLVED] linear model with solver
    By vert in forum Excel General
    Replies: 1
    Last Post: 04-04-2006, 11:35 AM

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