![]() | |||||||||||||||
| |||||||||||||||
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.
Source Files By clicking on a file name, a preview is opened at the bottom of this page.
Data Files runmat.mos (!****************************************************** Mosel Example Problems ====================== file runmat.mos ``````````````` Use Optimizer 'command' to read+solve a matrix file -- Read solution output into Mosel structures -- (c) 2017-2022 Fair Isaac Corporation author: S.Heipcke, 11 Sep 2017, rev. Oct. 2022 *******************************************************!) model "running Optimizer command line" uses "mmsystem", "mmxprs" ! Load+run on MPS format matrix scriptmps:=` readprob folio10 chgobjsense max mipoptimize writesol optsol.asc ` ! Load+run on LP format matrix scriptlp:=` readprob -l folio10 chgobjsense max mipoptimize writesol optsol.asc ` ! Uncomment to show the solver log setparam("XPRS_verbose", true) ! Uncomment one of the following 2 lines ! command(scriptmps) command(scriptlp) if getparam("XPRS_SOLSTATUS")=XPRS_SOLSTATUS_OPTIMAL then writeln_("Optimal solution: ", getparam("XPRS_MIPOBJVAL")) else writeln_("No solution found") exit(0) end-if ! Load the solution output into Mosel declarations Fields=1..3 SolVals: array(R:range,Fields) of any end-declarations ! Selecting the fields index, name, type, activity value from the solver output initializations from "mmsheet.csv:optsol.asc" SolVals as "partndx;[](#1,#2,#3,#5)" end-initializations ! Display all non-zero valued variables forall(i in R | SolVals(i,2)="C" and SolVals(i,3)<>0) writeln(SolVals(i,1), "=", SolVals(i,3)) end-model
| |||||||||||||||
© Copyright 2024 Fair Isaac Corporation. |