lp instead of mps

251 views
Skip to first unread message

Tom van der Hoeven

unread,
May 8, 2012, 4:32:34 PM5/8/12
to pulp-or...@googlegroups.com
Hello,
I have a problem with 12 variables, minimum constraints on these
variables and a maximum constraint on the total.
For instance Qmin(i) = 8.333333333333334 for i = 1 to 12 and Qmax = 100
for the total.
This is of course a degenerated problem.
I use the default solver, because if Stuart think it is the best, it
will be so.
I found that the mps format file is used where numbers are truncated.
Within solvers.py I forced to use the lp format file, where numbers are
not truncated.
Using mps format I get status infeasible, using lp format I get Optimal.

My questions are:
- Can I force the default solver to use the lp format, without changing
solvers.py
- Can I use the lp file that I write: for instance tom.lp instaed of
6080-pulp.lp
- Can I keep the solution file

Tom

Stuart Mitchell

unread,
May 8, 2012, 7:23:21 PM5/8/12
to pulp-or...@googlegroups.com
There is a problem with the LP format that if Variables have identical names the lp format will consider them
the same variable and therefore have problems,

If you want to keep the files  and use the lp format.

>>> from pulp import *
>>> prob = LpProblem('test')
>>> a = LpVariable('A')
>>> b = LpVariable('B')
>>> prob += a
>>> prob += a + b <=10
>>> cbc_solver = COIN_CMD(keepFiles=1)
>>> cbc_solver.solve_CBC(prob, use_mps=False)

$ ls test-*
test-pulp.lp  test-pulp.sol

The lp and sol files should be in your default directory.

Stu

I have not actually tested this 


Tom

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
To unsubscribe from this group, send email to pulp-or-discuss+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pulp-or-discuss?hl=en.




--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

Tom van der Hoeven

unread,
May 9, 2012, 12:37:04 PM5/9/12
to pulp-or...@googlegroups.com
Stuart,

I don't understand the first sentence.
How can it be a problem that there is a unique relation between a name and a variable.
Can you refer to a site where the problem with the lp format is explained.

Given my problem with summation of variables and constraints on the variables and sums, I considered elastic constraints.
So my idea was to make balance equations and summations elastic.
I cannot get it working, making the elastic constraints part of a larger problem.
Is it possible to have one problem with a number of elastic constraints.
Do you have an example .py file.

Tom



Op 9-5-2012 1:23, Stuart Mitchell schreef:

Stuart Mitchell

unread,
May 9, 2012, 4:55:59 PM5/9/12
to pulp-or...@googlegroups.com
Hi Tom the problem is (you probably don't have to worry about this) in Pulp you can have two different variables with the same name

>>> a = LpVariable('A')
>>> b = LpVariable('A')

And pulp and many solvers will still solve this problem ok, but the LP format will give a different answer.

I mention this because it may explain why your results with an LP and MPS format are different.

Pulp has a (undocumented) features which will generate and manage elastic constraints for you, I will try to work up and example.

Stu

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
To unsubscribe from this group, send email to pulp-or-discuss+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pulp-or-discuss?hl=en.

Tom van der Hoeven

unread,
May 10, 2012, 4:10:58 PM5/10/12
to pulp-or...@googlegroups.com
Stuart,

I get your point.

My problem is just feasible. With some rounding it becomes infeasible.
In a MPS file there is less accuracies (6 significant figures) then in a LP file, so it became infeasible.
What to do:
- set the zero tolerance of the solver higher. This is the preferred solution.
  Presolve of the default solver uses 1e-8 , and I found no way to change it!
- make all equations elastic: I did so and it works. (I added explicit positive and negative penalties)
  I always get an optimal solution! But you must take care of infeasibilities that are overlooked
- multiply all maxima by 1 + 1e-5 and all minima by 1 - 1e-5 in case the mps file is used.
  This is probably the simplest solution, but I did not yet do it.

I used to work with a piecewise linear programming package.
Constraints are just relations, and each variable has a convex piecewise linear cost function.
Here elasticity is almost for free.

Tom

By the way, thanks a lot!


Op 9-5-2012 22:55, Stuart Mitchell schreef:
Hi Tom the problem is (you probably don't have to worry about this) in Pulp you can have two different variables with the same name

>>> a = LpVariable('A')
>>> b = LpVariable('A')

And pulp and many solvers will still solve this problem ok, but the LP format will give a different answer.

I mention this because it may explain why your results with an LP and MPS format are different.

Pulp has a (undocumented) features which will generate and manage elastic constraints for you, I will try to work up and example.

Stu

On Thu, May 10, 2012 at 4:37 AM, Tom van der Hoeven <T...@vanderhoeven.biz> wrote:
Stuart,

I don't understand the first sentence.
How can it be a problem that there is a unique relation between a name and a variable.
Can you refer to a site where the problem with the lp format is explained.

Given my problem with summation of variables and constraints on the variables and sums, I considered elastic constraints.
So my idea was to make balance equations and summations elastic.
I cannot get it working, making the elastic constraints part of a larger problem.
Is it possible to have one problem with a number of elastic constraints.
Do you have an example .py file.

Tom



Op 9-5-2012 1:23, Stuart Mitchell schreef:

There is a problem with the LP format that if Variables have identical names the lp format will consider them
the same variable and therefore have problems,


--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To post to this group, send email to pulp-or...@googlegroups.com.
To unsubscribe from this group, send email to pulp-or-discu...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/pulp-or-discuss?hl=en.




--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To post to this group, send email to pulp-or...@googlegroups.com.
To unsubscribe from this group, send email to pulp-or-discu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages