Search code examples
excelvbasolver

Excel Solver explanation


I am using the excel solver to maximize a likelihood function, depending on three parameters, places in cells (for example) A3, A4, A5. The constraints of the optimization are:

  1. A3 >= 0
  2. A4 > 0
  3. A5 > 0
  4. A4 + A5 < 1

To manage the fourth point, I create an auxiliary cell (say A6) containing the sum of A4 and A5. Thus, the constraints passed to the solver function become:

  1. A3 >= 0
  2. A4 > 0
  3. A5 > 0
  4. A6 < 1

Despite this, sometimes I get an error because the solver tries to use values for A4 and A5 that add up to a number greater than 1. In other words, it seems that the condition A6 < 1 (A4 + A5 < 1) is not always considered during optimization.

Does anyone know how to deal with this problem?


Solution

  • Solver works by trial and error methods and tries to refine solutions based on what gets you closer to your target within the defined criteria. For non-linear but still reasonably smooth problems, there may be solution "wells" where if you can get close to a solution, you can refine it to find a better solution. But if the problem is not smooth, "near" solutions may not guide it towards valid solutions, or there may be such tiny solution wells that the solver just never manages to find a valid solution. It may also just be possible that no solution exists.

    The first step to try to solve the problem is to try the different solver methods, as different methods are better for different solution "surface" behaviors.

    You can also try seeding the solver by placing at least one set of "reasonable" values in the cells being changed.

    As a simple example, setting B1 formula of "=A1^2" and then solving for the largest possible B1 by changing A1 with constraint of B1<=16 seems quite simple... it should be able to figure out A1 = 4 easily. But it only works if A1 has a positive value. Any negative value or starting from 0 gives the wrong answer of 0.