... | ... | @@ -60,6 +60,85 @@ Running |
|
|
--maxGenerations=5 --initialPopulation=10 --num-masters=1 \
|
|
|
FiPha3Opt1.tmpl
|
|
|
|
|
|
Basic Syntax
|
|
|
============
|
|
|
|
|
|
One needs to define the design variables, objectives and constraints one by one:
|
|
|
|
|
|
```
|
|
|
d1: DVAR, VARIABLE="x1", LOWERBOUND="-1.0", UPPERBOUND="1.0";
|
|
|
d2: DVAR, VARIABLE="x2", LOWERBOUND="-1.0", UPPERBOUND="1.0";
|
|
|
d3: DVAR, VARIABLE="x3", LOWERBOUND="-1.0", UPPERBOUND="1.0";
|
|
|
```
|
|
|
|
|
|
This defines three design variables named `d1`, `d2` and `d3`.
|
|
|
The variable names `x1`, `x2` and `x3` can be used in objectives and constraints.
|
|
|
Bounds for design variables should always be given. Note the string notation.
|
|
|
|
|
|
```
|
|
|
obj1: OBJECTIVE, EXPR="-energy";
|
|
|
obj2: OBJECTIVE, EXPR="emit_x";
|
|
|
```
|
|
|
|
|
|
This defines two objectives named `obj1` and `obj2`.
|
|
|
The optimiser knows several mathematical functions and methods to access output files (see below).
|
|
|
Without the use of these special methods design variables or the variables from the `.stat` output file at the end of the simulation can be used for optimisation.
|
|
|
Note that objectives are always minimised, so in this case a solution where the final energy is maximal and the final horizontal emittance is minimal is looked for.
|
|
|
|
|
|
```
|
|
|
con1: CONSTRAINT, EXPR="x1+x2<1.0";
|
|
|
con2: CONSTRAINT, EXPR="numParticles>1000";
|
|
|
```
|
|
|
|
|
|
This defines two constraints. The syntax is similar to the `OBJECTIVE` syntax.
|
|
|
The first constraint consists of only design variables and will be evaluated before the simulation.
|
|
|
The second constraint will be evaluated after the simulation.
|
|
|
|
|
|
After defining the individual elements, one needs to define the sets of design variables, objectives and constraints:
|
|
|
|
|
|
```
|
|
|
dvars: DVARS = (d1, d2, d3);
|
|
|
objs: OBJECTIVES = (obj1, obj2);
|
|
|
constrs: CONSTRAINTS = (con1, con2);
|
|
|
```
|
|
|
|
|
|
There can be zero constraints:
|
|
|
|
|
|
```
|
|
|
constrs: CONSTRAINTS = ();
|
|
|
```
|
|
|
|
|
|
Finally, the optimiser command should be added:
|
|
|
|
|
|
```
|
|
|
opt: OPTIMIZE, OBJECTIVES=objs, DVARS=dvars, CONSTRAINTS=constrs;
|
|
|
```
|
|
|
|
|
|
Expression syntax
|
|
|
=================
|
|
|
|
|
|
The `EXPR` The optimiser parser knows the following mathematical functions (which are mapped directly to the STL <cmath> functions with the same name):
|
|
|
|
|
|
- `sqrt(x)` : square root of x
|
|
|
- `pow(x,k)` : x to the power k
|
|
|
- `exp(x)` : _e_ to the power x
|
|
|
- `log(x)` : natural logarithm of x
|
|
|
- `ceil(x)` : round x upward to the smallest integral value that is not less than x.
|
|
|
- `floor(x) : round x downward to smallest integral value that is not greater than x.
|
|
|
- `fabs(x)` : absolute value of x
|
|
|
- `fmod(x,y)`: floating point remainder of x/y
|
|
|
- `sin(x)` : sine of angle x (in radians)
|
|
|
- `asin(x)` : the arcsin of x (return value in radians)
|
|
|
- `cos(x)` : cosine of angle x (in radians)
|
|
|
- `acos(x)` : the arc cosine of x (return value in radians)
|
|
|
- `tan(x)` : tangent of angle x (in radians)
|
|
|
- `atan(x)` : the arc tangent of x (return value in radians)
|
|
|
|
|
|
In addition to this the optimiser parser has one non-STL function:
|
|
|
|
|
|
- `sq(x)` : square of x
|
|
|
|
|
|
*TODO* Methods to access output files
|
|
|
|
|
|
FODO Example
|
|
|
===========
|
... | ... | |