Interfacing solvers
As Scala is a relatively niche programming language in the physics community, we expect our users to use SymDPoly as a domain-specific tool (where Scala shines as a domain-specific language with notation close to the mathematical notation), and immediately export the data after the processing is done. Thus SymDPoly can output the problem data in a variety of formats.
In the following, we assume that the variable program
contains the conic linear program corresponding to the current moment-based relaxation.
import net.alasc.symdpoly._
import net.alasc.symdpoly.examples.quantum.CHSH
import CHSH._
val L = Quantum.eigenvalueEvaluator(real = true)
val generatingSet = Quantum.quotient(GSet.onePlus(Free.A, Free.B))
val program = L(Quantum.quotient(CHSH.chsh)).maximize.relaxation(generatingSet).program
Solver input data: text-based formats
- Mosek input file in the Conic Benchmark Format, which is a text based format. Use:
program.mosek.writeFile("chsh_mosek.cbf")
- Sparse SDPA input file (text based format again). Use:
program.sdpa.writeFile("chsh_sdpa.dat-s")
Solver input data: MAT file-based formats
Those solvers need to be called from Matlab. For those, SymDPoly saves .mat
files containing the argument values needed to call the main solver function.
- SCS, using the SCS-matlab interface.
program.scs.writeFile("chsh_scs.mat")
program.sdpt3.writeFile("chsh_sdpt3.mat")
- SeDuMi format file; note that the SeDuMi file format contains information about the symmetries of the semidefinite constraints.
program.sedumi.writeFile("chsh_sedumi.mat")
Java native solver
SymDPoly can interface with the JOptimizer package, able to solve semidefinite programs using a Barrier Method. Use with toy problems only.
Running Mosek directly (native problem formats)
You want to run the Mosek solver directly, without writing intermediate files, or write problems in the Task Format or JSON Format formats.
For that, you need to interface Mosek with the Java Virtual Machine. First, import the symdpoly-mosek
module in your build.sbt
file.
libraryDependencies += "net.alasc" %% "symdpoly-mosek" % "0.7.6"
Then, add a lib
subfolder at the root of your project, which contains the JAR files and shared libraries of mosek/8/tools/platform/XXX/bin
from your Mosek installation.
If you are running Linux, you may want to add that lib
subfolder to LD_LIBRARY_PATH
as well.
Then, you can call:
scala> import net.alasc.symdpoly.mosek._
import net.alasc.symdpoly.mosek._
scala> program.nativeMosek.solve()
res5: net.alasc.symdpoly.Solution = OptimumFound(Some(2.8284271247466592),2.8284271247461903)
to run Mosek directly, and
program.nativeMosek.writeFile("chsh_mosek.task")
program.nativeMosek.writeFile("chsh_mosek.jtask")
to write files in any of the Mosek supported formats.