Initializing help system before first use

Portfolio - Quadratic Programming with discrete variables


Type: Portfolio optimization
Rating: 2
Description: Quadratic Mixed Integer Programming example demonstrating Quadratic Programming with discrete variables.
File(s): xbportf.cxx
Data file(s): pfqcost.dat, pfubds.dat, pflcost.dat


xbportf.cxx
/********************************************************
  Xpress-BCL C++ Example Problems
  ===============================

  file xbportf.cxx
  ````````````````
  Quadratic portfolio model.

  (c) 2008 Fair Isaac Corporation
      author: S.Heipcke, Jan. 2000, rev. Mar. 2011
********************************************************/

/* In this model, a choice has to be made which values are taken   *
 * into a portfolio in order to minimize the total cost. The costs *
 * for some values are interrelated, introducing a quadratic part  *
 * to the objective function. Upper bounds are given on the total  *
 * number of values and the share of each value that may be taken. */

#include 
#include 
#include 
#include "xprb_cpp.h"
#include "xprs.h"

using namespace std;
using namespace ::dashoptimization;

#define NVal 30                       /* Total number of values */
#define LIMIT 20                      /* Maximum number to be chosen */

#define QFILE XPRBDATAPATH "/portf/pfqcost.dat" /* Quadratic cost coeff.s */
#define BFILE XPRBDATAPATH "/portf/pfubds.dat"  /* Upper bds. on percentages */
#define CFILE XPRBDATAPATH "/portf/pflcost.dat" /* Linear cost coefficients */

/**** DATA ****/
double Cost[NVal];                    /* Coeff. of lin. part of the obj. */
double QCost[NVal][NVal];             /* Coeff. of quad. part of the obj. */
double UBnd[NVal];                    /* Upper bound values */

XPRBprob p("Portfolio");              /* Initialize a new problem in BCL */

/***********************************************************************/

void modFolio()
{
 XPRBexpr le, qobj;
 XPRBvar x[NVal];                 /* Amount of a value taken into
                                     the portfolio */
 XPRBvar y[NVal];                 /* 1 if value i is chosen, else 0 */
 int i,j;

/**** VARIABLES ****/
 for(i=0;i