/******************************************************** Xpress-BCL C# Example Problems ============================== file foliomip1.cs ````````````````` Modeling a small MIP problem to perform portfolio optimization. -- Limiting the total number of assets -- (c) 2008-2023 Fair Isaac Corporation authors: S.Heipcke, D.Brett. ********************************************************/ using System; using System.Text; using System.IO; using BCL; namespace Examples { public class TestUGFolioMip1 { const int MAXNUM = 4; // Max. number of different assets const int NSHARES = 10; // Number of shares const int NRISK = 5; // Number of high-risk shares const int NNA = 4; // Number of North-American shares double[] RET = {5,17,26,12,8,9,7,6,31,21}; // Estimated return in investment int[] RISK = {1,2,3,8,9}; // High-risk values among shares int[] NA = {0,1,2,3}; // Shares issued in N.-America public static void Main() { XPRB.init(); int s; XPRBprob p = new XPRBprob("FolioMIP1"); // Initialize a new problem in BCL XPRBexpr Risk,Na,Return,Cap,Num; XPRBvar[] frac = new XPRBvar[NSHARES]; // Fraction of capital used per share XPRBvar[] buy = new XPRBvar[NSHARES]; // 1 if asset is in portfolio, 0 otherwise TestUGFolioMip1 TestInstance = new TestUGFolioMip1(); // Create the decision variables (including upper bounds for `frac') for(s=0;s= 0,5); // Spend all the capital Cap = new XPRBexpr(); for(s=0;s