TypeError when solving problem that is already build with MOSEK
When solving a problem two times with mosek as solver (with re-creating the entire problem) a TypeError: Argument bk has wrong type
occurs in the _make_mosek_instance
method.
A minimal example reproducing the error is the following:
prob = pic.Problem()
x = prob.add_variable('x')
prob.add_constraint(-5<=x)
prob.set_objective('min',x)
prob.solve(solver='mosek')
print('----- Solving problem again -----')
prob.solve(solver='mosek')
Which gives as output:
build mosek instance
mosek instance built
-----------------------------------
MOSEK version 7
-----------------------------------
Problem
Name :
Objective sense : min
Type : LO (linear optimization problem)
Constraints : 1
Cones : 0
Scalar variables : 1
Matrix variables : 0
Integer variables : 0
Optimizer started.
Presolve started.
Eliminator started.
Freed constraints in eliminator : 0
Eliminator terminated.
Eliminator - tries : 1 time : 0.00
Lin. dep. - tries : 0 time : 0.00
Lin. dep. - number : 0
Presolve terminated. Time: 0.00
Optimizer terminated. Time: 0.03
Interior-point solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: -5.0000000000e+00 nrm: 5e+00 Viol. con: 0e+00 var: 0e+00
Dual. obj: -5.0000000000e+00 nrm: 1e+00 Viol. con: 0e+00 var: 0e+00
Basic solution summary
Problem status : PRIMAL_AND_DUAL_FEASIBLE
Solution status : OPTIMAL
Primal. obj: -5.0000000000e+00 nrm: 5e+00 Viol. con: 0e+00 var: 0e+00
Dual. obj: -5.0000000000e+00 nrm: 1e+00 Viol. con: 0e+00 var: 0e+00
Solution status is optimal
----- Solving problem again -----
build mosek instance
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
C:\Anaconda3\envs\pygurobi\lib\site-packages\mosek\__init__.py in getboundslice(self, accmode_, first_, last_, bk, bl, bu)
2561 try:
-> 2562 bk_ = memoryview(bk)
2563 except TypeError:
TypeError: memoryview: a bytes-like object is required, not 'list'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
C:\Anaconda3\envs\pygurobi\lib\site-packages\mosek\__init__.py in getboundslice(self, accmode_, first_, last_, bk, bl, bu)
2564 try:
-> 2565 _tmparr_bk = array.array("i",bk)
2566 except TypeError:
TypeError: integer argument expected, got float
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-19-6263123a26f6> in <module>()
8 print('----- Solving problem again -----')
9
---> 10 prob.solve(solver='mosek')
C:\Anaconda3\envs\pygurobi\lib\site-packages\picos\problem.py in solve(self, **options)
5128 or self.options['solver'] == 'mosek6'):
5129
-> 5130 primals, duals, obj, sol = self._mosek_solve()
5131
5132 # for scip
C:\Anaconda3\envs\pygurobi\lib\site-packages\picos\problem.py in _mosek_solve(self)
6663 #----------------------------#
6664
-> 6665 self._make_mosek_instance()
6666 task = self.msk_task
6667
C:\Anaconda3\envs\pygurobi\lib\site-packages\picos\problem.py in _make_mosek_instance(self)
3953 si = si[0]
3954 bk, bl, bu = [0.] * sz, [0.] * sz, [0.] * sz
-> 3955 task.getboundslice(mosek.accmode.var, si, si + sz, bk, bl, bu)
3956 for ind, (ky, l, u) in enumerate(zip(bk, bl, bu)):
3957 if ky is mosek.boundkey.lo:
C:\Anaconda3\envs\pygurobi\lib\site-packages\mosek\__init__.py in getboundslice(self, accmode_, first_, last_, bk, bl, bu)
2565 _tmparr_bk = array.array("i",bk)
2566 except TypeError:
-> 2567 raise TypeError("Argument bk has wrong type")
2568 else:
2569 bk_ = memoryview(_tmparr_bk)
TypeError: Argument bk has wrong type