[ITEM]
12.04.2020

Microsoft Solver Foundation Tutorial Pdf

82

Microsoft Solver Foundation?

Assembly: Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll) Syntax. Public sealed class Solution The Solution type exposes the following members. Properties Name Description; Decisions: Gets the decisions and values for the solution of a model. Basic implementation of MilpManager using Microsoft Solver Foundation - afish/MsfMilpSolver.

Microsoft Solver Foundation is an extensible .NET framework that helps you model and solve complex problems by:

  • Modeling and solving scenarios by using constraints, goals, and data.
  • Programming in the Optimization Modeling Language (OML), in C# imperatively, in F# functionally, or in any .NET Framework language.
  • Integrating third-party solvers, such as Gurobi, Mosek™, FICO™ Xpress, LINDO, CPLEX®, and lp_solve.
  • Using familiar interfaces in Microsoft Office Excel and SharePoint to create and solve models.

Modeling and solving capabilities
Solver Foundation Services (SFS) can automatically analyze models and determine which solver is most appropriate. If you are an advanced modeler, you can choose specific solvers and solver attributes. While solving the models, SFS manages all threading, many-core, synchronization, scheduling, and model execution issues. When finished, SFS produces reports about solver behavior and results, and provides additional information about solutions, including sensitivity. Finally, SFS allows LINQ data binding of model parameters and delivery of results in multiple formats.

Program in OML, F#, C#, VB, C++, IronPython, and more
Solver Foundation supports all the .NET Framework languages and provides samples in many of them. In addition, if you prefer a modeling language, you can use Solver Foundation's type safe optimization modeling language (OML).

Integrated and Third-Party Solvers
Solver Foundation allows new or existing third-party solvers to plug into the SFS directly, avoiding the need to learn a new modeling language or the significant overhead in managing solver specific solutions. These solvers include numerical, symbolic, and search algorithms that you can use in your models. There is a collection of certified partner wrappers for Gurobi, Mosek™, FICO™ Xpress, and LINDO, as well as reference wrapper source code for CPLEX® and lp_solve.

The following system diagram describes the extensible architecture of Microsoft Solver Foundation.

For more information see Microsoft Solver Foundation blog

Introduction

Solver Foundation can be approached either at the Solver Foundation Services (SFS) level or via the APIs for specific kinds of solver.

The SFS level is recommended for conceptual clarity of modeling, for ease of binding to data from various sources, for educational use, for introducing you to all the capabilities of Solver Foundation, for automatic selection of a solver to suit your model, and for construction of models which may require the use of more than one kind of solver. Solver Foundation will be heavily investing in the SFS.

The Solver-specific APIs are intended for use by experienced programmers who clearly know which kind of solver they need to use, are prepared to write code to translate a model into a sequence of API calls, and where the usage is to be embedded in an application where the application is fully responsible for capturing the model and supplying the instance data. Inca iuwa-150m driver for mac os.

The advantage of using the SFS level is that code is (almost) solver independent. In the ideal case the system chooses which solver to use dependent of the model and availability of solvers. Solver choice can also be instructed via the configuration file. To have more control of the chosen solver and its parameters also a specific solver directive can be chosen in the code. Only that directive code is then solver specific.

The advantage of using the API of the specific solver is that you have more control over the solvers' specific features. Robots 2005 pc game. But the disadvantage is that you are targetting specifically that solver and it is thus more difficult to change solver.

The Microsoft solver foundation team recommend use of the Solver Foundation Services unless you are absolutely sure you need to program direct to a specific solver API.

Microsoft Foundation Solver and lpsolve

lpsolve is callable from Microsoft Foundation Solver via a wrapper or plugin. As such, it looks like lpsolve is fully integrated with Microsoft Foundation Solver.
This plugin acts as a bridge between Solver foundation and lpsolve.
Users of the plugin and MSF need to register the new solver in the app.config in order to use it.
To use the lpsolve plugin with MSF:

  • Copy the compiled lpsolve plugin wrapper code i.e LpSolvePlugIn.dll and the lpsolve library i.e lpsolve55.dll to the binDebug, binRelease folder. As an alternative, MSF has created a registry key 'HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft Solver Foundation' with a string value PluginDirectory. The lpsolve plugin can also installed in this folder. MSF will search first in the folder of the executable that embeds Solver Foundation, and then in the plug-in directory specified in the registry key. In 64-bit machines, Solver Foundation will also create the same registry key for 32-bit apps. The key will be stored under 'HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft'
  • Add a new file App.config to the project or edit the existing App.config and paste the solver registration contents as below:
    {Version} must be replaced by the version of MSF that is used. For example 2.0.2.8632 or 2.0.3.9657

LpSolveDirective object

