mosek_io#

class fenics_optim.mosek_io.MosekProblem(name='')#

A generic optimization problem using the Mosek optimization solver.

add_convex_term(conv_fun)#

Add the convex term conv_fun to the problem.

add_eq_constraint(Vy, A=None, b=0.0, bc=None, name=None)#

Add a linear equality constraint \(Ax = b\).

The constraint matrix A is expressed through a bilinear form involving the corresponding Lagrange multiplier defined on the space Vy. 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
  • Vy (FunctionSpace) – FunctionSpace of the corresponding Lagrange multiplier

  • A (function) – A function of signature y -> bilinear_form where the function argument y is the constraint Lagrange multiplier.

  • b (float, function) – A float or a function of signature y -> linear_form where the function argument y is the constraint Lagrange multiplier (default is 0.0)

  • bc (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(Vy, A=None, bu=None, bl=None, bc=None, name=None)#

Add a linear inequality constraint \(b_l \leq Ax \leq b_u\).

The constraint matrix A is expressed through a bilinear form involving the corresponding Lagrange multiplier defined on the space Vy. The right-hand sides are linear forms involving the same Lagrange multiplier. Naming the constraint enables to retrieve the corresponding Lagrange multiplier optimal value.

Parameters
  • Vy (FunctionSpace) – FunctionSpace of the corresponding Lagrange multiplier

  • A (function) – A function of signature y -> bilinear_form where the function argument y is the constraint Lagrange multiplier.

  • bl (float, function) – A float or a function of signature y -> linear_form where the function argument y is the constraint Lagrange multiplier (default is 0.0)

  • bu (float, function) – same as bl

  • bc (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_obj_func(obj)#

Add an objective function.

Parameters

obj (list of float, function) – objective function described either as a list of floats or as a linear form.

add_var(V, cone=None, lx=None, ux=None, bc=None, name=None, int_var=False)#

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

  • int_var ((list of) bool) – True if variable is an integer, False if it is continuous (default)

Returns

x – optimization variables

Return type

Function tuple

get_lagrange_multiplier(name)#

Return the corresponding Lagangrage multiplier from its name.

get_solution_info(output=True)#

Return information dictionary on the solution.

If output=True, it gets printed out.

get_var(name)#

Return the corresponding variable from its name.

optimize(sense='min', get_bound_dual=False)#

Write the problem in Mosek format and solves.

Parameters
  • sense ({"min[imize]", "max[imize]"}) – sense of optimization

  • get_bound_dual (bool) – if True, optimal dual variable bounds will be stored in self.sux and self.slx

Returns

pobj – the computed optimal value

Return type

float