+ Reply to Thread
Results 1 to 9 of 9

Solver error - Linearity condition not satisfied

  1. #1
    Registered User
    Join Date
    04-14-2021
    Location
    Iowa, USA
    MS-Off Ver
    2019
    Posts
    5

    Solver error - Linearity condition not satisfied

    Hello Friends,
    I am trying to run a seemingly simple solver optimization. to find the minimum cost of funding a portfolio with debt of different tenors and have a few constraints. Bu solver me giving this error "Linearity conditions required by LP Solver are not satisfied". I have done a lot of research on the internet for solutions. But have had no success. I am attaching the excel sheet here.
    Thank you in advance for your help.
    Regards
    Attached Files Attached Files

  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: Solver error - Linearity condition not satisfied

    The linear Solver can not work with CountIf and If functions. This is because these are discontinuous functions. Solver is not capable of determining a "finite difference" to help with a
    derivative. Then there is also the division in formula F7 and G7.

    The GRG Non-Linear engine may sometimes manage that and the evolutionary engine will find a solution in this case. But for a solution using the simplex engine you have to rebuild your mode.

    Alf
    Last edited by Alf; 04-15-2021 at 02:35 AM.

  3. #3
    Registered User
    Join Date
    04-14-2021
    Location
    Iowa, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: Solver error - Linearity condition not satisfied

    Thanks for your reply. Will Linear engine not work because of the divisions in cell F7 and G7. I tried the GRG and Evolutionary engine. They too don't give the right solutions. I will try to think how to workaround the Countif that I have in E26.

  4. #4
    Registered User
    Join Date
    04-14-2021
    Location
    Iowa, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: Solver error - Linearity condition not satisfied

    I tried to take out the Countif condition from E26. But it didn't solve the issue. So the division in F7 and G7 might be causing the issue.

  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 error - Linearity condition not satisfied

    Deleted my comments as my suggestion was made on a wrong assumption.

    Alf
    Last edited by Alf; 04-16-2021 at 10:41 AM.

  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 error - Linearity condition not satisfied

    Quote Originally Posted by tapaspanda1321 View Post
    So the division in F7 and G7 might be causing the issue.
    Assuming that c is a constant, a constraint like

    a/b < c

    can always be written in a linear form as

    a < b*c

    However, this workaround will not solve the COUNTIF problem. For that, you need an additional set of variables and constraints.

    Let me know if the attached file works for you.

    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.

  7. #7
    Registered User
    Join Date
    04-14-2021
    Location
    Iowa, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: Solver error - Linearity condition not satisfied

    Hi Francesco, Thanks for your help and sorry for the delayed response. I didn't understand the use constraint you put in your file for column G. Was it necessary? What is it trying to do?. Also one of the condition was not as per the requirement. I will attach the sheet with corrected condition.
    Last edited by tapaspanda1321; 04-19-2021 at 03:46 PM.

  8. #8
    Registered User
    Join Date
    04-14-2021
    Location
    Iowa, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: Solver error - Linearity condition not satisfied

    here is the attachment
    Attached Files Attached Files

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

    Re: Solver error - Linearity condition not satisfied

    In your worksheet, the use of COUNTIF in cell E26 makes the model non-linear. This isn't bad in itself, but we must rely on GRG or Evolutionary engines if we want a solution, and we can't be sure it is the best one.

    The constraints are needed only if you want to solve your problem using Simplex, because they will transform your model from non-linear to linear.
    The trick is to first introduce a set of binary variables, so that we can use a simple (and linear) function as SUM in E26, and then add some constraints that will switch the variables to 1 as soon as the Funding is > 0.

    This choice has several advantages: we are sure that the found solution (if it exists) is optimal, solving time is very small, and even the standard Solver engine can return a result. In the file ver.2 I have updated the conditions, and the answer looks reasonable, but feel free to test it with different inputs. Please note, however, that there may be no solution to your problem if Funding needs is set too low.

    We can also decide to keep the non-linearities, and multiply binary and continuos variables by each other in every row (the funding is > 0 only when the associated binary var is 1), but then we need a better engine than the standard ones bundled with Excel. This can be found in OpenSolver, a free Add-In you can download here. If you decide to try it, get the advanced version. In file ver.3 I have already setup the engine for this problem (Couenne), and as you can easily test, the result is the same as ver.2.

    HTH,

    Francesco
    Attached Files Attached Files
    Last edited by Hydraulics; 04-25-2021 at 04:48 AM.

+ 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 - linearity requirements not met in binary variable
    By tiredandconfused in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2020, 09:34 PM
  2. If condition satisfied but ignored
    By remkin76 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2019, 12:58 AM
  3. Replies: 5
    Last Post: 08-18-2016, 09:13 AM
  4. Replies: 7
    Last Post: 06-01-2015, 06:05 PM
  5. Replies: 0
    Last Post: 08-02-2014, 03:22 PM
  6. Excel Solver: linearity and MOLP
    By fboehlandt in forum Excel General
    Replies: 1
    Last Post: 12-16-2010, 03:07 PM
  7. [SOLVED] solver constaints not satisfied
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2006, 03:45 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