Unable to figure out ' invalid matrix input type -- ', u'1'

V

varun7rs

Hello Everyone,

I am currently working on Cplex using Python API. I have a problem when I run the code. I keep getting this error about the invalid matrix input but I'm not able to figure out what it is. I would be grateful if any of you could help. My function is as below

def add_constraint(self, variables, coefficients, sense, rhs, name):
self.prob.linear_constraints.add(
lin_expr = [[ variables, coefficients ]],
senses = [sense],
rhs = [rhs],
names = [name] )



Traceback (most recent call last):
File "RW10.py", line 569, in <module>
main(sys.argv[1:])
File "RW10.py", line 562, in main
solveVNEProblem( phy_network, demands, args.output)
File "RW10.py", line 116, in solveVNEProblem
solver.add_constraint( varNames, varCoeffs, "E", 1.0, "Location_Constraints1{}".format( demand.demandID ) )
File "RW10.py", line 26, in add_constraint
names = [name] )
File "/opt/ibm/ILOG/CPLEX_Studio125/cplex/python/x86-64_sles10_4.1/cplex/_internal/_subinterfaces.py", line 1187, in add
rmat = _C_HBMatrix(lin_expr, self._cplex._env_lp_ptr, 0, self._env.parameters.read.apiencoding.get())
File "/opt/ibm/ILOG/CPLEX_Studio125/cplex/python/x86-64_sles10_4.1/cplex/_internal/_matrices.py", line 74, in __init__
raise TypeError(" invalid matrix input type -- ", self._mat[0])
TypeError: (' invalid matrix input type -- ', u'1')


Thank You
 
M

Mark Lawrence

Hello Everyone,

I am currently working on Cplex using Python API. I have a problem when I run the code. I keep getting this error about the invalid matrix input but I'm not able to figure out what it is. I would be grateful if any of you could help. My function is as below

def add_constraint(self, variables, coefficients, sense, rhs, name):
self.prob.linear_constraints.add(
lin_expr = [[ variables, coefficients ]],
senses = [sense],
rhs = [rhs],
names = [name] )



Traceback (most recent call last):
File "RW10.py", line 569, in <module>
main(sys.argv[1:])
File "RW10.py", line 562, in main
solveVNEProblem( phy_network, demands, args.output)
File "RW10.py", line 116, in solveVNEProblem
solver.add_constraint( varNames, varCoeffs, "E", 1.0, "Location_Constraints1{}".format( demand.demandID ) )
File "RW10.py", line 26, in add_constraint
names = [name] )
File "/opt/ibm/ILOG/CPLEX_Studio125/cplex/python/x86-64_sles10_4.1/cplex/_internal/_subinterfaces.py", line 1187, in add
rmat = _C_HBMatrix(lin_expr, self._cplex._env_lp_ptr, 0, self._env.parameters.read.apiencoding.get())
File "/opt/ibm/ILOG/CPLEX_Studio125/cplex/python/x86-64_sles10_4.1/cplex/_internal/_matrices.py", line 74, in __init__
raise TypeError(" invalid matrix input type -- ", self._mat[0])
TypeError: (' invalid matrix input type -- ', u'1')


Thank You

I don't know but I'll guess that should be a letter l and not the number 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top