/******************************************************** Xpress-BCL Java Example Problems ================================ file folioqp.java ````````````````` Modeling a small QP problem to perform portfolio optimization. -- 1. QP: minimize variance 2. MIQP: limited number of assets --- (c) 2008 Fair Isaac Corporation author: S.Heipcke, 2003, rev. Dec. 2011 ********************************************************/ import com.dashoptimization.*; import java.io.*; import java.lang.*; public class folioqp { static final String DATAFILE = System.getProperty("XPRBDATA") + "/GS/foliocppqp.dat"; static final int TARGET = 9; /* Target yield */ static final int MAXNUM = 4; /* Max. number of different assets */ static final int NSHARES = 10; /* Number of shares */ static final int NNA = 4; /* Number of North-American shares */ static final double[] RET = {5,17,26,12,8,9,7,6,31,21}; /* Estimated return in investment */ static final int[] NA = {0,1,2,3}; /* Shares issued in N.-America */ static double[][] VAR; /* Variance/covariance matrix of estimated returns */ static XPRB bcl; static XPRBprob p; private static void readData() throws IOException { int s,t; FileReader datafile=null; StreamTokenizer st=null; VAR = new double[NSHARES][NSHARES]; /* Read `VAR' data from file */ datafile=new FileReader(DATAFILE); /* Open the data file */ st=new StreamTokenizer(datafile); /* Initialize the stream tokenizer */ st.commentChar('!'); /* Use the character '!' for comments */ st.eolIsSignificant(true); /* Return end-of-line character */ st.parseNumbers(); /* Read numbers as numbers (not strings) */ for(s=0;s