Title: Maximizing a Nonlinear Function with Local Maxima
1Example 8.1
- Maximizing a Nonlinear Function with Local Maxima
2Background Information
- To see how Evolutionary Solver works, we consider
a simple function that is difficult for the
standard Solvers nonlinear algorithm. - This example, analyzed in Chapter 7, is a
function of a single variable x f(x)(x - 1)(x -
2)(x - 3)(x - 4)(x - 5) for 1 x 5. - We want to maximize f(x) over this range.
- However, the graph of this function shown on the
next slide indicates that there are two local
maxima one at around x 3.5 and the other at x
5. - The global maximum, the one we want, is near x
1.5. - How do we find it with Excel?
3(No Transcript)
4LocalMaximaFunction.xls
- The model is particularly simple.
- It is shown here and in this file.
5Solution
- To set it up, enter any value in cell B6 (the
only changing cell), enter the formula B6-1 in
cell B7, copy this down to cell B11, and enter
the formula PRODUCT(B7B11) in cell B12. - We want to maximize the value in cell B12 while
constraining the value in cell B6 to be between 1
and 5. - If we use the standard Solver, without checking
the Assume Linear Model option, you can check
that the solution depends on the starting value
in cell B6.
6Solution -- continued
- If you didnt have a graph of the function to
lead you in the right direction, how would you
know what to pick as starting points. - Whatever starting point you use, how would you
know whether Solver had found the global maximum? - We now see how Evolutionary Solver can help solve
this problem.
7Using Evolutionary Solver
- Evolutionary Solver uses GAs to obtain good
solutions. - Occasionally, Evolutionary Solver drastically
changesmutatesthe value of a changing cell. - Usually we stop Evolutionary Solver after a
specified time period (say 5 minutes) or when
there has been no improvement in the target cell
value after a given time.
8Using Evolutionary Solver -- continued
- Following is some general information about
Evolutionary Solver - Evolutionary Solver usually finds a good
solution, but there is no guarantee that it will
find the best solution. - Evolutionary Solver is not very efficient at
handling constraints. The best way to handle
constraints is to penalize a violation of a
constraint. The penalty is then included in the
target cell. We do not use penalties in this
example, but we illustrate them in a later
example. - A good starting solutionthe values you place in
the changing cellsusually helps Evolutionary
Solver in its search for an optimal solution.
However, the starting solution is not absolutely
critical to success.
9Using Evolutionary Solver -- continued
- Evolutionary Solver places more of a burden on
you to specify certain parameters of the
algorithm. These parameters are specified in
Options dialog boxes, as we illustrate shortly.
Unfortunately, these parameters are not very
intuitive to most users, and some experimentation
is necessary to find the best settings of these
parameters for any given model. Nevertheless, if
you use the default settings or the settings we
suggest, they should work reasonably well. - Much of the solution process is driven by random
numbers that direct the search. Therefore, two
people can get different solutions to the same
problem. In fact, running Evolutionary Solver a
second time can possibly yield a different
solution! You can set a random seed parameter to
get the same solution on two successive runs.
10Using Evolutionary Solver -- continued
- After Evolutionary Solver has found a good
solution, you can use the GRG Nonlinear Solver
(the nonlinear algorithm included with the
Premium Solver software) to try to find a
slightly better solution. If there is no
improvement, you can probably infer that the
solution found by Evolutionary Solver is close to
optimal.
11Using Evolutionary Solver -- continued
- In general, use the following steps to implement
Evolutionary Solver - Specify the target cell, changing cells, and
constraints. This is done in the usual way. The
only difference is that you should put lower and
upper bounds on all changing cellsin addition to
any other constraints that might be in the model.
At this point, the Solver dialog box should
appear as shown on the next slide.
12(No Transcript)
13Using Evolutionary Solver -- continued
- Select Evolutionary Solver. Click on the Premium
button, and then click on the dropdown list of
available algorithms to select Evolutionary
Solver.
14Using Evolutionary Solver -- continued
- Solver Options. Click on the Options button to
show the Solver Options dialog box. - Max Time is not important. However, if you want
Solver to run unattended, set this to a large
value such as 10,000 seconds. - Iterations is not important. You can leave it at
its default value. - Precision governs how close the constraint values
must be to their bounds, and Convergence is
concerned with the rate of change of the
objective. - Population size is the number of candidate
solutions (chromosomes) at any point in time, and
the default value of 100 should work well
although we sometimes increase it to 150. - Mutation rate governs the frequency at which
mutations are introduced into the population of
solutions.
15Using Evolutionary Solver -- continued
- Evolutionary Solver uses a random mechanism to
perform its search, but you can make it go
through exactly the same calculations on two
separate runs if you use the same Random Seed
(any integer) on each run. - The check boxes at the lower left are much like
the ones of the same names in the standard
Solver. However, you should check the Require
Bounds on Variables option. This forces you to
enter explicit upper and lower bounds on all
changing cells which aids Evolutionary Solver in
its search process. - The radio buttons under Local Search are newthey
werent available in the versionthat accompanied
the second edition of this book. At each step of
the GA, Evolutionary Solver performs a local
search in the neighborhood of the best solution
found so far (the incumbent) to find better
nearby solutions. The options here govern the way
this local search is performed.
16(No Transcript)
17Using Evolutionary Solver -- continued
- Limit Options. Click on the Limit Options button
to bring up the dialog box. - Max Subproblems and Max Feasible Sols both have
to do with the length of time Evolutionary Solver
runs before asking you (with a beep) whether you
want to stop or continue. - Tolerance and Max Time w/o Improvement work in
tandem to specify when Evolutionary Solver should
stop. Specifically, if the percentage improvement
in the best solutions objective value is less
than the Tolerance value for the number of
seconds in the Max Time without Improvement box,
Evolutionary Solver stops and declares the best
solution so far as optimal. We recommend leaving
Tolerance at its default value but possibly
increasing Max Time w/o Improvement to, say, 100
seconds.However, chances are that this will just
let the algorithm spin its wheels at the same
18Using Evolutionary Solver -- continued
- Solve Without Integer Constraints allows you to
ignore integer constraints, at least temporarily,
to get a good noninteger solution. Then you can
recheck this box to add back the integer
constraints
19Using Evolutionary Solver -- continued
- Solve. From the Limit Options dialog box, back
your way out to the beginning Solver dialog box
and click on Solve. You can watch the progress of
the solution process in the status bar of your
screen. In particular, watch the Incumbent,
which is the current best value of the target
cell. - For this particular model, the Evolutionary
Solver gets to the solution shown earlier almost
instantaneously. Then it runs for 30 seconds (the
time we specified in the Limit Options dialog
box) without being able to find a better
solution, at which time it quits.
20Using Evolutionary Solver -- continued
- Evolutionary Solver is not as likely to get stuck
at a local optimum as the standard nonlinear
Solver.