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

Basic tasks: remote connection, coordination, communication, and parallelization

Description
A series of examples of basic tasks that typically need to be performed when working with remote models in Mosel:
  • Check for available remote Mosel servers: findservers.*
  • Run a single model on a remote machine: runrtdistr.* (executing rtparams.mos)
  • Running parallel submodels in a distributed architecture: runrtpardistr.* (executing rtparams3.mos)
  • Queuing submodels for parallel execution in a distributed architecture with one or several models per node: runrtparqueued.* (executing rtparams3.mos)
Further explanation of this example: Xpress Whitepaper 'Multiple models and parallel solving with Mosel', Section 'Basic tasks'.

runrtparxprd.zip[download all files]

Source Files





runrtdistr.java

/*******************************************************
   Mosel Example Problems 
   ======================

   file runrtdistr.java
   ````````````````````
   Running a model on a remote machine,
   passing runtime parameters to the submodel.

   Before running this model, you need to set up the 
   NODENAME with a machine name/address of your local network.
   The node that is used needs to have the same version of
   Xpress installed and suitably licensed, and the server 
   "xprmsrv" must have been started on this machine.
       
   (c) 2012 Fair Isaac Corporation
       author: S. Heipcke, Jan 2012
*******************************************************/

import com.dashoptimization.*;
import java.lang.*;
import java.io.*;

public class runrtdistr
{
 public static void main(String[] args) throws Exception
 {
  XPRD xprd=new XPRD();
  XPRDMosel mosInst=null;
  XPRDModel modRP=null;

       // Use the name or IP address of a machine in
       // your local network, or "" for current node
  String NODENAME = "";
                               // Open connection to a remote node
  mosInst=xprd.connect(NODENAME);
                               // Compile the model file
  mosInst.compile("", "rmt:rtparams.mos", "tmp:rp.bim"); 
                               // Load the bim file into the remote instance
  modRP=mosInst.loadModel("tmp:rp.bim"); 
                               // Run-time parameters
  modRP.execParams = "PARAM1=" + 2 + ",PARAM2=" + 3.4 + 
                     ",PARAM3='a string'" + ",PARAM4=true";
  modRP.run();                 // Run the model
  xprd.waitForEvent();         // Wait for model termination
  xprd.dropNextEvent();        // Ignore termination event message

  System.out.println("`rtparams' returned: " + modRP.getResult());

  mosInst.disconnect();        // Disconnect remote instance
 }
} 

Back to examples browserPrevious exampleNext example