/******************************************************** Xpress-BCL C++ Example Problems =============================== file foliodata.cpp `````````````````` Modeling a small LP problem to perform portfolio optimization. -- Data input from file -- (c) 2008 Fair Isaac Corporation author: S.Heipcke, Aug. 2003, rev. Mar. 2011 ********************************************************/ #include #include #include "xprb_cpp.h" using namespace std; using namespace ::dashoptimization; #define DATAFILE "foliocpplp.dat" #define NSHARES 10 // Number of shares #define NRISK 5 // Number of high-risk shares #define NNA 4 // Number of North-American shares double RET[NSHARES]; // Estimated return in investment char RISK[][100] = {"hardware", "theater", "telecom", "software", "electronics"}; // High-risk values among shares char NA[][100] = {"treasury", "hardware", "theater", "telecom"}; // Shares issued in N.-America XPRBindexSet SHARES; // Set of shares void readData(XPRBprob &p) { double value; int s; FILE *datafile; char name[100]; SHARES=p.newIndexSet("Shares",NSHARES); // Create the `SHARES' index set // Read `RET' data from file datafile=fopen(DATAFILE,"r"); for(s=0;s= 0,5); // Spend all the capital for(s=0;s