From 0fa934d9357d414ae2bb820399886e3055ab3bd6 Mon Sep 17 00:00:00 2001 From: raoul-herzog <83025179+raoul-herzog@users.noreply.github.com> Date: Thu, 22 Apr 2021 17:46:18 +0200 Subject: [PATCH] included update_warm_start functionality --- codegen/files_to_generate/emosqp_mex.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/codegen/files_to_generate/emosqp_mex.c b/codegen/files_to_generate/emosqp_mex.c index 6ca9fc7..36beb0f 100644 --- a/codegen/files_to_generate/emosqp_mex.c +++ b/codegen/files_to_generate/emosqp_mex.c @@ -299,6 +299,34 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) return; } + // update warm_start + if (!strcmp("update_warm_start", cmd)) { + + // Fill l, u + const mxArray *x = prhs[1]; + const mxArray *y = prhs[2]; + + // Copy vectors to ensure they are cast as c_float + c_float *x_vec; + c_float *y_vec; + if(!mxIsEmpty(x)){ + x_vec = copyToCfloatVector(mxGetPr(x), (&workspace)->data->m); + } + if(!mxIsEmpty(y)){ + y_vec = copyToCfloatVector(mxGetPr(y), (&workspace)->data->m); + } + + if(!mxIsEmpty(y)){ + osqp_warm_start(&workspace, x_vec, y_vec); + } + + // Free + if(!mxIsEmpty(x)) mxFree(x_vec); + if(!mxIsEmpty(y)) mxFree(y_vec); + + return; + } + #if EMBEDDED != 1 // update matrix P if (!strcmp("update_P", cmd)) {