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.java
Data file(s): pfqcost.dat, pfubds.dat, pflcost.dat


xbportf.java
/********************************************************
  Xpress-BCL Java Example Problems
  ================================

  file xbportf.java
  `````````````````
  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. */

import java.io.*;
import com.dashoptimization.*;

public class xbportf
{
 static final int NVal = 30;      /* Total number of values */
 static final int LIMIT = 20;     /* Maximum number to be chosen */

 static final String QFILE = System.getProperty("XPRBDATA") +
   "/portf/pfqcost.dat";          /* Quadratic cost coefficients */
 static final String BFILE = System.getProperty("XPRBDATA") +
   "/portf/pfubds.dat";           /* Upper bounds on percentages */
 static final String CFILE = System.getProperty("XPRBDATA") +
   "/portf/pflcost.dat";          /* Linear cost coefficients */

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

 static XPRB bcl;
 static XPRBprob p;

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

 static void modFolio() throws IOException
 {
  XPRBctr c;
  XPRBexpr le, qobj;
  XPRBvar[] x;                    /* Amount of a value taken into
                                     the portfolio */
  XPRBvar[] y;                    /* 1 if value i is chosen, else 0 */
  int i,j;
  
/**** VARIABLES ****/
  x = new XPRBvar[NVal];
  y = new XPRBvar[NVal];
  for(i=0;i