Microsoft Foundation Services can instruct the solver via a directive. All properties and methods starting with LpSolve are lp_solve specific and control the solver. All others are inherited from the base Directive object. These are the available properties and methods:

ArithmeticGet or set the arithmetic to use for numeric solving. lp_solve only allows double arithmetic. Setting this property to something different from Double or Default will result in a NotImplementedException exception.
GetSensitivityWhether to generate sensitivity information at report. The default is False.
LpSolveLogFuncA log callback function to allow lp_solve to return information to the application. See put_logfunc
LpSolveMsgFuncA message callback function to allow lp_solve to return information to the application. See put_msgfunc
LpSolveAntiDegenSee set_anti_degen
LpSolveBasiscrashSee set_basiscrash
LpSolveBbDepthlimitSee set_bb_depthlimit
LpSolveBbFloorfirstSee set_bb_floorfirst
LpSolveBbRuleSee set_bb_rule
LpSolveBreakAtFirstSee set_break_at_first
LpSolveBreakAtValueSee set_break_at_value
LpSolveDebugSee set_debug
LpSolveEpsbSee set_epsb
LpSolveEpsdSee set_epsd
LpSolveEpselSee set_epsel
LpSolveEpsintSee set_epsint
LpSolveEpsperturbSee set_epsperturb
LpSolveEpspivotSee set_epspivot
LpSolveImproveSee set_improve
LpSolveInfiniteSee set_infinite
LpSolveLogFileSee set_outputfile
LpSolveMaxpivotSee set_maxpivot
LpSolveMipGapAbsSee set_mip_gap
LpSolveMipGapRelSee set_mip_gap
LpSolveNegrangeSee set_negrange
LpSolveObjBoundSee set_obj_bound
LpSolveObjInBasisSee set_obj_in_basis
LpSolvePivotingSee set_pivoting
LpSolvePresolveSee set_presolve
LpSolvePresolveMaxLoopsSee set_presolve
LpSolveReadParamsRead all settings from a file. See read_params
LpSolveScalelimitSee set_scalelimit
LpSolveScalingSee set_scaling
LpSolveSimplextypeSee set_simplextype
LpSolveSolutionlimitSee set_solutionlimit
LpSolveTimeoutSee set_timeout
LpSolveTraceSee set_trace
LpSolveVerboseSee set_verbose
MaximumGoalCountGet and set the maximum number of goals to optimize. lp_solve allows only one goal. If something different from 1 is specified, a NotImplementedException will be thrown.
TimeLimitGet and set the time-limit (in milliseconds) of Solve. No limit if it is set to a negative value. Default value is -1 (no limit).
WaitLimitGet and set the amount of time (in milliseconds) the SFS will wait for a result after requesting a timeout/abort.

LpSolveSolver object (API)

When the solver is called directly via the API, the LpSolveSolver object is used to build and solve the model. All properties and methods starting with LpSolve are lp_solve specific and control the solver. All others are inherited from the base object. These are the available properties and methods:

LpSolveLogFuncA log callback function to allow lp_solve to return information to the application. See put_logfunc
LpSolveMsgFuncA message callback function to allow lp_solve to return information to the application. See put_msgfunc
LpSolvePrintDebugDumpSee print_debugdump
LpSolveWriteLpSee write_lp
LpSolveWriteMPSSee write_mps
LpSolveWriteParamsSee write_params
LpSolveWriteXLISee write_XLI

The LpSolveSolver object can also be subclassed to override the LpSolveLogFunc and LpSolveMsgFunc methods. That is an alternative for providing the these functions via the LpSolveLogFunc and LpSolveMsgFunc properties. That will be shown in the examples below.

SFS examples

Example1

This gives as output:

Example2

This gives as output:

Example3

It is also possible to return and access the sensitivity information (from MSF version 2.1). This is demonstrated by this example. This is the same example as in the sensitivity section.

Note that GetSensitivity on the directive must be set on true to get sensitivity information. By default this is not set and as in the examples above there is no sensitivity information provided if not set.

This gives as output:

Note that sensitivity information can also be retrieved from the report in variables via the methods GetAllShadowPrices() and GetAllConstraintBoundsSensitivity()

Example4

This example is an extension to Example3. Sensitivity is not asked and thus not reported. COLFOUR is defined as integer and an extra constraint is added. This constraint will be removed afterwards. Also log and message callback functions are set to show the lp_solve optimization process.

This gives as output:

API examples

Example5

This gives as output:

Example6

This gives as output:

Example7

This gives as output:

See also Using lpsolve from MATLAB, Using lpsolve from O-Matrix, Using lpsolve from Sysquake, Using lpsolve from Octave, Using lpsolve from FreeMat, Using lpsolve from Euler, Using lpsolve from Python, Using lpsolve from Sage, Using lpsolve from PHP, Using lpsolve from Scilab

[/ITEM]
[/MAIN]
12.04.2020

