Scip Class

Mathematical model solver using SCIP (https://www.scipopt.org/).

Definition

Namespace: Orx.MathProg.Solvers
Assembly: Orx.MathProg (in Orx.MathProg.dll) Version: 1.0.0
C#
public class Scip : ISolver
Inheritance
Object    Scip
Implements
ISolver

Constructors

ScipInitializes a new instance of the Scip class

Properties

DirectoryForTemporaryFiles Directory to be used for storing temporary files; operating system's temp folder is used by default.
Parameters Scip parameters.
SolverPath Path of the solver's binaries.

Methods

CheckAvailability Checks availability of the solver on the host, and returns the result.
  • The solver can be used if solver.CheckAvailability().IsOk.
  • The solver is not available otherwise. solver.CheckAvailability().ErrorMessage.Unwrap() provides the error details.
Possible fixes when solver.CheckAvailability().IsErr are as follows:
  • Make sure that the desired solver is installed on the host machine; such as cplex or scip.
  • Make sure that the solver's binary directory is included in the path variable.
  • Alternatively, one can provide the absolute path of the solver as follows:
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
GetHashCode
(Inherited from Object)
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
Solve(MathModel) Solves the given model and returns:
  • Ok of the solution if the execution is successfully completed,
  • experienced Err otherwise.

Assume we have just tried to solve the model.

C#
Scip scip = new();
var resSolution = await scip.Solve(model);

The result of the solution, resSolution here, can be used in different ways ().

#1: Handle error case and Unwrap

C#
if (resSolution.IsErr)
{
    // do something with the error:
    // * return a proper result
    // * throw an exception using the error message 'resSolution.ErrorMessage().Unwrap()'
}
MathModelSolution solution = resSolution.Unwrap();
// use the solution

#2: Use ThrowIfErr shorthand and Unwrap

C#
MathModelSolution solution = resSolution.ThrowIfErr().Unwrap();
// use the solution

#3: Map the solution to Res of the desired result

C#
Res<double> resObjVal = resSolution.Map(soln => soln.ObjectiveValue.UnwrapOr(double.PositiveInfinity));
// note that soln.ObjectiveValue can be None if the resSolution.IsOk (solver worked properly);
// however, the model is infeasible.
Solve(CancellationToken, MathModel) Solves the given model with a cancellationToken and returns:
  • Ok of the solution if the execution is successfully completed,
  • experienced Err otherwise.

Assume we have just tried to solve the model.

C#
Scip scip = new();
var resSolution = await scip.Solve(model);

The result of the solution, resSolution here, can be used in different ways ().

#1: Handle error case and Unwrap

C#
if (resSolution.IsErr)
{
    // do something with the error:
    // * return a proper result
    // * throw an exception using the error message 'resSolution.ErrorMessage().Unwrap()'
}
MathModelSolution solution = resSolution.Unwrap();
// use the solution

#2: Use ThrowIfErr shorthand and Unwrap

C#
MathModelSolution solution = resSolution.ThrowIfErr().Unwrap();
// use the solution

#3: Map the solution to Res of the desired result

C#
Res<double> resObjVal = resSolution.Map(soln => soln.ObjectiveValue.UnwrapOr(double.PositiveInfinity));
// note that soln.ObjectiveValue can be None if the resSolution.IsOk (solver worked properly);
// however, the model is infeasible.
ToString
(Inherited from Object)

See Also