4. Nonlinear problems with What’s Best! What’s Best! have a number of solvers. If we have a linear problem, it recognizes that and normally uses the simplex method. If we have a nonlinear problem it has a number of different methods that it will try. When solving nonlinear problems with a computer, numerical methods are normally the only choice. Numerical methods have the disadvantage that they normally only finds a local optima. If we have a problem which could have multiple local optima, we have to check whether the program have found the right optima. There are different types of adjustables in What’s Best! Adjustable Positive reel number Creates easiest by using (Make Adjustable), For more info see pages 17-20 Free
Reel number that can be both positive and negative. WB! / Adjustable / Make Adjustable & Free, Note! You have to give the area with Free-variables a name For more info see pages 19-20
Integer
nonnegative integer {0, 1, 2, 3 …..} WB! / Integer (choose General – WBINT) Note! You have to give the area with Integer-variables a name For more info see pages 34-35
Binary
integer, only {0, 1} WB! / Integer (choose Binary – WBBIN) Note! You have to give the area with Binary-variables a name For more info see pages 34-35
What’s Best! works like this: 1. 2. 3. 4. 5. 6.
It reads the excel file Creates a model Classifies the problem and selects method of solution Solves the problem Saves the result in the excel file (adjustables) Checks that Excel computes the same value of the “best cell”.
This means that What’s Best! have to understand all the functions we are using in our problem specification. If What’s Best! finds a cell that it doesn’t understand how to compute, it will give a warning and threat the cell as a constant value that doesn’t depend on the adjustables. Usually you also get warning that What’s Best! and Excel calculates different values of the “best cell”. One example of a function that is not supported is radians() (conversion of degree to radians) A supported function that should be avoided if possible is IF() See chapter 5 for supported functions.
H:\Optimering\2009 Simulering och Optimering av energisystem\WhatsBest nonlinear\Optimering och Whats Best - engelska.doc 2009-04-02
17
What’s Best! Classifies a problem as: • • •
Linear (easily solved) Quadratic (needs a license we don’t have) Nonlinear (is usually tricky)
All three above may be combined with integer number problem. A method solving integer problems is to test all possible combinations of integer values. But at least in combination with linear problems there are methods to reduce the number of combinations that has to be tested. One of the methods are called branch-and-bound. The success of nonlinear problems depends much of how the problem is formulated. Good starting values may sometimes be needed if WhatsBest will find a any, or the correct solution. If a error occurs, all adjustables are set to zero, so the model will be much easier to cope with if it is formulated in a way that cleared adjustables gives a model that is mathematically correct. If the constraints also are fulfilled, it normally works even better. Considering that we have a insulated tube that should be optimized: r1=the inner diameter inside the tube r2=the outer diameter of the tube r3=the outer diameter of the insulation If r1, r2 and r3 are set as adjustables we get problem if any of the diameters are zero, or if they are in incorrect order. This could might solved by constraints, but the model normally works much better if it is formulated something like: r1=a1+0,001 r2=r1+a2+0,001 r3=r2+a3+0,001 where a1, a2 and a3 are adjustable and 0,001 is for the problem a small number. Recommended reading: ”Guidlines for Modelling with WhatsBest!” page 142-144. The rest of chapter 6 is also good reading. Recommend examples: • • •
Flow Network Modelling page 160-164 Seasonal sales factoring page 193-197 Blending page 149-152
H:\Optimering\2009 Simulering och Optimering av energisystem\WhatsBest nonlinear\Optimering och Whats Best - engelska.doc 2009-04-02
18
Låt oss lösa vårt gamla demo-problem från Lagrange, P8.7 Konvektionskoefficienten, h, ges av:
h = 2 + 0.55θ 0.27 D −1.2
där D är diametern på en sfärisk reaktor och θ är temperaturskillnaden till omgivningen. Värmeförlusten ges av
q = hA(Ts − Ta )
Den sfäriska reaktorns yta ges av:
A = πD 2
Pga hållfasthetskrav har vi villkoret:
Dθ = 75
Bestäm de D och som ger den minsta värmeförlusten. Vi startar excel och skriver in nedanstående: Diameter 1 Theta 1 h= 2,55 A= 3,141593 Krav 1 q=
75
8,011061
Cellerna till höger om Diameter och Theta sätter vi till ett godtyckligt numeriskt värde ”1” Cellerna till höger om h=, A=, Krav och q= beräknas enligt de samband vi har. Cellen till vänster om 75 markeras och vi trycker sedan på villkorsknappen ”=”. Sedan markerar vi de två godtyckliga cellerna och trycker på knappen ”Make adjustable” Vi markerar cellen till höger om q= och trycker sedan på knappen ”Minimize” Excelarket visar då följande: Diameter 1 Theta 1 h= 2,55 A= 3,141593 Krav 1 q=
Not =
75
8,011061
Nu är det dags att lösa problemet, vi trycker på knappen Solve (måltavlan) Whats Best skapar nu ett nytt kalkylblad, WB! Status, där den lägger en del information om lösningen:
H:\Optimering\2009 Simulering och Optimering av energisystem\WhatsBest nonlinear\Optimering och Whats Best - engelska.doc 2009-04-02
19
What'sBest!® 8.0.4.0 (Apr 06, 2006) - Library 4.1.1.13 - Status Report DATE GENERATED:
apr 10, 2006
06:53 PM
MODEL INFORMATION: CLASSIFICATION DATA Current Capacity Limits -------------------------------------------------------Numerics 5 Variables 7 Adjustables 2 2000 Constraints 1 1000 Integers/Binaries 0/0 200 Nonlinears 4 200 Coefficients 14 Minimum Minimum Maximum Maximum
coefficient coefficient coefficient coefficient
value: in formula: value: in formula:
1 on Blad1!D8 Blad1!D8 75 on Blad1!E10
MODEL TYPE:
Nonlinear
SOLUTION STATUS:
LOCALLY OPTIMAL
OPTIMALITY CONDITION:
SATISFIED
OBJECTIVE VALUE:
809.82392600084
DIRECTION:
Minimize
SOLVER TYPE:
Multistart
TRIES:
120
INFEASIBILITY:
0
Den viktigaste informationen är Solution status: Locally Optimal Växlar vi över till kalkylbladet där vi matade in nyss, ser vi: Diameter 0,549452 Theta 136,4996 h= 6,255319 A= 0,94844 Krav 75 q=
=
75
809,8239
Nu kan vi gå in i menyn WB! / Options / Global solver och sätta en bock framför Global Solver, OK.
H:\Optimering\2009 Simulering och Optimering av energisystem\WhatsBest nonlinear\Optimering och Whats Best - engelska.doc 2009-04-02
20
Ett nytt tryck på knappen Solve-knappen ger efter några sekunder följande rapport: What'sBest!® 8.0.4.0 (Apr 06, 2006) - Library 4.1.1.13 - Status Report DATE GENERATED:
apr 10, 2006
06:59 PM
MODEL INFORMATION: CLASSIFICATION DATA Current Capacity Limits -------------------------------------------------------Numerics 5 Variables 7 Adjustables 2 2000 Constraints 1 1000 Integers/Binaries 0/0 200 Globals 4 10 Coefficients 14 Minimum Minimum Maximum Maximum
coefficient coefficient coefficient coefficient
value: in formula: value: in formula:
1 on Blad1!D8 Blad1!D8 75 on Blad1!E10
MODEL TYPE:
Nonlinear
SOLUTION STATUS:
GLOBALLY OPTIMAL
OPTIMALITY CONDITION:
SATISFIED
OBJECTIVE VALUE:
809.82392600084
DIRECTION:
Minimize
SOLVER TYPE:
Global
TRIES:
10595
INFEASIBILITY:
0
BEST OBJECTIVE BOUND:
809.82315341434
STEPS:
73
Nu anser Whats Best att den hittat ett globalt minimum!
Lämpliga övningsuppgifter: Övningsuppgifterna P1 och P3 från Lagrange. Exempel acktank med påbyggnad av start/stopp
H:\Optimering\2009 Simulering och Optimering av energisystem\WhatsBest nonlinear\Optimering och Whats Best - engelska.doc 2009-04-02
21