Microsoft Solver Foundation Tutorial Pdf

78

Microsoft Solver Foundation?

Assembly: Microsoft.Solver.Foundation (in Microsoft.Solver.Foundation.dll) Syntax. Public sealed class Solution The Solution type exposes the following members. Properties Name Description; Decisions: Gets the decisions and values for the solution of a model. Basic implementation of MilpManager using Microsoft Solver Foundation - afish/MsfMilpSolver.

Microsoft Solver Foundation is an extensible .NET framework that helps you model and solve complex problems by:

  • Modeling and solving scenarios by using constraints, goals, and data.
  • Programming in the Optimization Modeling Language (OML), in C# imperatively, in F# functionally, or in any .NET Framework language.
  • Integrating third-party solvers, such as Gurobi, Mosek™, FICO™ Xpress, LINDO, CPLEX®, and lp_solve.
  • Using familiar interfaces in Microsoft Office Excel and SharePoint to create and solve models.

Modeling and solving capabilities
Solver Foundation Services (SFS) can automatically analyze models and determine which solver is most appropriate. If you are an advanced modeler, you can choose specific solvers and solver attributes. While solving the models, SFS manages all threading, many-core, synchronization, scheduling, and model execution issues. When finished, SFS produces reports about solver behavior and results, and provides additional information about solutions, including sensitivity. Finally, SFS allows LINQ data binding of model parameters and delivery of results in multiple formats.

Program in OML, F#, C#, VB, C++, IronPython, and more
Solver Foundation supports all the .NET Framework languages and provides samples in many of them. In addition, if you prefer a modeling language, you can use Solver Foundation's type safe optimization modeling language (OML).

Integrated and Third-Party Solvers
Solver Foundation allows new or existing third-party solvers to plug into the SFS directly, avoiding the need to learn a new modeling language or the significant overhead in managing solver specific solutions. These solvers include numerical, symbolic, and search algorithms that you can use in your models. There is a collection of certified partner wrappers for Gurobi, Mosek™, FICO™ Xpress, and LINDO, as well as reference wrapper source code for CPLEX® and lp_solve.

The following system diagram describes the extensible architecture of Microsoft Solver Foundation.

For more information see Microsoft Solver Foundation blog

Introduction

Solver Foundation can be approached either at the Solver Foundation Services (SFS) level or via the APIs for specific kinds of solver.

The SFS level is recommended for conceptual clarity of modeling, for ease of binding to data from various sources, for educational use, for introducing you to all the capabilities of Solver Foundation, for automatic selection of a solver to suit your model, and for construction of models which may require the use of more than one kind of solver. Solver Foundation will be heavily investing in the SFS.

The Solver-specific APIs are intended for use by experienced programmers who clearly know which kind of solver they need to use, are prepared to write code to translate a model into a sequence of API calls, and where the usage is to be embedded in an application where the application is fully responsible for capturing the model and supplying the instance data. Inca iuwa-150m driver for mac os.

The advantage of using the SFS level is that code is (almost) solver independent. In the ideal case the system chooses which solver to use dependent of the model and availability of solvers. Solver choice can also be instructed via the configuration file. To have more control of the chosen solver and its parameters also a specific solver directive can be chosen in the code. Only that directive code is then solver specific.

The advantage of using the API of the specific solver is that you have more control over the solvers' specific features. Robots 2005 pc game. But the disadvantage is that you are targetting specifically that solver and it is thus more difficult to change solver.

The Microsoft solver foundation team recommend use of the Solver Foundation Services unless you are absolutely sure you need to program direct to a specific solver API.

Microsoft Foundation Solver and lpsolve

lpsolve is callable from Microsoft Foundation Solver via a wrapper or plugin. As such, it looks like lpsolve is fully integrated with Microsoft Foundation Solver.
This plugin acts as a bridge between Solver foundation and lpsolve.
Users of the plugin and MSF need to register the new solver in the app.config in order to use it.
To use the lpsolve plugin with MSF:

  • Copy the compiled lpsolve plugin wrapper code i.e LpSolvePlugIn.dll and the lpsolve library i.e lpsolve55.dll to the binDebug, binRelease folder. As an alternative, MSF has created a registry key 'HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft Solver Foundation' with a string value PluginDirectory. The lpsolve plugin can also installed in this folder. MSF will search first in the folder of the executable that embeds Solver Foundation, and then in the plug-in directory specified in the registry key. In 64-bit machines, Solver Foundation will also create the same registry key for 32-bit apps. The key will be stored under 'HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft'
  • Add a new file App.config to the project or edit the existing App.config and paste the solver registration contents as below:
    {Version} must be replaced by the version of MSF that is used. For example 2.0.2.8632 or 2.0.3.9657

LpSolveDirective object

