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





findservers.c

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

   file findservers.c
   ``````````````````
   Find Mosel servers that are able to accept remote model runs

   This file only produces output on the local node, 
   it does not start any remote runs.
       
   (c) 2013 Fair Isaac Corporation
       author: S. Heipcke, Jan. 2013
*******************************************************/

#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "xprd.h"

#define M 20                   /* Max. number of servers to be sought */

int main(int argv,char *args[]) 
{
  XPRDcontext xprd;
  XPRDmosel mosInst;
  struct in_addr Hosts[M];
  char buf[200];
  int hsize, i;

  xprd=XPRDinit();             /* Create an XPRD context */
 
  printf("Searching...\n"); fflush(stdout);
  hsize=XPRDfindxsrvs(xprd, 1,M, (unsigned int *)Hosts);
  printf("%d server(s) found.\n", hsize); fflush(stdout);
   
  for(i=0;i<hsize;i++) 
  {                            /* Open connection to a remote node */
    mosInst=XPRDconnect(xprd, inet_ntoa(Hosts[i]), NULL, NULL, NULL, 0);
    if (mosInst!=NULL)
    {
      printf("Server %s: %s\n", inet_ntoa(Hosts[i]),
        XPRDsysinfo(mosInst, XPRD_SYS_ALL, buf, sizeof(buf)));
      fflush(stdout);
      XPRDdisconnect(mosInst);     /* Disconnect remote instance */
    }
    else printf("Connection to %s failed\n", inet_ntoa(Hosts[i]));
  }
  
  XPRDfinish(xprd);            /* Terminate XPRD */
  return 0;
} 


Back to examples browserPrevious exampleNext example