112 template<
typename T1>
116 if (XPRScreateprob(&d->
xprob))
return 1;
121 template<
typename T1>
124 XPRSdestroyprob(d->
xprob);
130 template<
typename T1>
132 casadi_int* sz_arg, casadi_int* sz_res, casadi_int* sz_iw, casadi_int* sz_w) {
133 casadi_qp_work(p->
qp, sz_arg, sz_res, sz_iw, sz_w);
141 if (p->
socp) casadi_socp_work(p->
socp, sz_iw, sz_w);
145 template<
typename T1>
147 const T1*** arg, T1*** res, casadi_int** iw, T1** w) {
149 d->
qrtype =
reinterpret_cast<char*
>(*iw); *iw += p->
qp->na;
150 d->
col_idx =
reinterpret_cast<int*
>(*iw); *iw += p->
qp->nx;
151 d->
rhs = *w; *w += p->
qp->na;
152 d->
rng = *w; *w += p->
qp->na;
157 casadi_socp_init(&d->
socp, iw, w);
164 #ifndef XPRS_LOG_ERROR
165 #define XPRS_LOG_ERROR(FN, PROB, LEVEL) \
166 char xprs_msg[XPRS_MAXMESSAGELENGTH] = {0}; \
167 XPRSgetlasterror((PROB), xprs_msg); \
168 uerr() << LEVEL " (" #FN "): " << xprs_msg << "\n"
171 #define XPRS_WARN(FN, PROB, ...) \
173 if (FN((PROB), __VA_ARGS__) != 0) { \
174 XPRS_LOG_ERROR(FN, PROB, "Warning"); \
179 #define XPRS_RETURN(FN, PROB, ...) \
181 if (FN((PROB), __VA_ARGS__) != 0) { \
182 XPRS_LOG_ERROR(FN, PROB, "Error"); \
196 template<
typename T1>
198 const double** arg,
double** res, casadi_int* iw,
double* w) {
205 int has_mip = p->
coltype ? 1 : 0;
208 for (i = 0; i < p_qp->
na; ++i) {
209 T1 lo = d_qp->
lba[i];
210 T1 up = d_qp->
uba[i];
211 int lo_inf = (lo <= -std::numeric_limits<T1>::infinity());
212 int up_inf = (up >= std::numeric_limits<T1>::infinity());
213 if (!lo_inf && !up_inf) {
217 d->
qrtype[i] =
'R'; d->
rhs[i] = up; d->
rng[i] = up - lo;
219 }
else if (!up_inf) {
221 }
else if (!lo_inf) {
225 d->
qrtype[i] =
'L'; d->
rhs[i] = std::numeric_limits<T1>::infinity(); d->
rng[i] = 0;
232 for (k = 0; k < p->
nquad; ++k) {
237 XPRS_RETURN(XPRSloadqp, d->
xprob,
"casadi_qp",
254 casadi_socp_build(sd);
256 XPRS_RETURN(XPRSaddcols, d->
xprob,
static_cast<int>(sp->
n_lifted), 0,
260 XPRS_RETURN(XPRSaddrows, d->
xprob,
static_cast<int>(sp->
n_eq),
261 static_cast<int>(sp->
eq_nnz),
265 XPRS_RETURN(XPRSgetintattrib, d->
xprob, XPRS_ROWS, &n_rows_after_eq);
267 XPRS_RETURN(XPRSaddrows, d->
xprob,
static_cast<int>(sp->
n_blocks), 0,
271 for (b = 0; b < sp->
n_blocks; ++b) {
272 casadi_int bs = casadi_socp_cone_build(sd, b);
273 XPRS_RETURN(XPRSaddqmatrix, d->
xprob, n_rows_after_eq +
static_cast<int>(b),
281 for (i = 0; i < p_qp->
nx; ++i) d->
col_idx[i] = i;
289 XPRS_WARN(XPRSaddmipsol, d->
xprob, p_qp->
nx, d->
x0, 0, 0);
291 XPRS_RETURN(XPRSmipoptimize, d->
xprob,
"");
293 XPRS_RETURN(XPRSlpoptimize, d->
xprob,
"");
299 XPRS_WARN(XPRSgetdblattrib, d->
xprob, XPRS_MIPOBJVAL, &d->
obj_val);
310 XPRS_WARN(XPRSgetintattrib, d->
xprob, XPRS_LPSTATUS, &d->
lp_status);
311 XPRS_WARN(XPRSgetdblattrib, d->
xprob, XPRS_LPOBJVAL, &d->
obj_val);
316 else if (d->
lp_status == XPRS_LP_UNFINISHED ||
326 if (XPRSpostsolve(d->
xprob) != 0) {
327 XPRS_LOG_ERROR(XPRSpostsolve, d->
xprob,
"Error");
335 int sol_status = XPRS_SOLAVAILABLE_NOTFOUND;
336 XPRS_WARN(XPRSgetsolution, d->
xprob, &sol_status, d_qp->
x, 0, p_qp->
nx - 1);
337 if (sol_status == XPRS_SOLAVAILABLE_NOTFOUND) {
338 fprintf(stderr,
"Warning (XPRSgetsolution): no primal solution available.\n");
339 casadi_fill(d_qp->
x, p_qp->
nx, std::numeric_limits<T1>::quiet_NaN());
345 casadi_fill(d_qp->
lam_x, p_qp->
nx, std::numeric_limits<T1>::quiet_NaN());
346 casadi_fill(d_qp->
lam_a, p_qp->
na, std::numeric_limits<T1>::quiet_NaN());
349 if (d_qp->
lam_a && p_qp->
na > 0) {
350 int dual_status = XPRS_SOLAVAILABLE_NOTFOUND;
351 XPRS_WARN(XPRSgetduals, d->
xprob, &dual_status, d_qp->
lam_a, 0, p_qp->
na - 1);
352 if (dual_status == XPRS_SOLAVAILABLE_NOTFOUND) {
353 fprintf(stderr,
"Warning (XPRSgetduals): no dual solution available.\n");
354 casadi_fill(d_qp->
lam_a, p_qp->
na, std::numeric_limits<T1>::quiet_NaN());
356 for (i = 0; i < p_qp->
na; ++i) d_qp->
lam_a[i] = -d_qp->
lam_a[i];
359 if (d_qp->
lam_x && p_qp->
nx > 0) {
360 int rc_status = XPRS_SOLAVAILABLE_NOTFOUND;
361 XPRS_WARN(XPRSgetredcosts, d->
xprob, &rc_status, d_qp->
lam_x, 0, p_qp->
nx - 1);
362 if (rc_status == XPRS_SOLAVAILABLE_NOTFOUND) {
363 fprintf(stderr,
"Warning (XPRSgetredcosts): no reduced costs available.\n");
364 casadi_fill(d_qp->
lam_x, p_qp->
nx, std::numeric_limits<T1>::quiet_NaN());
366 for (i = 0; i < p_qp->
nx; ++i) d_qp->
lam_x[i] = -d_qp->
lam_x[i];
UnifiedReturnStatus unified_return_status
const casadi_socp_prob< T1 > * prob
casadi_qp_data< T1 > * qp
casadi_socp_data< T1 > socp
const casadi_xpress_prob< T1 > * prob
const double * sos_refval
const casadi_qp_prob< T1 > * qp
const casadi_socp_prob< T1 > * socp