scipopt / JSCIPOpt

Java interface for the SCIP Optimization Suite
MIT License
62 stars 35 forks source link

Adding `SCIPchgvarobj` native support. #29

Closed xunzhang closed 2 years ago

xunzhang commented 3 years ago

This is quite useful in real scenarios, that decouple the definition of the objective function and the variables. This pull request adding interface scip.changeVarObj to support that, please check the usage below.

Usage:

Variable y = scip.createVar("y", 0.0, scip.infinity(), 0.0, SCIP_Vartype.SCIP_VARTYPE_INTEGER);
scip.changeVarObj(y, -3.0);

// Equivalent to below line
Variable y = scip.createVar("y", 0.0, scip.infinity(), -3.0, SCIP_Vartype.SCIP_VARTYPE_INTEGER);
kkofler commented 2 years ago

Looks reasonable, though I have to wonder why you apparently manually edited the generated file instead of running SWIG (otherwise you would not have made a typo).

The patch also needs to be rebased against current master.

I am going to look into cleaning this up so that it can be merged.

kkofler commented 2 years ago

I rebased your pull request so that it can be merged. I also actually ran SWIG to regenerate the generated files.

kkofler commented 2 years ago

Another force-push, fixed "you can adding" to "you can add" in a comment.

xunzhang commented 2 years ago

Thank you!