+ Reply to Thread
Results 1 to 9 of 9

Solver Range Constraint

  1. #1
    Registered User
    Join Date
    08-07-2014
    Location
    Maryland
    MS-Off Ver
    2010
    Posts
    4

    Solver Range Constraint

    I am using the solver tool for some optimization on a financial portfolio. I am trying to find out a way so that my range of cells has the constraint of being 0 or greater than 10. Any ideas? Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,885

    Re: Solver Range Constraint

    I just used an extra set of cells and a formula that cuts to zero below 10.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    D3 will ofcourse be in the range "By changing variable cells:"
    I have little clue about solver but I'm pretty sure such a non-linearity will make it a lot harder for solver to find a solution.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Registered User
    Join Date
    08-07-2014
    Location
    Maryland
    MS-Off Ver
    2010
    Posts
    4

    Re: Solver Range Constraint

    Thanks for replying Jacc. That helps me pin point which values aren't in the acceptable range but one of my constraints is that the sum of a row that I'm optimizing needs to be a certain number so it doesn't quite get me there. For example, if I tell solver that the sum of this row needs to be 50 and then solver tells me the optimized row of values is 0, 5, 15, 12, 18. Once I make 5 a 0 instead, then my sum is 45.

    Anyone else have an idea?

  4. #4
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,885

    Re: Solver Range Constraint

    That's pretty much exact the setup I had. Here is a workbook so you can see what I mean.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-07-2014
    Location
    Maryland
    MS-Off Ver
    2010
    Posts
    4

    Re: Solver Range Constraint

    Right, but that doesn't help me. Unless I'm mistaken?

  6. #6
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,885

    Re: Solver Range Constraint

    The way I see it, it does solve the problem of implementing your constraints. Part of the constraint is implemented in solver and the other part in a formula. Probably not making life easy for Solver but that's what I could come up with. I have minor knowledge of solver, Alf, shg and some other guys here on the forum are known for knowing solver. At least Alf have a tendency to find these threads.
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,437

    Re: Solver Range Constraint

    It is difficult to make any specific suggestions based on so little information about the problem. Can you explain the algorithm you are using or wanting to use to optimize this financial portfolio? What is your objective function? How do the decision variables impact the objective function? So much of a Solver problem is less about Solver and more about what you are using for an objective function. When you want to include constraints like this that are non-continuous -- the algorithms have to be even more carefully thought through.

    Your profile says you are using 2010. Which Solver algorithm are you using -- evolutionary or GRG non-linear? Evolutionary algorithm is computationally more intense, but often does better with non-continuous functions/constraints. If functions (like if x<10 then 0) tend to create non-continuous functions. So, the evolutionary algorithm may have more success on a problem like this, but it will not be backwards compatible to earlier versions of Excel/Solver.

    One strategy I sometimes use for constraints like sum(decision variables)=50 is to hard code the constraint in the spreadsheet rather than adding a constraint to the Solver model. A formula for the last decision variable =50-sum(other decision variables) (then only use the other decision variables in the by changing field in Solver) will force the summation without relying on Solver's numerical algorithms to meet the constraint.

    One thought re: if(xi<10,0,xi) -- It might be easiest to Solve the problem first without this condition present. After Solver has optimized the problem once, you can manually go through and set each xi that is less than 10 to 0, then re-run Solver again, removing these 0's from the list of decision variables. Unless something in the model pushes everything below 10, I expect it would only take a couple of "iterations" like this to get the final solution.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  8. #8
    Registered User
    Join Date
    08-07-2014
    Location
    Maryland
    MS-Off Ver
    2010
    Posts
    4

    Re: Solver Range Constraint

    MrShorty - Thanks a bunch for the reply. I'll take a stab at better explaining my algorithm.

    My objective function is to minimize a cell which is the sum of my costs this is 3 * 8 = 24 total costs. The costs are a function of factors (values which are already "set") multiplied by the amount of dollars going into each asset class (8) in each investment vehicle (3). I have two constraints: 1.) The sum of each investment vehicle is a set value that I have input. already. 2.) The sum of each asset allocation is a set percentage that I have input already. All of these percentages result in a value that is over 10.

    Basically I have 3 different types of investment vehicles (IRA, 401k, taxable) and 8 different types of asset allocations (stocks, bonds, international, etc.) that I am trying to minimize my costs on.

    Yes, I am using 2010. I am a newb to using solver. I might have used it once or twice a few years ago in college. Evolutionary certainly does take much longer to run. GRC non-linear and Simplex LP come up with the the same answer and give me answers quickly. Only 1 of my 24 optimized cells is coming out over 0 but less than 10 so it is quite easy to manually move this one value to another cell at the end. Just trying to skip the step of hard entering this and rerunning it again from another array.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,437

    Re: Solver Range Constraint

    Only 1 of my 24 optimized cells is coming out over 0 but less than 10 so it is quite easy to manually move this one value to another cell at the end. Just trying to skip the step of hard entering this and rerunning it again from another array.
    It sometimes seems like our goal in life is to automate everything possible. Sometimes we maybe need to think this through. I do a lot of things manually that I'm sure could be automated. I still do them manually because I figure it will take more time and effort to automate them than it takes to do them manually. Sometimes we need to step back and judge whether the effort to avoid a simple manual step is worth the extra effort it will take.

    When you tried the evolutionary engine, did it find a different, better solution than the others? Based on what I see, Jacc's IF() function coupled with the evolutionary engine might be the simplest approach to avoiding the manual step -- but only if the evolutionary engine proves able to handle this IF() function.

+ 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, # of categories used Constraint
    By exitonly in forum Excel General
    Replies: 8
    Last Post: 05-16-2013, 06:57 AM
  2. BUY-IN Constraint in Solver
    By WhamBam in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-07-2012, 02:30 AM
  3. Setting up Solver constraint
    By Jstewart304 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2012, 01:36 PM
  4. A wacky solver constraint
    By simonsays in forum Excel General
    Replies: 0
    Last Post: 09-08-2006, 05:14 PM
  5. [SOLVED] solver constraint
    By jojo in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-18-2005, 10:06 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