embotech/ecos

Reinitialize ECOS after solve for new (but similar) problem definition

Opened this issue · 0 comments

At the moment, the typical work flow of solving SOCPs sequentially using the C API of ECOS is as follows:

  1. ECOS_setup() with you problem data.
  2. ECOS_solve() to solve first SOCP.
  3. ECOS_cleanup() to cleanup problem data.
  4. ECOS_setup()
  5. ECOS_solve()
  6. etc.

In the ECOS_setup()-routine several operations are performed that do not need to be repeated in case the structure of one problem to the other remains the same. One of which is the dynamic memory allocation.

It would be interesting to have a function called e.g., ECOS_update() that would allow the user to provide new data for a problem of the same structure (sparsity patterns and dimensions). A tentative prototype could be:

void ECOS_update(pwork* old_problem, pfloat* Gpr, pfloat* Apr, pfloat* c, pfloat* h, pfloat* b);

One of the tricky parts of such a routine would be that after the initialization, the problem matrices (in the pwork struct) are scaled and permuted. The new problem data cannot be written to the according elements in the pwork struct naively, instead the data needs to be updated according to the existing scalings and permutations.

The new workflow could be:

  1. ECOS_setup() with your initial problem data.
  2. ECOS_solve() to solve first SOCP.
  3. ECOS_update() to update the problem data.
  4. ECOS_solve()
  5. ECOS_update()
  6. etc.

and cleanup only once if the e.g., SCP algorithm terminates.