6.5 Conic Exponential Optimization¶
The structure of a typical conic optimization problem is
(see Sec. 12 (Problem Formulation and Solutions) for detailed formulations). We recommend Sec. 6.2 (From Linear to Conic Optimization) for a tutorial on how problems of that form are represented in MOSEK and what data structures are relevant. Here we discuss how to set-up problems with the primal/dual exponential cones.
MOSEK supports two exponential cones, namely:
Primal exponential cone:
\[\EXP = \left\lbrace x \in \real^3: x_0 \geq x_1 \exp(x_2/x_1),\ x_0,x_1\geq 0 \right\rbrace.\]Dual exponential cone:
\[\EXP^* = \left\lbrace s \in \real^3: s_0 \geq -s_2 e^{-1} \exp(s_1/s_2),\ s_2\leq 0,s_0\geq 0 \right\rbrace.\]
For example, consider the following constraint:
which describes a convex cone in \(\real^3\) given by the inequalities:
For other types of cones supported by MOSEK, see Sec. 15.9 (Supported domains) and the other tutorials in this chapter. Different cone types can appear together in one optimization problem.
6.5.1 Example CEO1¶
Consider the following basic conic exponential problem which involves some linear constraints and an exponential inequality:
The affine conic form of (6.15) is:
where \(I\) is the \(3\times 3\) identity matrix.
Setting up the linear part
The linear parts (constraints, variables, objective) are set up using exactly the same methods as for linear problems, and we refer to Sec. 6.1 (Linear Optimization) for all the details. The same applies to technical aspects such as defining an optimization task, retrieving the solution and so on.
Setting up the conic constraints
In order to append the conic constraints we first input the sparse identity matrix \(\afef\) as indicated by (6.16).
The affine conic constraint is then appended using the function Task.append_acc
, with the primal exponential domain and the list of \(\afef\) rows, in this case consisting of all rows in their natural order.
task.append_afes(3)?;
let afeidxs = vec![0, 1, 2 ];
let b = vec![0.0,0.0,0.0];
let domidx = task.append_primal_exp_cone_domain()?;
task.put_afe_f_row_list(afeidxs.as_slice(),
vec![1,1,1].as_slice(),
vec![0,1,2].as_slice(),
vec![0,1,2].as_slice(),
vec![1.0,1.0,1.0].as_slice())?;
task.append_acc(domidx,afeidxs.as_slice(),b.as_slice())?;
The first argument selects the domain, which must be appended before being used, and must have the dimension matching the number of affine expressions appearing in the constraint. Variants of this method are available to append multiple ACCs at a time. It is also possible to define the matrix \(\afef\) using a variety of methods (row after row, column by column, individual entries, etc.) similarly as for the linear constraint matrix \(A\).
For a more thorough exposition of the affine expression storage (AFE) matrix \(\afef\) and vector \(\afeg\) see Sec. 6.2 (From Linear to Conic Optimization).
Source code
extern crate mosek;
use mosek::{Task,Boundkey,Objsense,Streamtype,Solsta,Soltype};
const INF : f64 = 0.0;
fn main() -> Result<(),String> {
let numcon = 1;
let numvar = 3;
let bkc = mosek::Boundkey::FX;
let blc = 1.0;
let buc = 1.0;
let bkx = vec![ Boundkey::FR,
Boundkey::FR,
Boundkey::FR ];
let blx = vec![ -INF, -INF, -INF ];
let bux = vec![ INF, INF, INF ];
let c = vec![ 1.0, 1.0, 0.0 ];
let a = vec![ 1.0, 1.0, 1.0 ];
let asub = vec![0, 1, 2];
//let csub = new int[numvar];
//double[] xx = new double[numvar];
/* Create the optimization task. */
Task::new().expect("Failed to create task")
.with_stream_callback(
Streamtype::LOG,
&mut|msg| print!("{}",msg),
|task| task.with_callback(
&mut |caller| { println!("caller = {}",caller); false },
|task| {
/* Append 'numcon' empty constraints.
The constraints will initially have no bounds. */
task.append_cons(numcon)?;
/* Append 'numvar' variables.
The variables will initially be fixed at zero (x=0). */
task.append_vars(numvar)?;
/* Define the linear part of the problem */
task.put_c_slice(0, numvar, c.as_slice())?;
task.put_a_row(0, asub.as_slice(), a.as_slice())?;
task.put_con_bound(0, bkc, blc, buc)?;
task.put_var_bound_slice(0, numvar, bkx.as_slice(), blx.as_slice(), bux.as_slice())?;
/* Add a conic constraint */
task.append_afes(3)?;
let afeidxs = vec![0, 1, 2 ];
let b = vec![0.0,0.0,0.0];
let domidx = task.append_primal_exp_cone_domain()?;
task.put_afe_f_row_list(afeidxs.as_slice(),
vec![1,1,1].as_slice(),
vec![0,1,2].as_slice(),
vec![0,1,2].as_slice(),
vec![1.0,1.0,1.0].as_slice())?;
task.append_acc(domidx,afeidxs.as_slice(),b.as_slice())?;
task.put_obj_sense(Objsense::MINIMIZE)?;
println!("optimize");
/* Solve the problem */
task.optimize()?;
// Print a summary containing information
// about the solution for debugging purposes
task.solution_summary(Streamtype::MSG)?;
/* Get status information about the solution */
let solsta = task.get_sol_sta(Soltype::ITR)?;
assert!(solsta == Solsta::OPTIMAL);
let mut xx = vec![0.0; numvar as usize];
task.get_xx(Soltype::ITR, & mut xx[..])?;
println!("Optimal primal solution");
for j in 0..numvar as usize {
println!("x[{}]: {:.4}",j,xx[j]);
}
Ok(())
}))
}