General Commands > About General Commands > model.opt()

model.opt()
Optimization interface.
Syntax
model.opt().objective().create(<tag>,type)
model.opt().objective(<tag>).set(property,<value>)
 
model.opt().constr().create(<tag>)
model.opt().constr(<tag>).etc
 
model.opt().gconstr().create(<tag>)
model.opt().gconstr(<tag>).constr(<constrExpr>)
model.opt().gconstr(<tag>).lbound(<lboundExpr>)
model.opt().gconstr(<tag>).ubound(<uboundExpr>)
Description
The purpose of model.opt is to manage information relating to optimization and sensitivity analysis. Most of the fields under model.opt are read and interpreted directly by the optimization and sensitivity solvers. They never affect the result of other solvers.
model.opt().objective().create(<tag>,type) adds an objective function of the specified type. The supported types are Global and LeastSquares.
model.opt().objective(<tag>).set(property,<value>) sets an objective function property. Objective functions of type Global support the single property expr, which takes a globally defined expression as value. Allowed properties for objectives of type LeastSquares are described below.
model.opt().objective(<tag>).selection().named(<seltag>) assigns the objective function to the named selection <seltag>.
model.opt().objective(<tag>).selection().set(...) defines a local selection that assigns the objective function to geometric entities. For a complete list of methods available under selection(), see model.selection(). Only objective functions of type LeastSquares require a selection. See further below.
model.opt().constr().create(<tag>) adds a pointwise (mesh-based) constraint on the control variables. The syntax is shared with model.constr() with the exception that the ctype parameter expects values constr, lbound, and ubound for constraint, lower bound, and upper bound, respectively.
model.opt().gconstr().create(<tag>) registers a global constraint with the optimization solvers. Such constraints consist of a globally available expression, which can depend both on optimization variables and on the forward PDE solution, together with likewise global expressions for lower and upper bound.
model.opt().gconstr(<tag>).constr(<constrExpr>) specifies a global constraint expression.
model.opt().gconstr(<tag>).lbound(<lboundExpr>) sets lower bound for the constraint.
model.opt().gconstr(<tag>).ubound(<lboundExpr>) sets upper bound for the constraint.