scipopt / russcip

Rust interface for SCIP
https://crates.io/crates/russcip
Apache License 2.0
30 stars 10 forks source link

Add constraint to Model<Solved> #118

Closed egaban closed 3 months ago

egaban commented 8 months ago

I couldn't find in the documentation if there's a safe way to add a constraint after the model was solved

This could be useful for solving a TSP with lazy constraint generation, for instance

mmghannam commented 8 months ago

Hi @egaban, yes this is not allowed because SCIP doesn't allow you to create a constraint after the model is solved. However, to implement these lazy constraints, you would need to implement the Constraint handler plugin (like in here). This is unfortunately not yet implemented in russcip.

egaban commented 8 months ago

@mmghannam Thanks for the clarification. Would it be possible to implement that in my own code using traits, like described in the readme? If it works I could create a fork and open a PR to add that

mmghannam commented 8 months ago

That would be great @egaban, feel free to ask here or email me if you have any questions. Good luck, looking forward to your PR!

mmghannam commented 4 months ago

I think I was complicating it too much, an easier way would be to add access to the SCIP freeTransform method that would free the underlying SCIP transformed problem and would return russcip's Model to the ProblemCreated state where one could add more variables and constraints.

This sounds like a more tangible goal, @egaban are you still interested in working on this?

egaban commented 4 months ago

Hi @mmghannam! I apologize for not having enough time to work on that earlier, but I'm still interested in contributing.

The alternative approach you suggested sounds easier to implement, though the Constraint Handlers might be a more robust solution. Maybe we can do the freeTransform first.

I've started learning about Rust FFI, but the main challenge for the Constraint Handlers now is figuring out how to do that in SCIP's C interface (I've never done that in C before), and in a generic way (unknown ConsData type). I estimate that I'll be ready to start working on this in about a month, if that's ok.

mmghannam commented 4 months ago

No apologies needed! I'm happy to hear you're still interested. Let me know if I you need any help :)

mmghannam commented 3 months ago

@egaban This should be kind of solved with #129. I added another issue https://github.com/scipopt/russcip/issues/130 for the constraint handler plugin to track it so let's continue the discussion there when you have time to work on it.

egaban commented 3 months ago

That's great! Thanks for the update