Compilation and program execution
If you have followed the standard installation procedure of Xpress Optimizer, you may compile this file with the following command under Windows:
cl /MD /I%XPRESSDIR%\include %XPRESSDIR%\lib\xprs.lib foliolp.c
For Linux or Solaris use
cc -D_REENTRANT -I${XPRESSDIR}/include -L${XPRESSDIR}/lib foliolp.c -o foliolp -lxprs
For other systems please refer to the example makefile provided with the corresponding distribution.
Running the resulting program will generate the following output:
Total return: 14.0667 1: 30% 2: 0% 3: 20% 4: 0% 5: 6.66667% 6: 30% 7: 0% 8: 0% 9: 13.3333% 10: 0%
Under Unix this is preceded by the log of Xpress Optimizer:
Reading Problem FolioLP Problem Statistics 3 ( 0 spare) rows 10 ( 0 spare) structural columns 19 ( 0 spare) non-zero elements Global Statistics 0 entities 0 sets 0 set members Maximizing LP FolioLP Original problem has: 3 rows 10 cols 19 elements Presolved problem has: 3 rows 10 cols 19 elements Its Obj Value S Ninf Nneg Sum Inf Time 0 42.600000 D 2 0 .000000 0 5 14.066667 D 0 0 .000000 0 Uncrunching matrix 5 14.066667 D 0 0 .000000 0 Optimal solution found
Windows users can retrieve the Optimizer log by redirecting it to a file. Add the following line to your program immediately after the problem creation:
XPRSsetlogfile(prob, "logfile.txt");
The Optimizer log displays the size of the matrix, 3 rows (i.e. constraints) and 10 columns (i.e. decision variables), and the log of the LP solution algorithm (here: `D' for dual Simplex). The output produced by our program tells us that the maximum return of 14.0667 is obtained with a portfolio consisting of shares 1, 3, 5, 6, and 9. 30% of the total amount are spent in shares 1 and 6 each, 20% in 3, 13.3333% in 9 and 6.6667% in 5. It is easily verified that all constraints are indeed satisfied: we have 50% of North-American shares (1 and 3) and 33.33% of high-risk shares (3 and 9).