Mosek¶
Initial setup¶
from pyoptinterface import mosek
model = mosek.Model()
You need to follow the instructions in Getting Started to set up the optimizer correctly.
If you want to manage the license of Mosek manually, you can create a mosek.Env
object and pass it to the constructor of the mosek.Model
object, otherwise we will initialize an implicit global mosek.Env
object automatically and use it.
env = mosek.Env()
model = mosek.Model(env)
The capability of mosek.Model
¶
Supported constraints¶
Supported model attribute¶
Attribute |
Get |
Set |
---|---|---|
Name |
❌ |
❌ |
ObjectiveSense |
✅ |
✅ |
DualStatus |
✅ |
❌ |
PrimalStatus |
✅ |
❌ |
RawStatusString |
✅ |
❌ |
TerminationStatus |
✅ |
❌ |
BarrierIterations |
❌ |
❌ |
DualObjectiveValue |
✅ |
❌ |
NodeCount |
❌ |
❌ |
NumberOfThreads |
✅ |
✅ |
ObjectiveBound |
❌ |
❌ |
ObjectiveValue |
✅ |
❌ |
RelativeGap |
✅ |
✅ |
Silent |
✅ |
✅ |
SimplexIterations |
❌ |
❌ |
SolverName |
✅ |
❌ |
SolverVersion |
✅ |
❌ |
SolveTimeSec |
✅ |
❌ |
TimeLimitSec |
✅ |
✅ |
Supported variable attribute¶
Attribute |
Get |
Set |
---|---|---|
Value |
✅ |
❌ |
LowerBound |
✅ |
✅ |
UpperBound |
✅ |
✅ |
Domain |
✅ |
✅ |
PrimalStart |
❌ |
✅ |
Name |
✅ |
✅ |
Supported constraint attribute¶
Attribute |
Get |
Set |
---|---|---|
Name |
✅ |
✅ |
Primal |
✅ |
❌ |
Dual |
✅ |
❌ |
Solver-specific operations¶
Parameter¶
For solver-specific parameters, we provide get_raw_parameter
and set_raw_parameter
methods to get and set the parameters.
model = mosek.Model()
# get the value of the parameter
value = model.get_raw_parameter("MSK_DPAR_OPTIMIZER_MAX_TIME")
# set the value of the parameter
model.set_raw_parameter("MSK_DPAR_OPTIMIZER_MAX_TIME", 10.0)
Information¶
Mosek provides information for the model. We provide model.get_raw_information(name: str)
method to access the value of information.