# Updated NMath API for LP and MIP related classes

The Linear Programming (LP) and Mixed Integer Programming (MIP) classes in NMath are currently built upon the Microsoft Solver Foundation (MSF) library. However development and maintenance of the library was stopped in January 2017 with the final release of 3.1.0. With the release of NMath 7.2 the LP and MIP solver classes will be built on the Google OR-Tools library (GORT). With this change the API has been simplified primarily by reducing the complexity of the algorithm parameterization. And most importantly to many users, migrating to GORT will free NMath users from the MSF variable limits [1]. Finally, GORT is a modern .NET Standard Library and therefore can be used with .NET Framework, .NET Core, and .NET 5 projects, whereas MS Solver Foundation is restricted to NET Framework.

Beginning with the release of NMath 7.2 the following table lists the deprecated MS Solver Foundation classes on the left and their Google OR-Tools replacements, if necessary.

## API Changes

The primary change between the deprecated MSF classes and the GORT classes is in the reduced algorithm parameterization. For example, in the toy MIP problem coded below the only change in the API regards constructing the new GORT solver and the lack of need for the parameter helper class. Note that the entire problem setup and related classes are unchanged making it a simple job to migrate to the new solver classes.

``````  // The problem setup is identical between the new and the deprecated API.

// minimize -3*x1 -2*x2 -x3
var mip = new MixedIntegerLinearProgrammingProblem( new DoubleVector( -3.0, -2.0, -1.0 ) );

// x1 + x2 + x3 <= 7
mip.AddUpperBoundConstraint( new DoubleVector( 1.0, 1.0, 1.0 ), 7.0 );

// 4*x1 + 2*x2 +x3 = 12
mip.AddEqualityConstraint( new DoubleVector( 4.0, 2.0, 1.0 ), 12.0 );

// x1, x2 >= 0

// x3 is 0 or 1

// Make a new Google OR-Tools solver and solve the MIP
var solver = new PrimalSimplexSolverORTools();
solver.Solve( mip, true ); // true -> minimize

// Solve the same MIP with the old deprecated API
var solver = new PrimalSimplexSolver();
var solverParams = new PrimalSimplexSolverParams { Minimize = true };
solver.Solve( mip, solverParams );``````

NMath 7.2 is released on Nuget as usual.

[1] MS Solver Foundation variable limits: NonzeroLimit = 100000, MipVariableLimit = 2000, MipRowLimit = 2000, MipNonzeroLimit = 10000, CspTermLimit = 25000, LP variable limit = 1000

Top