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

Basic embedding tasks

  • Compiling a model into a BIM file (requires burglar2.mos, burglar.dat)
  • Compiling a model into a BIM file saved in Mosel's temporary directory (requires burglar2.mos, burglar.dat)
  • Compiling a model into a BIM file, then load and run it (requires burglar2.bim, burglar.dat)
  • Redirecting the model output (requires burglar2.mos, burglar.dat)
  • Accessing modeling objects: sparse arrays (requires transport.mos, transprt.dat)
  • Retrieve model output via a callback (requires burglar2.mos, burglar.dat)
  • Passing parameters to a Mosel model (requires prime.mos)
  • Accessing modeling objects and solution information (requires burglar3.mos, burglar.dat)

Source Files

Data Files

   Mosel User Guide Example Problems

   Retrieve model output via callback-style functionality.
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, 2006

import com.dashoptimization.*;

public class ugcb
                            // OutputStream class to handle default output
 public static class MyOut extends OutputStream
  public void flush()
  { System.out.flush(); }
  public void write(byte[] b)
   System.out.print("Mosel: "); 
   System.out.write(b, 0, b.length);
  // The following methods are not used by Mosel:
  public void write(byte[] b, int off, int len) {}
  public void write(int b) {}
  public void close() {}

 public static void main(String[] args) throws Exception
  XPRM mosel;
  XPRMModel mod;
  MyOut cbmsg = new MyOut();            // Define output stream as "MyOut"

  mosel = new XPRM();                   // Initialize Mosel

                                // Redirect error stream to default output
  mosel.setDefaultStream(XPRM.F_ERROR, "java:java.lang.System.out");

  mosel.bind("mycb", cbmsg);    // Associate Java object with a name in Mosel
                                // Set default output stream to cbmsg
  mosel.setDefaultStream(XPRM.F_OUTPUT|XPRM.F_LINBUF, "java:mycb");

  mosel.compile("burglar2.mos");        // Compile, load & run the model
  mod = mosel.loadModel("burglar2.bim");;

Back to examples browserPrevious exampleNext example