4

I have a Integer Linear Programming probem to solve. So, I decided o use python and SciPy spcecifically.

I have the following short snippet.

obj_function = running_instance_coeffs + new_instance_coeffs
A = [[1]*len(running_instance_coeffs) + [1]*len(new_instance_coeffs), encoding_speed_running_instances + encoding_speed_new_instances]
b = [MAX_INSTANCES, ((-1)*load/QoS)]

bounds=[]

for inst in running_instances:
    bounds.append([0,1])

for inst in instances:
    bounds.append([0,10])

res=linprog(obj_function, A_ub=A, b_ub=b, bounds=bounds, options={"disp": True})
print('Optimal value:', res.fun, '\nX:', res.x)

It works perfectly well. However, it does not give an integer solution. Is it possible to simply change it to ILP solution? I realize there are other libraries like pulp which allow to do this, but it would be easier to change it here.

kosta
  • 4,302
  • 10
  • 50
  • 104
  • 1
    "method : str, optional Type of solver. At this time only ‘simplex’ is supported" Since the only method implemented is simplex, I don't think it's possible to solve ILP problems. – ayhan Mar 31 '16 at 07:16
  • so, what is the recommended way/library to solve these type of problem in Python? – kosta Mar 31 '16 at 08:09
  • I would reccomend you to use [PyGLPK](http://tfinley.net/software/pyglpk/) (Python inerface for [GLPK](https://en.wikibooks.org/wiki/GLPK)) and solve the IP right away as rounding the LP relaxation solution is known to be bad isea. – serge_k Mar 31 '16 at 08:10
  • Another option is the Python interface of [SCIP](http://scip.zib.de) – mattmilten Apr 01 '16 at 14:41
  • This is an older and better formulated question but it is unanswered so I had to close this one instead of the other. – ayhan Dec 09 '17 at 14:27

0 Answers0