FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

Using Optimizer Console for running matrices within Mosel

Description
Is it possible to run matrices from Workbench / Mosel?

Not directly, but you can use the Optimizer command of the module mmxprs to work with the Optimizer Console from within Mosel. In this case there is no problem representation in Mosel, but solver controls and attributes (setparam and getparam routines on "XPRS_" parameters) and simple (logging) callbacks can be used. If needed, a Mosel program can parse solver output files (see Appendix 'Log and file formats' of the Optimizer Reference Manual) to retrieve information into Mosel.
  • Loading and running a matrix file in LP or MPS format, reading solver CSV output files into Mosel (runmat.mos)
  • Callback definition when running a matrix file (runmatcb.mos)
  • Setting solver parameters via the console command (runmatparam.mos)


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
runmat.mos[download]
runmatcb.mos[download]
runmatparam.mos[download]

Data Files





runmatcb.mos

(!******************************************************
   Mosel Example Problems
   ======================

   file runmatcb.mos
   `````````````````
   Use Optimizer 'command' to read+solve a matrix file
   -- Using CB definition in Mosel with Optimizer command line --
   
  (c) 2020-2022 Fair Isaac Corporation
      author: S.Heipcke, 19 Aug 2020, rev. Oct. 2022
*******************************************************!)
model "running Optimizer command line"
 uses "mmsystem", "mmxprs"

! Load+run on MPS format matrix
 scriptmps:=`
readprob folio10
chgobjsense max
mipoptimize
`
 declarations
   starttime: real
   procedure printsol
 end-declarations

! Set a MIP solution callback
 setcallback(XPRS_CB_INTSOL, ->printsol)

 setparam("XPRS_verbose", false)
 starttime:=gettime

! Load and run the matrix
 command(scriptmps)


!**** Define INTSOL callback: retrieve info via Optimizer parameters
 procedure printsol
   writeln("(",gettime-starttime, "sec)  Solution ", getparam("XPRS_MIPSOLS"),
           "  Value: ", getparam("XPRS_MIPOBJVAL"))
 end-procedure

end-model 

Back to examples browserPrevious exampleNext example