Thursday, October 24, 2013

Investigating the data of a semidefinite optimization problem

In the MOSEK optimizer API it is not possible to dump a semidefinite optimization problem to a text file unfortunately. However, it is possible to dump the problem to a task file and then viewing the barA matrix using the following Python script.

import sys

import mosek

env = mosek.Env()
task = env.Task(0,0)


num  = task.getnumbarablocktriplets()
subi = num*[0]
subj = num*[0]
subl = num*[0]
subk = num*[0]
valijkl = num*[0.0]
num = task.getbarablocktriplet(subi,subj,subk,subl,valijkl)
for k in range(0,num):
    print('%d %d %d %d %e\n' % (subi[k],subj[k],subk[k],subl[k],valijkl[k])),
If the above Python code is saved to a file called and then it is possible to do
python myfile.task
Note the function getbarablocktriplet() is available in all optimizer APIs.