public void RunProblem(string problemName, double optimalValue, int colCount, int rowCount, int nonZeroCount, int rangeCount, int objectSense, double objectConst, double[] objectCoeffs, double[] lowerBounds, double[] upperBounds, char[] rowType, double[] rhsValues, double[] rangeValues, int[] matrixBegin, int[] matrixCount, int[] matrixIndex, double[] matrixValues, string[] colNames, string[] rowNames, string objectName, double[] initValues, char[] colType) { IntPtr hProb; int result; logTxt.NewLine(); logTxt.WriteLine("Solve Problem: " + problemName + " (obj=" + optimalValue + ")"); logTxt.WriteLine("---------------------------------------------------------------"); hProb = CoinMP.CoinCreateProblem(problemName); result = CoinMP.CoinLoadMatrix(hProb, colCount, rowCount, nonZeroCount, rangeCount, objectSense, objectConst, objectCoeffs, lowerBounds, upperBounds, rowType, rhsValues, rangeValues, matrixBegin, matrixCount, matrixIndex, matrixValues); result = CoinMP.CoinLoadNames(hProb, colNames, rowNames, objectName); if (result != 0) { logTxt.WriteLine("CoinLoadProblem failed"); } if (colType != null) { result = CoinMP.CoinLoadInteger(hProb, colType); if (result != 0) { logTxt.WriteLine("CoinLoadInteger failed"); } } result = CoinMP.CoinCheckProblem(hProb); if (result != 0) { logTxt.WriteLine("Check Problem failed (result = " + result + ")"); } CoinMP.MsgLogDelegate MsgLogDelegate = new CoinMP.MsgLogDelegate(MsgLogCallback); result = CoinMP.CoinSetMsgLogCallback(hProb, MsgLogDelegate); result = CoinMP.CoinOptimizeProblem(hProb); result = CoinMP.CoinWriteFile(hProb, CoinMP.SOLV_FILE_MPS, problemName); GetAndCheckSolution(optimalValue, hProb); result = CoinMP.CoinUnloadProblem(hProb); }
public override object CreateProblem(int columns) { NUM_COLS = columns; NUM_ROWS = 0; ObjectCoeffs = new double[columns]; Matrix = new double[1, columns]; RowTypes = new char[1]; RhsValues = new double[1]; RangeValues = new double[1]; ColNames = new string[NUM_COLS]; RowNames = new string[1]; SosType = new int[1]; SosPrior = new int[1]; SosBegin = new int[1]; SosIndex = new int[1]; for (int i = 0; i < NUM_COLS; i++) { ColNames[i] = "C" + i; } return((IntPtr)CoinMP.CoinCreateProblem("Problem_CoinMP")); }