CyLP icon indicating copy to clipboard operation
CyLP copied to clipboard

getBasisStatus influence primalVariableSolutionAll

Open abdxyz opened this issue 4 years ago • 0 comments

When I add one more line model.getBasisStatus(). The result changes.

import numpy as np
from cylp.cy import CyClpSimplex
from cylp.py.modeling.CyLPModel import CyLPArray

A = [[50, 31], [-3, 2, ]]
b = [250, 4]
c = [-1, -0.64]
l = [1, 0]
u = [10000, 10000]

model = CyClpSimplex()
x = model.addVariable('x', len(c))
A = np.matrix(A)
b = np.matrix(b)
l = CyLPArray(l)
u = CyLPArray(u)
c = CyLPArray(c)
model += (A * x <= b)
model += l <= x <= u
model.objective = c * x

model.primal()
#print(model.getBasisStatus())
print(model.primalConstraintSolution)   #row value
print(model.primalVariableSolutionAll)  #row slack

print(model.dualConstraintSolution)     #dual variable
print(model.dualVariableSolution)       #dual slack

model.primalVariableSolutionAll will output [1.94818653e+000 4.92227979e+000 2.31462827e-152 1.63041663e-322] But If uncoment the model.getBasisStatus(), primalVariableSolutionAll will return [1.94818653e+000 4.92227979e+000 3.22302250e+160 1.63041663e-322]

abdxyz avatar Dec 08 '20 02:12 abdxyz