##
# Copyright: Copyright (c) MOSEK ApS, Denmark. All rights reserved.
#
# File: sdo1.py
#
# Purpose: Demonstrates how to solve a small mixed semidefinite and conic quadratic
# optimization problem using the MOSEK Python API.
##
import sys
import mosek
# If numpy is installed, use that, otherwise use the
# Mosek's array module.
try:
from numpy import array,zeros,ones
except ImportError:
from mosek.array import array, zeros, ones
# Since the value of infinity is ignored, we define it solely
# for symbolic purposes
inf = 0.0
# Define a stream printer to grab output from MOSEK
def streamprinter(text):
sys.stdout.write(text)
sys.stdout.flush()
def main ():
# Make mosek environment
env = mosek.Env()
# Create a task object and attach log stream printer
task = env.Task(0,0)
task.set_Stream(mosek.streamtype.log, streamprinter)
# Bound values for constraints
blc = [1.0, 0.5]
buc = [1.0, 0.5]
# Below is the sparse representation of the A
# matrix stored by row.
asub = [ array([0]),
array([1, 2])]
aval = [ array([1.0]),
array([1.0, 1.0]) ]
conesub = [0, 1, 2]