100 template<
typename T1>
105 if (MSK_makeenv(&d->
env, 0) != MSK_RES_OK)
return 1;
106 if (MSK_maketask(d->
env, 0, 0, &d->
task) != MSK_RES_OK)
return 1;
111 template<
typename T1>
114 MSK_deletetask(&d->
task);
118 MSK_deleteenv(&d->
env);
124 template<
typename T1>
126 casadi_int* sz_arg, casadi_int* sz_res, casadi_int* sz_iw, casadi_int* sz_w) {
127 casadi_qp_work(p->
qp, sz_arg, sz_res, sz_iw, sz_w);
136 casadi_socp_work(p->
socp, sz_iw, sz_w);
138 *sz_iw += p->
socp->max_block;
143 template<
typename T1>
145 const T1*** arg, T1*** res, casadi_int** iw, T1** w) {
147 d->
col_idx =
reinterpret_cast<int*
>(*iw); *iw += p->
qp->nx;
148 d->
vtype =
reinterpret_cast<int*
>(*iw); *iw += p->
qp->nx;
155 casadi_socp_init(&d->
socp, iw, w);
156 d->
cone_idx =
reinterpret_cast<int*
>(*iw); *iw += p->
socp->max_block;
167 template<
typename T1>
169 const double** arg,
double** res, casadi_int* iw,
double* w) {
176 int has_mip = p->
coltype ? 1 : 0;
177 MSKtask_t task = d->
task;
181 int n_lifted = (p->
socp) ?
static_cast<int>(p->
socp->n_lifted) : 0;
182 int nvar = p_qp->
nx + n_lifted;
183 int ncon = p_qp->
na + ((p->
socp) ?
static_cast<int>(p->
socp->n_eq) : 0);
186 if (MSK_appendvars(task, nvar) != MSK_RES_OK)
return 1;
187 if (MSK_appendcons(task, ncon) != MSK_RES_OK)
return 1;
188 MSK_putobjsense(task, MSK_OBJECTIVE_SENSE_MINIMIZE);
192 for (j = 0; j < p_qp->
nx; ++j) {
193 MSK_putcj(task, j, d_qp->
g[j]);
198 for (j = 0; j < p_qp->
nx; ++j) {
199 T1 lo = d_qp->
lbx[j], up = d_qp->
ubx[j];
200 int lo_inf = (lo <= -std::numeric_limits<T1>::infinity());
201 int up_inf = (up >= std::numeric_limits<T1>::infinity());
203 if (lo_inf && up_inf) {
206 bk = MSK_BK_UP; lo = -std::numeric_limits<T1>::infinity();
208 bk = MSK_BK_LO; up = std::numeric_limits<T1>::infinity();
209 }
else if (lo == up) {
214 MSK_putvarbound(task, j, bk, lo, up);
218 for (j = 0; j < p_qp->
nx; ++j) {
223 MSK_putacol(task, j, kend - kbeg, p->
rowa + kbeg, d_qp->
a + kbeg);
228 for (i = 0; i < p_qp->
na; ++i) {
229 T1 lo = d_qp->
lba[i], up = d_qp->
uba[i];
230 int lo_inf = (lo <= -std::numeric_limits<T1>::infinity());
231 int up_inf = (up >= std::numeric_limits<T1>::infinity());
233 if (lo_inf && up_inf) {
236 bk = MSK_BK_UP; lo = -std::numeric_limits<T1>::infinity();
238 bk = MSK_BK_LO; up = std::numeric_limits<T1>::infinity();
239 }
else if (lo == up) {
244 MSK_putconbound(task, i, bk, lo, up);
249 for (k = 0; k < p->
nquad; ++k) {
254 != MSK_RES_OK)
return 1;
263 casadi_socp_build(sd);
266 for (j = 0; j < n_lifted; ++j) {
267 int jvar = p_qp->
nx + j;
269 int lo_inf = (lo <= -std::numeric_limits<T1>::infinity());
270 int up_inf = (up >= std::numeric_limits<T1>::infinity());
272 if (lo_inf && up_inf) {
275 bk = MSK_BK_UP; lo = -std::numeric_limits<T1>::infinity();
277 bk = MSK_BK_LO; up = std::numeric_limits<T1>::infinity();
278 }
else if (lo == up) {
283 MSK_putvarbound(task, jvar, bk, lo, up);
288 int eq_offset = p_qp->
na;
289 for (i = 0; i < static_cast<int>(sp->
n_eq); ++i) {
292 MSK_putarow(task, eq_offset + i, kend - kbeg,
294 MSK_putconbound(task, eq_offset + i, MSK_BK_FX,
303 for (b = 0; b < sp->
n_blocks; ++b) {
304 casadi_int bs = sp->
r[b + 1] - sp->
r[b];
305 int base =
static_cast<int>(p_qp->
nx + sp->
r[b]);
306 d->
cone_idx[0] = base +
static_cast<int>(bs - 1);
307 for (j = 0; j < static_cast<int>(bs) - 1; ++j) d->
cone_idx[1 + j] = base + j;
308 MSK_appendcone(task, MSK_CT_QUAD, 0.0,
static_cast<int>(bs), d->
cone_idx);
315 for (j = 0; j < p_qp->
nx; ++j) {
317 ? MSK_VAR_TYPE_INT : MSK_VAR_TYPE_CONT;
319 for (j = 0; j < p_qp->
nx; ++j) {
320 MSK_putvartype(task, j,
321 static_cast<MSKvariabletypee
>(d->
vtype[j]));
328 MSKrescodee trm = MSK_RES_OK;
329 r = MSK_optimizetrm(task, &trm);
331 if (r != MSK_RES_OK) {
341 soltype = MSK_SOL_ITG;
343 MSKbooleant bas_def = 0;
344 MSK_solutiondef(task, MSK_SOL_BAS, &bas_def);
345 soltype = bas_def ? MSK_SOL_BAS : MSK_SOL_ITR;
349 MSKsolstae solsta = MSK_SOL_STA_UNKNOWN;
350 MSKprostae prosta = MSK_PRO_STA_UNKNOWN;
351 MSK_getsolsta(task, soltype, &solsta);
352 MSK_getprosta(task, soltype, &prosta);
356 d_qp->
success = (solsta == MSK_SOL_STA_OPTIMAL ||
357 solsta == MSK_SOL_STA_INTEGER_OPTIMAL ||
358 solsta == MSK_SOL_STA_PRIM_AND_DUAL_FEAS);
363 MSK_getxxslice(task, soltype, 0, p_qp->
nx, d_qp->
x);
367 MSK_getprimalobj(task, soltype, &d->
obj_val);
372 if (d_qp->
lam_x)
for (i = 0; i < p_qp->
nx; ++i) d_qp->
lam_x[i] = 0;
373 if (d_qp->
lam_a)
for (i = 0; i < p_qp->
na; ++i) d_qp->
lam_a[i] = 0;
376 if (d_qp->
lam_a && p_qp->
na > 0) {
377 MSK_getyslice(task, soltype, 0, p_qp->
na, d_qp->
lam_a);
378 for (i = 0; i < p_qp->
na; ++i) d_qp->
lam_a[i] = -d_qp->
lam_a[i];
381 if (d_qp->
lam_x && p_qp->
nx > 0) {
383 MSK_getslxslice(task, soltype, 0, p_qp->
nx, d_qp->
lam_x);
385 for (i = 0; i < p_qp->
nx; ++i)
const casadi_mosek_prob< T1 > * prob
casadi_qp_data< T1 > * qp
casadi_socp_data< T1 > socp
const casadi_socp_prob< T1 > * socp
const casadi_qp_prob< T1 > * qp
UnifiedReturnStatus unified_return_status
const casadi_socp_prob< T1 > * prob