public void GetAndCheckSolution(double optimalValue, IntPtr hProb) { int solutionStatus; String solutionText; double objectValue; int i; int colCount; double[] xValues; int result; int length; String colName; String problemName; logMsg.WriteLine("---------------------------------------------------------------"); problemName = CoinMP.CoinGetProblemName(hProb); solutionStatus = CoinMP.CoinGetSolutionStatus(hProb); solutionText = CoinMP.CoinGetSolutionText(hProb); objectValue = CoinMP.CoinGetObjectValue(hProb); logTxt.WriteLine("Problem Name: " + problemName); logTxt.WriteLine("Solution Result: " + solutionText); logTxt.WriteLine("Solution Status: " + solutionStatus); logTxt.WriteLine("Optimal Value: " + objectValue + " (" + optimalValue + ")"); logTxt.WriteLine("---------------------------------------------------------------"); colCount = CoinMP.CoinGetColCount(hProb); xValues = new double[colCount]; result = CoinMP.CoinGetSolutionValues(hProb, xValues, null, null, null); for (i = 0; i < colCount; i++) { if (xValues[i] != 0.0) { colName = CoinMP.CoinGetColName(hProb, i); logTxt.WriteLine(colName + " = " + xValues[i]); } } logTxt.WriteLine("---------------------------------------------------------------"); logTxt.NewLine(); if (solutionStatus != 0) { MessageBox.Show("status=" + solutionStatus, problemName); } if (optimalValue != 0.0) { if (Math.Abs(objectValue - optimalValue) >= 0.001) { MessageBox.Show("Obj=" + objectValue + " <> " + optimalValue, problemName); } } }