/********************************************************
BCL Example Problems
====================
file xbportf.c
``````````````
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 "xprb.h"
#include "xprs.h"
#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 bounds 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 */
/***********************************************************************/
void modfolio(XPRBprob prob)
{
int i,j;
XPRBctr cobj, c;
XPRBvar x[NVal]; /* Amount of a value taken into
the portfolio */
XPRBvar y[NVal]; /* 1 if value i is chosen, else 0 */
/**** VARIABLES ****/
for(i=0;i |