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

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)

Locate (Name)

Locates a specific variable name, returns the variable number. (Method)

Properties for the Variables Object

BinaryCount

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

Count

The number of variables in the collection. (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)

SemiContCount

The number of variables that are semi-continuous. (Integer Property - Read Only)

SosCount

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

StageCount

The number of variables with defined stochastic stages. (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.

CSharp Example:


     OptiMax MPL;
     Model planModel;
     Variables planVars;

     cpxSolver = MPL.Solvers.Add("CPLEX");
     planModel = MPL.Models.Add("Planning");

     string WorkingDirectory = "c:\\mplwin4";
     string modFilePath = WorkingDirectory + "\\" + "Planning.mpl";

     result = planModel.ReadModel(modFilePath);
     planVars = planModel.Matrix.Variables;

     Console.WriteLine("Variable Count  = {0}", planVars.Count);
     Console.WriteLine("Binary Count    = {0}", planVars.BinaryCount);

     Console.WriteLine("Integer Count   = {0}", planVars.IntegerCount);
     Console.WriteLine("Free Count      = {0}", planVars.FreeCount);
     Console.WriteLine("Nonlinear Count = {0}", planVars.NonlinearCount);

        

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