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.c

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

   file runrtdistr.c
   `````````````````
   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
*******************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "xprd.h"

int main(int argv,char *args[]) 
{
  XPRDcontext xprd;
  XPRDmosel mosInst;
  XPRDmodel modRP;
  char params[200];

       /* Use the name or IP address of a machine in
        * your local network, or "" for current node */
  char *NODENAME = "";

  xprd=XPRDinit();             /* Create an XPRD context */
                               /* Open connection to a remote node */
  mosInst=XPRDconnect(xprd, NODENAME, NULL, NULL, NULL, 0);
                               /* Compile the model file */
  XPRDcompmod(mosInst, "", "rmt:rtparams.mos", "tmp:rp.bim", "");
                               /* Load the bim file into the remote instance */
  modRP=XPRDloadmod(mosInst, "tmp:rp.bim"); 
                               /* Run-time parameters */
  sprintf(params, "PARAM1=%d,PARAM2=%g,PARAM3='a string',PARAM4=true", 2, 3.4);
  XPRDrunmod(modRP, params);   /* Run the model */
  XPRDwaitevent(xprd,-1);      /* Wait for model termination */
  XPRDdropevent(xprd);         /* Ignore termination event message */

  printf("`rtparams' returned: %d\n", XPRDgetexitcode(modRP));

  XPRDunloadmod(modRP);        /* Unload the model */
  XPRDdisconnect(mosInst);     /* Disconnect remote instance */
  XPRDfinish(xprd);            /* Terminate XPRD */
  return 0;
} 

Back to examples browserPrevious exampleNext example