First, use mosek.jar instead of mosekmatlab.jar in the Java path in MATLAB, for instance:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javaaddpath mosek/9.0/tools/platform/linux64x86/bin/mosek.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = M.variable('x', 4, Domain.greaterThan(0.0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x.index(0), x.index(1), x.index(2), x.index(3) |
This applies only to indexing Java objects from mosek.fusion. Nothing changes with regard to MATLAB arrays, so operations which don't use explicit indexes are not affected, and whenever the input/output of a method is a MATLAB array, it will be 1-based indexed as always. So the following piece of code works both in the old and new regime:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mosek.fusion.*; | |
c = [ 3.0, 1.0, 5.0, 1.0 ]; | |
A = [ 3.0, 1.0, 2.0, 0.0 ; ... | |
2.0, 1.0, 3.0, 1.0 ; ... | |
0.0, 2.0, 0.0, 3.0 ]; | |
b = [ 2.0, 5.0, 3.0 ]; | |
M = Model(); | |
x = M.variable(4, Domain.greaterThan(0.0)); | |
M.objective('obj', ObjectiveSense.Maximize, Expr.dot(c, x)); | |
M.constraint(Expr.mul(A, x), Domain.lessThan(b)); | |
M.solve(); | |
disp(['x = ' mat2str(x.level()',7)]); |
Finally note that Java 1.8+ is required.