The Variables Collection

The Variables collection is used to store a list of Variable objects.The parent can either be the Matrix object or the Solution object. These objects use the Variables collection to store a list of all the variables that are defined in the matrix or the solution.

Objects contained by the Variables Object

Count

The number of variables in the collection. (Integer Property - Read Only)

Item (Index)

Returns the selected Variable object from the collection. (Object Property)

Methods for the Variables Object

Add (Count)

Adds a new Variable object to the matrix. (Method)

Properties for the Variables Object

BinaryCount

The number of binary variables. (Integer Property - Read Only)

FreeCount

The number of free variables. (Integer Property - Read Only)

InitCount

The number of variables with nonzero initial value. (Integer Property - Read Only)

IntegerCount

The number of general integer variables. (Integer Property - Read Only)

LowerBoundCount

The number of variables with nonzero lower bound. (Integer Property - Read Only)

NonlinearCount

The number of variables that appear in nonlinear terms. (Integer Property - Read Only)

PriorityCount

The number of variables with defined priority values. (Integer Property - Read Only)

SosCount

The number of variables that are members of SOS sets. (Integer Property - Read Only)

UpperBoundCount

The number of variables with defined upper bound. (Integer Property - Read Only)

UsedCount

The number of variables that appear in at least one constraint or the objective. (Integer Property - Read Only)

Visual Bassic Example:


     Dim MPL As OptiMax
     Dim planModel As Model
     Dim planSol As Solution
     Dim planVar As Variables

     Set MPL = New OptiMax
     MPL.Solvers.Add ("c:\mplwin4\CPLEX65.dll")
     Set planModel = MPL.Models.Add("Planning.mpl")
     Set planSol = planModel.Solution
     Set planVars = planModel.Matrix.Variables

     MPL.WorkingDirectory = "c:\mplwin4"
     Result = planModel.ReadModel(planModel.Name)
     Result = planModel.Solve

     Debug.Print "Variable Count     = " & planVars.Count
     Debug.Print "Binary Count       = " & planVars.BinaryCount

     Debug.Print "Integer Count      = " & planVars.IntegerCount
     Debug.Print "Free Count         = " & planVars.IntegerCount
     Debug.Print "Nonlinear Count    = " & planVars.IntegerCount

        

Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page