0

Its possible to solve a problem from a .mod file using Pulp?

In the documentation there's nothing about it.

is initiated like this:

prob = LpProblem("linearProblem", LpMinimize)

I want something like this:

prob = LpProblem("/home/problem.mod","linearProblem", LpMinimize)

I'm using python3.4

Lucas Rodrigues
  • 139
  • 3
  • 13

1 Answers1

1

Yes and No.

From within Pulp the GLPK solve call is fixed to the lp format (which is used when creating a problem with Pulp). When you look into the sourcecode of Pulp you see that there is just a simple commandline call to start GLPK (starting line 355 and excecuted in line 369 or 371).

You can make basically the same call with

proc = ["glpsol", "--math", your_mod_file, "-o", your_solution_file]

When the operation is done you can read the solution back in the Pulp structure with the Pulp function

pulp.solver.GLPK.readsol(your_solution_file)
Paul G.
  • 632
  • 6
  • 16