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

Defining and retrieving annotations

  • annottest.mos: Defining and accessing annotations
  • annotdisplay.c: Retrieving annotations into a C program (requires annottest.mos)
  • Retrieving annotations into a Java program (requires annottest.mos)
Further explanation of this example: 'Mosel User Guide', Section 18.1 Accessing annotations

Source Files


   Mosel User Guide Example Problems

   file annotdisplay.c
   Compiling and loading a model to retrieve some
   annotations from it for display.
   (c) 2015 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2015

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

/* Maximum number of annotations */
#define MAXANN 100

int main()
 XPRMmodel mod;
 void *ref;
 const char *symb;                    /* A model object name */
 const char *ann[MAXANN*2];           /* List of annotations */
 int i,n;

 if(XPRMinit())                       /* Initialize Mosel */
  return 1;

 if(XPRMcompmod(NULL, "annottest.mos", NULL, "Annotation example"))
  return 2;                           /* Compile the model into a BIM */

 if((mod=XPRMloadmod("annottest.bim",NULL))==NULL)  /* Load the BIM file */
  return 3;

/* Retrieve and display global annotations */
 printf("Global annotations (total: %d):\n", n/2);
 for(i=0;i<n && i<MAXANN;i+=2)
  printf("   %s:%s\n",ann[i],(ann[i+1]!=NULL)?ann[i+1]:"");

/* Retrieve and display all annotations associated with model objects */
 printf("Annotations associated with objects:\n");
  printf(" %s->\n",symb);
  for(i=0;i<n && i<MAXANN;i+=2)
   printf("   %s:%s\n",ann[i],(ann[i+1]!=NULL)?ann[i+1]:"");

/* Retrieve and display annotations for model object 'myint' */
 printf("Annotations defined for 'myint' (total: %d):\n", n/2);
 for(i=0;i<n && i<MAXANN;i+=2)
  printf("   %s:%s\n",ann[i],(ann[i+1]!=NULL)?ann[i+1]:"");

 return 0;

Back to examples browserPrevious exampleNext example