The Model object is used to store all the information that's + available for a particular model and perform actions, such as reading model files into memory and then solving them. The Model object is an element of the parent Models collection
Returns the ConstraintVectors collection for the model. (Object Property)
Returns the DataConstants collection for the model. (Object Property)
Returns the DataVectors collection for the model. (Object Property)
Returns the IndexSets collection for the model. (Object Property)
Returns the Macros collection for the model. (Object Property)
Returns the PlainConstraints collection for the model. (Object Property)
Returns the PlainVariables collection for the model. (Object Property)
Returns the Symbols collection for the model. (Object Property)
Returns the VariableVectors collection for the model. (Object Property)
Visual Basic Example:
Dim MPL As OptiMax
Dim planModel As Model
Dim prodVarVector As VariableVector
Set MPL = New OptiMax
MPL.WorkingDirectory = "c:\mplwin4"
Set planModel = MPL.Models.Add("Planning")
Result = planModel.ReadModel("Planning.mpl")
Set prodVarVector = planModel.VariableVectors("Sales")
Returns the Matrix object for the model. (Object Property)
Returns the Solution object for the model. (Object Property)
Visual Basic Example:
Dim MPL As OptiMax
Dim planModel As Model
Dim planMatrix As Matrix
Dim planSol As Solution
Set MPL = New OptiMax
MPL.Solvers.Add("CPLEX")
MPL.WorkingDirectory = "c:\mplwin4"
Set planModel = MPL.Models.Add("Planning")
PlanModel.ReadModel("Planning.mpl")
PlanModel.Solve
Set PlanMatrix = planModel.Matrix
Set planSol = planModel.Solution
Specifies whether beep is sounded after model is solved. (Boolean Property - Read/Write)
The error message from the last Read or Parse method call. (String Property - Read Only)
VisualBasic Example:
Dim MPL As OptiMax
Dim planModel As Model
Dim Result As Integer
Set MPL = New OptiMax
MPL.Solvers.Add("CPLEX")
MPL.WorkingDirectory = "c:\mplwin4"
Set planModel = MPL.Models.Add("Planning")
Result = planModel.ReadModel("Planning.mpl")
If Result > 0 Then
Debug.Print "MPL ERROR MESSAGE: " & mplModel.ErrorMessage
End If
The error number from the last Read or Parse method call. (Integer Property - Read Only)
The error line number from the last Read or Parse method call. (Integer Property - Read Only)
The error column number from the last Read or Parse method call. (Integer Property - Read Only)
The error filename from the last Read or Parse method call. (String Property - Read Only)
The filename of the current model file. (String Property - Read Only)
The result code from the last Read or Parse method call. (Integer Property - Read Only)
The name of the model object. (String Property - Read/Write)
The full pathname for the current model file. (String Property - Read/Write)
The result string from the last Read, Parse, or Solve method call. (String Property - Read/Write)
The native solver environment pointer for the current model. (Pointer property - Read Only)
The native solver problem instance pointer for the current model. (Pointer property - Read Only)
The model name that is given with the TITLE statement in MPL. (String Property - Read/Write)
The current working directory for the model. (String Property - Read/Write)
Cancel the current run as soon as possible. (Method)
Checks the syntax for the model file. (Method)
Clears the model currently stored in memory. (Method)
Defines a conditional directive for the model. (Method)
Loads the current model into the solver. (Method)
Parses in a string source containing MPL model statements, appending it to the model already in memory. (Method)
Parses in a string source containing MPL model statements, clearing the existing model in memory. (Method)
VisualBasic Example:
Private Function ParseCuttingStockModel() As Integer
MPL.StatusWindowAutomatic = False
MPL.StatusWindowVisible = True
csModel.ParseModel ("TITLE CuttingStock")
csModel.Parse ("INDEX cuts := EXCELRANGE(""CutStock.xls"", ""CutsTable"", 1);")
csModel.Parse ("INDEX patterns := EXCELRANGE(PatternTable,1);")
csModel.Parse ("DATA PriceSheet := EXCELRANGE(PriceSheet);")
csModel.Parse ("DATA SheetsAvail := EXCELRANGE(SheetsAvail);")
csModel.Parse ("DATA CutWidths[cuts] := EXCELSPARSE(CutsTable,2);")
csModel.Parse ("DATA CutDemand[cuts] := EXCELSPARSE(CutsTable,3);")
csModel.Parse ("DATA PatWaste[patterns] := EXCELRANGE(PatternTable);")
csModel.Parse ("DATA CutsInPattern[patterns, cuts] := EXCELRANGE(Patterns);")
csModel.Parse ("VAR SheetsCut -> T1 EXPORT TO " & _
" EXCELRANGE(""CutStock.xls"", SheetsToCut);")
csModel.Parse ("VAR TotalCost -> TC EXPORT TO EXCELRANGE(TotalCost);")
csModel.Parse ("VAR PatternCount[patterns] -> PT EXPORT TO EXCELRANGE(PatCount);")
csModel.Parse ("VAR ExcessCuts[cuts] -> X;")
csModel.Parse ("MODEL")
csModel.Parse (" MIN z = PriceSheet*SheetsCut;")
csModel.Parse ("SUBJECT TO TotCost: TotalCost = PriceSheet * SheetsCut;")
csModel.Parse ("SUBJECT TO RawAvail: SheetsCut <= SheetsAvail;")
csModel.Parse ("SUBJECT TO Sheets: SheetsCut = "SUM(patterns: PatterCount);")
csModel.Parse ("SUBJECT TO CutReq[cuts] * PatternCount[patterns: & _
"CutsInPattern=[patterns, cuts] * PatternCount[patterns]) " & _
"= CutDemand[cuts] + ExcessCuts[cuts];")
ParseCuttingStockMOdel = csModel.Parse("End")
End Function
Reads a model file containing MPL model statements, appending it to the model already in memory. (Method)
Reads model file containing MPL model statements, clearing the existing model in memory. (Method)
Solves the model currently stored in the Matrix object. (Method)
VisualBasic Example:
Dim MPL As OptiMax
Dim planModel as Model
Dim dietModel as Model
Dim theModel as Model
Set MPL = New OptiMax
MPL.Solvers.Add("CPLEX")
planModel = MPL.Models.Add "planning"
dietModel = MPL.Models.Add "diet"
For Each theModel In MPL.Models
theModel.ReadModel(theModel.Name & ".mpl")
theModel.Solve
Next theModel
Reads the file into a new model and then solves it. (Method)
Returns a string representing the Model object. (Method)
Writes out an input file for the current model. (Method)
Writes out an mapping file for the current model. (Method)
Writes out an MPS file for the current model. (Method)
VisualBasic Example:
Dim MPL As OptiMax
Dim planModel As Model
Set MPL = New OptiMax
MPL.WorkingDirectory = "c:\mplwin4"
Set planModel = MPL.Models.Add("Planning")
planModel.ReadModel ("planning.mpl")
planModel.WriteMpsFile ("planning.mps")
Writes out a solution file for the current model solution. (Method)
VisualBasic Example:
Dim planModel as Model
Set MPL = New OptiMax
MPL.Solvers.Add("CPLEX")
Set planModel = MPL.Models.Add "planning"
planModel.ReadModel("planning.mpl")
planModel.Solve
planModel.WriteSolutionFile("planning.sol")