/***************************************************************************************\ * Name: MipSolPool.cs Fair Isaac 13/06/2008 * * Purpose: All solutions with the MIP solution pool * * Description: We take the power generation problem stored in hpw15.mps which seeks to * * optimise the operating pattern of a group of electricity generators. We * * solve the problem collecting all solutions found during the MIP search. * * The optimal solution's objective and solution values are printed to * * screen. * * Input: hpw15.mps * \***************************************************************************************/ using System; using System.IO; using Optimizer; namespace XPRSExamples { class MipSolPool { static void Main(string[] args) { XPRS.Init(); XPRSprob prob = new XPRSprob(); prob.AddMsgHandlerCallback(Console.Out); XPRSmipsolpool msp = new XPRSmipsolpool(); msp.ProbAttach(prob); prob.MPSFormat = -1; prob.ReadProb(@"..\..\..\data\hpw15"); prob.Minim("g"); int nSols = msp.Solutions; if (nSols > 0) { int iSolutionId, iSolutionIdStatus; double dObj; msp.GetDblAttribProbExtreme(prob, 0, out iSolutionId, (int)XPRSattribute.Msp_SolPrb_Obj, out dObj); Console.WriteLine("Optimal Solution ID: " + iSolutionId); Console.WriteLine("Optimal Objective : " + dObj); int nCols = msp.GetIntAttribSol(iSolutionId, out iSolutionIdStatus, (int)XPRSattribute.Msp_Sol_Cols); for (int i = 0; i < nCols; i++) { int nValuesReturned; double[] dSol = new double[1]; msp.GetSol(iSolutionId, out iSolutionIdStatus, dSol, i, i, out nValuesReturned); Console.WriteLine(i + " = " + dSol[0]); } } XPRS.Free(); } } }