The Variable Object

The Variable object is an element of the Variables collection and contains all the information stored about each individual variable in the model.

Properties for the Variable Object

Activity

The activity for the variable from the solution. (Double Property - Read/Write)

InitValue

The initial value for the variable. (Double Property - Read/Write)

IsBinary

Specifies if the variable is a binary variable. (Boolean Property - Read/Write)

IsFree

Specifies if the variable is a free variable. (Boolean Property - Read/Write)

IsInteger

Specifies if the variable is an integer variable. (Boolean Property - Read/Write)

IsNonlinear

Specifies if the variable is used in a nonlinear term. (Boolean Property - Read/Write)

IsSemiCont

Specifies if the variable is a semi-continuous variable. (Boolean Property - Read/Write)

IsSOS

Specifies if the variable is a member of a SOS set. (Boolean Property - Read/Write)

IsUsed

Specifies if the variable is used in at least one of the constraints or the objective function. (Boolean Property - Read/Write)

LowerBound

The lower bound for the variable. (Double Property - Read/Write)

Name

The name of the variable. (String Property - Read/Write)

ObjectCoeff

The objective coefficient for the variable. (Double Property - Read/Write)

ObjectLowerRange

The lower range for the objective function coefficient in the solution. (Double Property - Read Only)

ObjectUpperRange

The upper range for the objective function coefficient in the solution. (Double Property - Read Only)

PriorityValue

The priority value for the variable. (Integer Property - Read/Write)

ReducedCost

The reduced cost for the variable from the solution. (Double Property - Read Only)

SolverColNr

The column number for the variable in the solver solution. (Integer Property - Read Only)

StageNr

The stochastic stage number for the variable. (Integer Property - Read only)

Type

The variable type from the VariableType enumeration. (Enum Property - Read/Write) Possible values are: Binary Continuous Integer Free

UpperBound

The upper bound for the variable. (Double Property - Read/Write)

VarNr

The variable number in the matrix for the variable. (Integer Property - Read/Write)

CSharp Example:


     OptiMax MPL;
     Solver cpxSolver;
     Model planModel;
     Variables planVars;
     ResultType result;

     MPL = new OptiMax();

     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;
     result = planModel.Solve();

     foreach(Variable vars in planVars)
        Console.WriteLine(vars.VarNr + ":" + vars.Name + ":" +
                          vars.Activity + ":" + vars.ReducedCost);

        

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