mosek_io
#
- class MosekProblem(domain: Mesh, name: str)[source]#
A generic optimization problem using the Mosek optimization solver.
- Parameters:
domain (dolfinx.mesh.Mesh) – Underlying mesh.
name (str) – Problem name.
- add_convex_term(conv_fun: ConvexTerm)[source]#
Add the convex term conv_fun to the problem.
- add_eq_constraint(A=None, b=0.0, bc=None, name=None)[source]#
Add a linear equality constraint \(Ax = b\).
The constraint matrix A is expressed through a linear form involving optimization variables and Lagrange multiplier test functions. The right-hand side is a linear form involving the same Lagrange multiplier. Naming the constraint enables to retrieve the corresponding Lagrange multiplier optimal value.
- Parameters:
A (Form) – A linear form involving optimization variables. If A contains constant terms, the latter are transferred to the right-hand side b.
b (float, Form) – Right-hand side as a float or a linear form involving the same Lagrange multipliers as in A
bc (dolfinx.fem.dirichletbc) – boundary conditions to apply on the Lagrange multiplier (will be applied to all columns of the constraint when possible)
name (str) – Lagrange multiplier name
- add_ineq_constraint(A=None, bl=None, bu=None, bc=None, name=None)[source]#
Add a linear inequality constraint \(b_l \leq Ax \leq b_u\).
The constraint matrix A is expressed through a linear form involving optimization variables and Lagrange multiplier test functions. The right-hand side is a linear form involving the same Lagrange multiplier. Naming the constraint enables to retrieve the corresponding Lagrange multiplier optimal value.
- Parameters:
A (Form) – A linear form involving optimization variables. If A contains constant terms, the latter are transferred to the right-hand side b.
bl (float, Form) – Lower-bound as a float or a linear form involving the same Lagrange multipliers as in A
bu (float, Form) – Same as bl.
bc (dolfinx.fem.dirichletbc) – boundary conditions to apply on the Lagrange multiplier (will be applied to all columns of the constraint when possible)
name (str) – Lagrange multiplier name
- add_var(V, cone=None, lx=None, ux=None, bc=None, name=None)[source]#
Add a (list of) optimization variable.
The added variables belong to the corresponding FunctionSpace V.
- Parameters:
V ((list of) FunctionSpace) – variable FunctionSpace
cone ((list of) Cone) – cone in which each variable belongs (None if no constraint)
ux ((list of) float, Function) – upper bound on variable \(x \leq u_x\)
lx ((list of) float, Function) – lower bound on variable \(l_x \leq x\)
bc ((list of) DirichletBC) – boundary conditions applied to the variables (None if no bcs)
name ((list of) str) – name of the associated functions
- Returns:
x – optimization variables
- Return type:
Function tuple
- get_lagrange_multiplier(name)[source]#
Retrieves Lagrange multiplier function associated with constraint name.
- get_solution_info(output=True)[source]#
Return information dictionary on the solution.
If output=True, it gets printed out.
- optimize(sense='min', dump=False)[source]#
Write the problem in Mosek format and solves.
- Parameters:
sense ({"min[imize]", "max[imize]"}) – sense of optimization
dump (bool) – dumps the problem to a .ptf file format, default=False
- Returns:
pobj (float) – the computed primal optimal value
dobj (float) – the computed dual optimal value