MosekCOModel is still an experimental project project. Use with caution,
expect rough corners and untested cases, and the API is subject to change
MosekCOModel
The MosekCOModel crate is a modeling package for building optimization models
with Mosek.rs. The Mosek.rs package is a
relatively thin interface in top of low-level MOSEK
optimizer C API, where MosekModel is an attempt to create an interface that
is more like the MOSEK Fusion modelling interface.
Published crates: https://crates.io/crates/mosekcomodel
Documentation for latest crates: https://docs.rs/mosekcomodel/latest/mosekcomodel/
Design principle
MosekModel allows building a model of the form
min/max c^t x + c_fix
such that Ax_b ∊ K_c
x ∊ K_x
That is affine expressions and conic domains of constraints and variables.
The MosekModel package provides functionality to build the linear expressions.
Simple conic example
Implementing the models
minimize y₁ + y₂ + y₃
such that
x₁ + x₂2 + 2.0 x₃ = 1.0
x₁,x₂,x₃ ≥ 0.0
and
(y₁,x₁,x₂) in C₃,
(y₂,y₃,x₃) in K₃
where C₃ and K₃ are respectively the quadratic and
rotated quadratic cone of size 3 defined as
C₃ = { z₁,z₂,z₃ : z₁ ≥ √(z₂² + z₃²) }
K₃ = { z₁,z₂,z₃ : 2 z1 z₂ ≥ z₃² }
This is the included model cqo1.rs:
extern crate mosekcomodel;
use *;
use *;
Compiling, testing, running
First, to build simply type
Optionally, also pass the --release flag as the Debug build is significantly slower that the release build.
Running examples requires the MOSEK library to be available and a valid MOSEK license file. The simplest solution is to download and unpack the MOSEK distro from MOSEK Downloads, unpack the distro and set relevant environment variable:
- On MS Windows:
set PATH=C:\full\path\to\mosek\binaries;%PATH% - On Mac OSX:
export DYLD_LIBRARY_PATH=/full/path/to/mosek/binaries:$DYLD_LIBRARY_PATH - On Linux:
export LD_LIBRARY_PATH=/full/path/to/mosek/binaries:$LD_LIBRARY_PATH
To run tests, do
A trial license can be obtained from MOSEK Trial license.
Demos
The project also contanis a set of graphical demos. These are in separate
sub-projects in examples/demos since they depend on a lot of external
libraries.
To run these, go to the sub-folder with demos
Then to run, say lowner-john-2d, do
lowner-john-2d
For a set of moving, rotating polygons, computes the minimal bounding ellipsoid containing all polygons (or, in fact all corner points), and the maximum ellipsoid contained in the intersection (when the intersection is non-empty).

lowner-john-outer-3d
For a set of rotating and moving polyhedrons, compute the minimal bounding ellipsoid containing all polyhedrons (or their corner points).

ellipsoid-approximation
For a set of moving and rotating ellipses, compute the outer approximation (minimal ellipse containing all moving ellipses), and inner approximation (maximum ellipe contained in the intersection of all ellipses).

ellipsoid-approximation-3d
For a set of moving and rotating ellipsoids, compute the minimal bounding ellipsoid.

trigpoly
Simple visualization of trigonometric polynomial optimization.

truss
Simple 2D truss design model assigning material to bars in a truss construction. This requires a data file, e.g.
