Premium Solver for Excel - Object-Oriented Application Programming Interface
Object-Oriented API
The Premium Solver V8.0 includes support for the traditional VBA functions used to programmatically control the Solver, such as SolverOK and SolverSolve. But it also provides a new, high level, object-oriented API (Application Programming Interface) for optimization that complements the Risk Solver Engine object-oriented API, and closely resembles the object-oriented API of the Solver Platform SDK, Frontline's Software Development Kit for creating optimization and simulation models in a programming language.
The new object-oriented API is more powerful and much more convenient for programming the Solver than the traditional VBA functions. For example, instead of writing VBA code using the Excel object model to retrieve decision variable and constraint values from cells on the worksheet, or obtain sensitivity information from cells on a report worksheet, you can simply reference an API object and property to retrieve each of these values in an array in your program. |

The new object-oriented API offers
IntelliSense prompts in Excel VBA. |
Premium Solver Object Model
The Premium Solver makes available a hierarchy of objects for describing optimization problems, as pictured to the right.
The Problem object represents the whole problem, and the Model object represents the internal structure of the model, which in the Premium Solver is defined by your formulas on the spreadsheet. The Solver object represents the optimization process - you call its Optimize method to find an optimal solution. The Engine object represents either a built-in or plug-in Solver engine.
A Variable object represents a range of one or more contiguous cells that contains decision variables, while a Function object represents a range of cells that contains either constraint left hand sides or the objective.
Each Problem has a collection of Variable objects, and a collection of Function objects. An Evaluator represents a function you write that the Solver will call on each iteration (Trial Solution), or on each subproblem in a larger problem.
|

Object Hierarchy diagram |
The Model has a collection of ModelParam objects. An Engine has a collection of EngineParam objects, each representing a single option or parameter of a Solver engine. It also has an EngineLimit object, holding problem size limits for this Solver engine, and an EngineStat object, holding performance statistics for the last optimization problem solved by this engine. An OptIIS object holds results of an infeasibility analysis of the problem.
Example VBA Code Using the Object Model
Below is an example of VBA code that could be linked to a command button on the worksheet:
Private Sub CommandButton1_Click()
Dim prob As New Problem
prob.Engine = prob.Engines("Standard LP/Quadratic")
prob.Engine.Params("MaxTime") = 600
prob.Solver.Optimize
MsgBox "Status = " & prob.Solver.OptimizeStatus
MsgBox "Obj = " & prob.FcnObjective.FinalValue(0)
For i = 0 To prob.Variables.Count - 1
For j = 0 To prob.Variables(i).Size - 1
MsgBox prob.Variables(i).FinalValue(j)
Next j
Next i
Set prob = Nothing
End Sub
< Back to Premium Solver Product Overview