FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserNext example

Folio - Introductory examples from 'Getting Started'

Simple tasks for formulating and solving a portfolio optimization problem:
  • loading an LP problem via matrix input (folioinput.c)
  • inputting an LP problem from data arrays (foliolp.c)
  • inputting a MIP problem - binary variables (foliomip1.c)
  • inputting a MIP problem - semicontinuous variables (foliomip2.c)
  • inputting a QP problem (folioqp.c)
  • using the MIP solution enumerator (foliomatenumsol.c)
  • using the MIP solution pool (foliomatsolpool.c)

Source Files

Data Files


  Xpress Optimizer Example Problems

  file foliomatenumsol.c
  Using the MIP solution enumerator with a MIP problem
  input from a matrix file.

  (c) 2009 Fair Isaac Corporation
      author: D.Nielsen, S.Heipcke, July 2009, rev. Jul. 2014

#include <stdio.h>
#include <stdlib.h>
#include "xprs.h"
#include "xprs_mse_defaulthandler.h"

int main(int argc, char **argv)
 XPRSprob prob;
 XPRSmipsolpool msp;
 XPRSmipsolenum mse;
 int i, s, nSols, solID, nCols, solStatus, presolveOps, maxSols;
 double objval, sol;

 XPRSinit(NULL);                         /* Initialize Xpress Optimizer */
 XPRScreateprob(&prob);                  /* Create a new problem */
 XPRSreadprob(prob, "folio10_7.lp", "");    /* Read the problem matrix */

 /* Get the number of columns in the problem */
 XPRSgetintattrib(prob, XPRS_ORIGINALCOLS, &nCols);

 /* Create a mip solution pool to store the solutions */

 /* Create a mip solution enumerator to run the search */

 /* Disable heuristics to avoid duplicate solutions being found and stored */
 XPRSsetintcontrol(prob, XPRS_HEURSTRATEGY, 0);

 /* Disable presolve operations that attempt to improve the efficiency by 
    cutting off MIP solutions from the feasible region that are either:-
    1) Degenerate (i.e., that have equivalent representations with 
       different feasible values of the variables) or
    2) Dominated (i.e., that can be deduced to be worse than solutions 
       contained in the remaining feasible region). 
 XPRSgetintcontrol(prob, XPRS_PRESOLVEOPS, &presolveOps);  
 presolveOps &= ~(1 << 5);     /* Disable duplicate column removal  */
 presolveOps &= ~(1 << 3);     /* Disable dual reduction operations */
 XPRSsetintcontrol(prob, XPRS_PRESOLVEOPS, presolveOps);  
 XPRSgetintcontrol(prob, XPRS_MIPPRESOLVE, &presolveOps);  
 presolveOps &= ~(1 << 4);     /* Disable dual reductions */
 XPRSsetintcontrol(prob, XPRS_MIPPRESOLVE, presolveOps);  
 XPRSsetintcontrol(prob, XPRS_SYMMETRY, 0);  /* Disable symmetry detection */

 /* Run the enumeration */
 maxSols = 10;
 XPRS_mse_maxim(mse, prob, msp, XPRS_mse_defaulthandler, NULL, &maxSols);

 /* Get the number of solutions found */
 XPRS_mse_getintattrib(mse, XPRS_MSE_SOLUTIONS, &nSols);

 /* Print out the solutions found */
 for(i=1; i<=nSols; i++)
  XPRS_mse_getsollist(mse, XPRS_MSE_METRIC_MIPOBJECT, i, i, &solID, 
                      NULL, NULL);
  XPRS_mse_getsolmetric(mse, solID, &solStatus, XPRS_MSE_METRIC_MIPOBJECT,
  printf("--------\nSolution %d:  Objective: %g\n", i, objval);
  for(s=0; s<nCols ;s++) {
   XPRS_msp_getsol(msp, solID, &solStatus, &sol, s, s, NULL);
   if(sol!=0) printf("%3d: %g\n", s+1, sol);


 XPRSdestroyprob(prob);                  /* Delete the problem */ 
 XPRSfree();                             /* Terminate Xpress */
 return 0;

Back to examples browserNext example