25.11.2015 Views

The MOSEK Python optimizer API manual Version 7.0 (Revision 141)

Optimizer API for Python - Documentation - Mosek

Optimizer API for Python - Documentation - Mosek

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.2. LINEAR OPTIMIZATION 33<br />

51 mosek.boundkey.ra,<br />

52 mosek.boundkey.lo,<br />

53 mosek.boundkey.lo]<br />

54 # Bound values for variables<br />

55 blx = [ 0.0, 0.0, 0.0, 0.0]<br />

56 bux = [+inf, 10.0, +inf, +inf]<br />

57 # Objective coefficients<br />

58<br />

59 c = [ 3.0, 1.0, 5.0, 1.0 ]<br />

60<br />

61 # We input the A matrix column-wise<br />

62 # asub contains row indexes<br />

63 asub = [ array([0, 1, 2]),<br />

64 array([0, 1, 2, 3]),<br />

65 array([0, 3])]<br />

66 # acof contains coefficients<br />

67 aval = [ array([3.0, 1.0, 2.0]),<br />

68 array([2.0, 1.0, 3.0, 1.0]),<br />

69 array([2.0, 3.0])]<br />

70 numvar = len(bkx)<br />

71 numcon = len(bkc)<br />

72 # Append ’numcon’ empty constraints.<br />

73 # <strong>The</strong> constraints will initially have no bounds.<br />

74 task.appendcons(numcon)<br />

75<br />

76 #Append ’numvar’ variables.<br />

77 # <strong>The</strong> variables will initially be fixed at zero (x=0).<br />

78 task.appendvars(numvar)<br />

79<br />

80 for j in range(numvar):<br />

81 # Set the linear term c j in the objective.<br />

82 task.putcj(j,c[j])<br />

83 # Set the bounds on variable j<br />

84 # blx[j]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!