Microsoft Foundation Services can instruct the solver via a directive. All properties and methods starting with LpSolve are lp_solve specific and control the solver. All others are inherited from the base Directive object. These are the available properties and methods:

ArithmeticGet or set the arithmetic to use for numeric solving. lp_solve only allows double arithmetic. Setting this property to something different from Double or Default will result in a NotImplementedException exception.
GetSensitivityWhether to generate sensitivity information at report. The default is False.
LpSolveLogFuncA log callback function to allow lp_solve to return information to the application. See put_logfunc
LpSolveMsgFuncA message callback function to allow lp_solve to return information to the application. See put_msgfunc
LpSolveAntiDegenSee set_anti_degen
LpSolveBasiscrashSee set_basiscrash
LpSolveBbDepthlimitSee set_bb_depthlimit
LpSolveBbFloorfirstSee set_bb_floorfirst
LpSolveBbRuleSee set_bb_rule
LpSolveBreakAtFirstSee set_break_at_first
LpSolveBreakAtValueSee set_break_at_value
LpSolveDebugSee set_debug
LpSolveEpsbSee set_epsb
LpSolveEpsdSee set_epsd
LpSolveEpselSee set_epsel
LpSolveEpsintSee set_epsint
LpSolveEpsperturbSee set_epsperturb
LpSolveEpspivotSee set_epspivot
LpSolveImproveSee set_improve
LpSolveInfiniteSee set_infinite
LpSolveLogFileSee set_outputfile
LpSolveMaxpivotSee set_maxpivot
LpSolveMipGapAbsSee set_mip_gap
LpSolveMipGapRelSee set_mip_gap
LpSolveNegrangeSee set_negrange
LpSolveObjBoundSee set_obj_bound
LpSolveObjInBasisSee set_obj_in_basis
LpSolvePivotingSee set_pivoting
LpSolvePresolveSee set_presolve
LpSolvePresolveMaxLoopsSee set_presolve
LpSolveReadParamsRead all settings from a file. See read_params
LpSolveScalelimitSee set_scalelimit
LpSolveScalingSee set_scaling
LpSolveSimplextypeSee set_simplextype
LpSolveSolutionlimitSee set_solutionlimit
LpSolveTimeoutSee set_timeout
LpSolveTraceSee set_trace
LpSolveVerboseSee set_verbose
MaximumGoalCountGet and set the maximum number of goals to optimize. lp_solve allows only one goal. If something different from 1 is specified, a NotImplementedException will be thrown.
TimeLimitGet and set the time-limit (in milliseconds) of Solve. No limit if it is set to a negative value. Default value is -1 (no limit).
WaitLimitGet and set the amount of time (in milliseconds) the SFS will wait for a result after requesting a timeout/abort.

LpSolveSolver object (API)

When the solver is called directly via the API, the LpSolveSolver object is used to build and solve the model. All properties and methods starting with LpSolve are lp_solve specific and control the solver. All others are inherited from the base object. These are the available properties and methods:

LpSolveLogFuncA log callback function to allow lp_solve to return information to the application. See put_logfunc
LpSolveMsgFuncA message callback function to allow lp_solve to return information to the application. See put_msgfunc
LpSolvePrintDebugDumpSee print_debugdump
LpSolveWriteLpSee write_lp
LpSolveWriteMPSSee write_mps
LpSolveWriteParamsSee write_params
LpSolveWriteXLISee write_XLI

The LpSolveSolver object can also be subclassed to override the LpSolveLogFunc and LpSolveMsgFunc methods. That is an alternative for providing the these functions via the LpSolveLogFunc and LpSolveMsgFunc properties. That will be shown in the examples below.

SFS examples

Example1

This gives as output:

Example2

This gives as output:

Example3

It is also possible to return and access the sensitivity information (from MSF version 2.1). This is demonstrated by this example. This is the same example as in the sensitivity section.

Note that GetSensitivity on the directive must be set on true to get sensitivity information. By default this is not set and as in the examples above there is no sensitivity information provided if not set.

This gives as output:

Note that sensitivity information can also be retrieved from the report in variables via the methods GetAllShadowPrices() and GetAllConstraintBoundsSensitivity()

Example4

This example is an extension to Example3. Sensitivity is not asked and thus not reported. COLFOUR is defined as integer and an extra constraint is added. This constraint will be removed afterwards. Also log and message callback functions are set to show the lp_solve optimization process.

This gives as output:

API examples

Example5

This gives as output:

Example6

This gives as output:

Example7

This gives as output:

See also Using lpsolve from MATLAB, Using lpsolve from O-Matrix, Using lpsolve from Sysquake, Using lpsolve from Octave, Using lpsolve from FreeMat, Using lpsolve from Euler, Using lpsolve from Python, Using lpsolve from Sage, Using lpsolve from PHP, Using lpsolve from Scilab