CoinCplexWrapper_2_0_32 2.0.1

dotnet add package CoinCplexWrapper_2_0_32 --version 2.0.1                
NuGet\Install-Package CoinCplexWrapper_2_0_32 -Version 2.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoinCplexWrapper_2_0_32" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CoinCplexWrapper_2_0_32 --version 2.0.1                
#r "nuget: CoinCplexWrapper_2_0_32, 2.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CoinCplexWrapper_2_0_32 as a Cake Addin
#addin nuget:?package=CoinCplexWrapper_2_0_32&version=2.0.1

// Install CoinCplexWrapper_2_0_32 as a Cake Tool
#tool nuget:?package=CoinCplexWrapper_2_0_32&version=2.0.1                

CoinMP - Cplex c# wrapper

This is a simple and straightforward wrapper for accessing from c# some of the callable APIs of either CoinMP or IBM Cplex. Other MIP solvers could be easily included when needed.

Wrapping is based on P/Invoke, simply linking the external solver dll's. The solver is expected to reside in the exe directory and to be named either CoinMP.dll or cplex.dll (no version number). The CoinMP solver actually expects to access also an addrows API that is not part of the current stable distribution. I implemented it and submitted the code.

The project webpage provides full Visual Studio 2019 solutions using the wrapper. It also has the CoinMP.dll implementing my addrows.

The wrapper is provided in two versions, a 32 bit version for CoinMP and a 64 bit version for cplex. Do not mix, it will not link.

Currently supported API are:

public Wrapper()
public bool getCoinMPSolver()
public bool getCPLEXSolver()
public int initSolver(bool solver)
public int closeSolver(bool solver)
public string getSolverName(bool solver)
public string getVersion(bool solver)
public WrapProblem createProblem(string problemName, bool solver)
public void loadProblem(WrapProblem problem, int colCount, int rowCount, int nzCount, int rangeCount, int objSense,
                        double objConst, double[] objCoeffs, double[] lowerBounds, double[] upperBounds,
                        string rowType, double[] rhsValues, double[] rangeValues, int[] matrixBegin,
                        int[] matrixCount, int[] matrixIndex, double[] matrixValues, string[] colNames,
                        string[] rowNames, string objName)
public void loadInteger(WrapProblem problem, string colType)
public void loadPriority(WrapProblem problem, int priorCount, int[] priorIndex, int[] priorValues,
                           int[] branchDirection)
public void loadSos(WrapProblem problem, int sosCount, int sosNzCount, int[] coinSosType, int[] sosPrior,
                     int[] sosBegin, int[] sosIndex, double[] sosRef, string cplexSosType, string[] sosNames)
public void loadQuadratic(WrapProblem problem, int[] quadBegin, int[] quadCount, int[] quadIndex,
                           double[] quadValues)
public void unloadProblem(WrapProblem problem)
public string getProblemName(WrapProblem problem)
public int getColCount(WrapProblem problem)
public int getRowCount(WrapProblem problem)
public string getColName(WrapProblem problem, int colIndex)
public string getRowName(WrapProblem problem, int rowIndex)
public void optimizeLpProblem(WrapProblem problem)
public void optimizeMipProblem(WrapProblem problem)
public int getSolutionStatus(WrapProblem problem)
public string getSolutionText(WrapProblem problem, int solutionStatus)
public double getObjectValue(WrapProblem problem)
public double getMipBestBound(WrapProblem problem)
public int getIterCount(WrapProblem problem)
public int getMipNodeCount(WrapProblem problem)
public void getSolutionValues(WrapProblem problem, double[] x,
                              double[] reducedCost, double[] slackValues,
                              double[] duals, bool isMIP = false)
public int getSolverStatus(WrapProblem problem)
public void getSolutionBasis(WrapProblem problem, int[] colStatus, double[] rowStatus)
public void readFile(WrapProblem problem, string fileName)
public void writeFile(WrapProblem problem, string ext)
public string getParamName(WrapProblem problem, int paramID)
public void getIntParamMinMax(WrapProblem problem, int paramID, out int minValue, out int maxValue)
public void getRealParamMinMax(WrapProblem problem, int paramID, out double minValue, out double maxValue)
public int getIntParam(WrapProblem problem, int paramID)
public void setIntParam(WrapProblem problem, int paramID, int intValue)
public double getRealParam(WrapProblem problem, int paramID)
public void setRealParam(WrapProblem problem, int paramID, double realValue)
public string getStringParam(WrapProblem problem, int paramID)
public void setStringParam(WrapProblem problem, int paramID, string strValue)
public void addrows(WrapProblem problem, int ccnt, int rcnt,
                     int nzcnt, double[] rhs, string sense,
                     int[] rmatbeg, int[] rmatind, double[] rmatval,
                     string[] colname, string[] rowname)
public void addrow(WrapProblem problem, double rhsvalue, double[] values, string sense, string rowname, string colname = null)
public void addcols(WrapProblem problem, int ccnt, int nzcnt,
                  double[] obj, int[] cmatbeg, int[] cmatind,
                  double[] cmatval, double[] lb, double[] ub,
                  string[] colname)
public void delrows(WrapProblem problem, int begin, int end)
public void delcols(WrapProblem problem, int begin, int end)

Basic usage:

// obj: (5/2)x - y
//  x + 2y <= 4
// 2x + y  >= 2
//  x + y  <= 7/2
//    x,y  >= 0
res = w.initSolver(w.getCoinMPSolver());
String problemName    = "SimpleTest";
int colCount          = 2; // tableau columns (without RHS)
int rowCount          = 3; // tableau rows (without nonnegativity, it goes in the bounds)
int nonZeroCount      = 6;
int rangeCount        = 0;
String objectName     = "obj";
int objectSense       = -1;
double objectConst    = 0.0;
double[] objectCoeffs = new double[] { 2.5, -1.0 };
double[] lowerBounds  = new double[] { 0, 0 };
double[] upperBounds  = new double[] { 1000000.0, 1000000.0 };
String rowType        = "LGL"; // inequality type: Lessereq, Greatereq, Equal, R (?), N (?)
double[] rhsValues    = new double[] { 4.0, 2.0, 3.5 }; // right hand side
int[] matrixBegin     = new int[] { 0, 3, 6 }; 
int[] matrixCount     = new int[] { 3, 3 };    
int[] matrixIndex     = new int[] { 0, 1, 2, 0, 1, 2 }; 
double[] matrixValues = new double[] { 1.0, 2.0, 1.0, 2.0, 1.0, 1.0 }; 
String[] colNames     = new String[] { "X", "Y" };
String[] rowNames     = new String[] { "r1", "r2", "r3" };
WrapProblem prob;
prob = w.createProblem(problemName, w.getCoinMPSolver());
w.loadProblem(prob, colCount, rowCount, nonZeroCount, rangeCount, objectSense, objectConst, objectCoeffs, lowerBounds,
              upperBounds, rowType, rhsValues, null, matrixBegin, matrixCount, matrixIndex,
              matrixValues, null, null, objectName);
// 2x - y <= 3
w.addrow(prob, 3.0, new double[] { 2.0, -1.0 }, "L", null);
w.optimizeLpProblem(prob);
w.unloadProblem(prob);
Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 552 2/1/2022
2.0.0 475 2/1/2022

First release, 32 bit version. There is also an analogous 64 bit one.