scipopt / scip

SCIP - Solving Constraint Integer Programs
Other
366 stars 63 forks source link

loadProblem() with a single function call #56

Open grinya007 opened 1 year ago

grinya007 commented 1 year ago

Hello!

I'm working with various models in the domain of Energy Markets. Some of my models are quite large (tens of millions of variables, millions of constraints) and I'm constantly looking for ways to improve the solving time. I would love to experiment with SCIP but I couldn't find a way to pass the entire problem to the solver with a single function call (well, 3-4 would be ok too but not millions ;) I developed a generic solver interface for my kind of models, such that at the high level takes network objects (such as Supply/Transport/Demand nodes and Edges) and at the low level passes corresponding variables and constraints down to a solver in the form of ordered lower_bound/upper_bound/cost arrays for variables, and CSC matrix and bounds arrays for constraints. So far, I managed to integrate my library with

  1. Gurobi via GRBloadmodel
  2. CBC via Cbc_loadProblem
  3. HiGHS via Highs_passLp/Highs_passMip

I'm sure a similar method exists in Mosek but I haven't had a chance to integrate with it just yet. These methods allow me to quickly integrate different solvers through thin driver libraries as my generic library outputs almost exactly what these methods accept. But I can't find any similar function in the C API of SCIP and the need to pass every variable and constraint with a function call holds me back.

I saw this struct_matrix.h in the docs but it seems this structure can only be read from the model once it is all set up and never used to actually create/load a problem.

I hope to be wrong, or let this be a feature request otherwise =)

Thank you!

sschnug commented 1 year ago

Afaik there is no algebraic modelling (or let's say matrix-based modelling) available in SCIP, meaning: there is no way to define a vector / batch of variables and there is no way to define a vector / batch of constraints defined by a constraint coeff-matrix and a constraint rhs-vector. Each var and each constraint introduced needs an explicit call to do that.

That being said, i don't see the issue.

Targeting this kind of low-lvl algebraic structure (i'm having Highs in mind which i once filled with some parent which also filled or-tools' PDLP) sounds relatively straightforward to me:

I would guess that's < 100 lines of code. Maybe even < 50 if one would store the algebraic model in something like Eigen. Don't forget the necessary memory-management (SCIPfree...)

Don't you agree, that a 50-100 loc wrapper external_to_scip(...) is a small investment?

One more remark:

One more opinion:

ambros-gleixner commented 12 months ago

Hi, you are correct that there is no such matrix-based problem creation function in SCIP. I agree that this would be a nice convenience feature. It could be an addition to the interface of cons_linear. I don't think we are going to implement that ourselves, but we would welcome and support a PR! (The solution is pretty much a combination of for loops as described by @sschnug .)