How to: Create a Custom Solver Report using the SFS APIs
Solver Foundation 3.0
If you are using or creating a third-party solver, you can use the Solver Foundation Services reporting APIs to access the solver data and to extend the report to include data about custom properties.
To create a custom solver report
-
Add the following Imports or using statements.
-
Create a custom report class that inherits from LinearReport and that creates a new property called solutionGoals.
Class CustomReport Inherits LinearReport Private ReadOnly _linearModel As ILinearModel Private _lpSolutionMapping As LinearSolutionMapping Public Sub New(ByVal context As SolverContext, ByVal solver As ISolver, ByVal solution As Solution, ByVal solutionMapping As LinearSolutionMapping) MyBase.New(context, solver, solution, solutionMapping) _lpSolutionMapping = solutionMapping _linearModel = TryCast(solver, ILinearModel) If _linearModel Is Nothing Then Throw New ArgumentNullException() End If End Sub Public ReadOnly Property solutionGoals() As String Get ValidateSolution() Dim temp As String = "" For Each goal In Solution.Goals temp += ("The value of " & goal.Name & " is ") + goal.ToString() & ". " Next Return temp End Get End Property End Class
-
Generate a report using the custom property.
Show: