Two bugs, both minor but worth reporting.
float("inf")
the .lp that is exported is unreadable.
In [1]:
from docplex.mp.model import Model
from docplex.mp.model_reader import ModelReader
In [2]:
m = Model("has an infinity on rhs")
v1 = m.continuous_var(ub = 10, name = "v1")
v2 = m.continuous_var(ub = 10, name = "v2")
m.add_constraint(3*v1 + 2*v2 <= float("inf"))
m.maximize(5*v1 + 4*v2)
print m.solve()
In [3]:
file1 = m.export_as_lp("has_infiniy.lp")
file2 = m.export_as_sav("has_infinity.sav")
Bug 1 - the export_as_sav
doesn't use the current working directory.
In [4]:
import os
os.path.exists(os.path.join(os.getcwd(), "has_infiniy.lp"))
Out[4]:
In [5]:
os.path.exists(os.path.join(os.getcwd(), "has_infinity.sav"))
Out[5]:
In [6]:
file2
Out[6]:
Bug 2 It can't read the file that was written. The 'inf' is tripping it up.
In [7]:
mr =ModelReader()
mr.read_model(file1)
The save format does work here.
In [8]:
m2 = mr.read_model(file2)
In [9]:
m2.get_constraint_by_index(0)
Out[9]:
Just to make this totally clear, if I remove the infinity, then the .lp file writing/reading works.
In [10]:
m = Model("no infinity")
v1 = m.continuous_var(ub = 10, name = "v1")
v2 = m.continuous_var(ub = 10, name = "v2")
m.add_constraint(3*v1 + 2*v2 <= 10000)
m.maximize(5*v1 + 4*v2)
print m.solve()
In [11]:
file1 = m.export_as_lp("no_infiniy.lp")
In [12]:
m2 = mr.read_model(file1)
In [ ]: