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

Using the model return value for error handling

Description
The default return value of a Mosel model at the end of its execution is 0. Other values may be set with the procedure exit as shown in the file exitvalue.mos. The model return values can be used by the calling application (exitvalue.c, runexitvalue.mos) for the implementation of error handling routines.


Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
exitvalue.mos[download]
exitvalue.c[download]
runexitvalue.mos[download]





exitvalue.c

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

   file exitvalue.c
   ````````````````
   Example of the use of `exit' for error handling in C.
       
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Feb. 2002
*******************************************************/

#include <stdio.h>
#include <stdlib.h>
#include "xprm_mc.h"
#include "xprm_rt.h"

int main()
{
 int result;
 XPRMmodel mod;

 XPRMinit();

 XPRMcompmod(NULL,"exitvalue.mos",NULL,""); /* Compile the model */
 mod=XPRMloadmod("exitvalue.bim",NULL);     /* Load the BIM file */
 XPRMrunmod(mod,&result,NULL);              /* Run the model */

 switch(result)
 {
  case 0: printf("Integer solution: %g\n", XPRMgetobjval(mod)); break;
  case 1: printf("LP infeasible\n"); break;
  case 2: printf("No integer solution\n"); break;
 }

 return 0;
}

Back to examples browserPrevious exampleNext example