DD1
DD1

Reputation: 19

How to install SCIP into Spyder (Python 3.6)

Can someone please tell me how to install SCIP module into Spyder (Python 3.6). This is linked to anaconda by the way. I have been trying to get this module into this python 3.6 for last two days, and I am not getting anywhere. It is frustrating.

I need it solve a mixed integer programming problem.

Honestly, I do not care what programming language we use as long as I can solve my MIP problem. However, it will best if SCIP gets installed into Spyder (Python 3.6) because I am familiar with the language.

Please tell me the quickest and easiest way to do this. I also just downloaded and installed the stand-alone python 3.6. I would really appreciate, if someone can help me with this.

Thanks!

I am trying to run the following code:

from zibopt import scip
solver = scip.solver()

# All variables have default lower bounds of 0
x1 = solver.variable(scip.INTEGER)
x2 = solver.variable(scip.INTEGER)
x3 = solver.variable(scip.INTEGER)

# x1 has an upper bound of 2
solver += x1 <= 2

# Add a constraint such that:  x1 + x2 + 3*x3 <= 3
solver += x1 + x2 + 3*x3 <= 3

# The objective function is: z = x1 + x2 + 2*x3
solution = solver.maximize(objective=x1 + x2 + 2*x3)

# Print the optimal solution if it is feasible.
if solution:
    print('z  =', solution.objective)
    print('x1 =', solution[x1])
    print('x3 =', solution[x2])
    print('x2 =', solution[x3])
else:
    print('invalid problem')

Error I am getting:

from zibopt import scip

ModuleNotFoundError: No module named 'zibopt'

I have already placed scip folder into site-packages folder in the C: drive, and hoped that it would work. I have few other things, but I don't remember what they were.

Upvotes: 0

Views: 2574

Answers (2)

HRC
HRC

Reputation: 1

You could simply download & install Gusek (https://sourceforge.net/projects/gusek/) and model the problem in MathProg (cut and paste the following text in gusek IDE, save & run):

/*# All variables have default lower bounds of 0*/
var x1 integer, >=0;
var x2 integer, >=0;
var x3 integer, >=0;

/*# x1 has an upper bound of 2*/
s.t. upx1: x1 <= 2;

/*# Add a constraint such that:  x1 + x2 + 3*x3 <= 3*/

s.t. c1: x1 + x2 + 3*x3 <= 3;


/*# The objective function is: z = x1 + x2 + 2*x3*/

maximize FunObj:x1 + x2 + 2*x3;


solve;

end;

You can also use gusek (Ctrl-2 in gusek IDE) to generate an *.lp (CPLEX format) and solve it with standalone SCIP.

Upvotes: -1

mattmilten
mattmilten

Reputation: 6716

If you want to use SCIP in Python you should use this interface: https://github.com/SCIP-Interfaces/PySCIPOpt

I don't even know how you found the old zibopt package without stumbling over PySCIPOpt.

And by the way, if you only want to solve a mixed integer program, you can simply download a binary/executable of SCIP for the platform of your choice. You then need to model your problem in some way, e.g. using ZIMPL or simply as a plain .lp file (see here for a format description).

Upvotes: 2

Related Questions