K.wang
K.wang

Reputation: 25

SCIP how to add objective function in my source code by using c++ when I use SCIP

I want to use SCIP as a MIP solver, but I do not know how to add objective function in my source code. I did not find related code in SCIP C++ example code.

Upvotes: 0

Views: 837

Answers (2)

Gregor
Gregor

Reputation: 1375

SCIP only understands linear objective functions, i.e., every variable has an objective coefficient that can be passed as SCIP_Real obj to

All example projects of SCIP create variables and set objective coefficients in one form or another. Note that SCIP by default minimizes a given objective function. A good example how to setup a simple MIP is the n-queens example in the examples directory of SCIP. This example sets up a maximization problem!

Nonlinear objective functions can be added as a constraint instead, using an artificial objective variable, whose value is bounded by the constraint, with objective coefficient 1. Good examples of setting up nonlinear problems can be browsed in the Callable Library example.

Upvotes: 2

mueldgog
mueldgog

Reputation: 383

The objective coefficient of each variable has to be specified during creation, i.e., in the SCIPcreateVar call. You can also change an objective coefficient by calling SCIPchgVarObj. Note that SCIP only supports linear objective functions.

Upvotes: 0

Related Questions