...
You can run optimization from the API.
One common appliation application is to run several iterations of multiple types of optimization, see https://awrcorp.com/download/faq/english/scripts/Optimizers.aspx
Code Snippets
Setting Optimizer Type
...
Code Block | ||
---|---|---|
| ||
Project.Optimizer.Type=6 |
The number will the number in the list when you open the optimizer in the user interface.
We don't recommend setting optimizer by number as this order could change.
Alternately, you can set by the name
...
Code Block | ||
---|---|---|
| ||
Project.Optimizer.Type="Gradient Optimization" |
You can write a simple script to print out all the types.
Code Block | ||
---|---|---|
| ||
|
Sub Main Debug.Clear For i = 1 To Project.Optimizer.TypeCount Debug.Print Project.Optimizer.TypeName(i) Next i End Sub
...
* Alternately, you can write a function to call the optimizer by name and have it return the index if the name is matched, an example is shown below.
Code Block | ||
---|---|---|
|
...
Project.Optimizer.Type=find_opt_type("Simplex Optimizer")
Function find_opt_type(nm As String) As Integer
Dim typ As Integer
typ = -1
For i = 1 To Project.Optimizer.TypeCount
If nm = Project.Optimizer.TypeName(i) Then
typ = i
End If
Next i
If typ = -1 Then
MsgBox ("could not find optimizer name specified:" & nm)
End If
find_opt_type = typ
End Function |
Setting Optimizer Iterations
Very simple
...
Code Block | ||
---|---|---|
| ||
Project.Optimizer.Iterations=1000 |
Running the Optimizer
simple to start, write a loop to check to see if running on when to continue.
...
Code Block | ||
---|---|---|
| ||
Project.Optimizer.Start While Project.Optimizer.Running=True Wend |