Huge Collections of Software Manuals and Knowledgebase

GreatManuals.com
Huge Collections of Software Manuals and Knowledgebase

 
Home Contact Us Request to publish your help manuals Request to remove your help manuals
Introduction
» Linear Programming Library Gipals32
Library Interface
» Library Interface
» Specifying & Updating Variables
» Specifying & Updating Constraints
» Importing LP from MPS file
» Calculating
» Getting Calculation Results
» Calculation Settings
 

Specifying & Updating Variables

Gipals32 provides several routines to manipulate with decision variables.

int AddVariable(double Cost, // Objective function coefficient
double Lower, // Lower bound of variable (ignored if LowerInf <> 0)
double Upper, // Upper bound of variable (ignored if UpperInf <> 0) int LowerInf, // If <> 0 then indicates variable has no lower bound int UpperInf);// If <> 0 then indicates variable has no upper bound
)

This function creates a new variable in the LP and sets cost and bounds for this variable. The function returns the variable’s index if succeeded and -1 if the maximum size (5,000) has been reached. The function can be used to create a new variable only up to 5,000 variables because behind this size the performance is dramatically slows down. For the LP with more than 5,000 variables the procedure SetVariableCount should be used.

DeleteVariable(int Index)
This procedure deletes the specified variable from LP.

int GetVariableCount()
The function returns the number of the variables that have been specified in the LP.

int SetVariable(int Index, // Variable index
double Cost, // Objective function coefficient
double Lower, // Lower bound of variable (ignored if LowerInf <> 0) double Upper, // Upper bound of variable (ignored if UpperInf <> 0) int LowerInf, // If <> 0 then indicates variable has no lower bound int UpperInf // If <> 0 then indicates variable has no upper bound
)

flash card data recovery drive recovery data recovery usb
digital photo restore digital camera repair compact flash recovery
data recovery download best data recovery bulk sms

The function setups the parameters of the existing variable Index. If the variable doesn’t exist then returns 0.

Example 1. Creating new variables using AddVariable function:

  1. Define a new variable that has cost (objective function coefficient) of 5 and can be any positive number without upper bound. Such variable is called “normal variable”.
    AddVariable(5, 0, 0, 0, 1);
  2. b) Define a new variable that has cost of -5 and can be any positive number not more than 1000. In this case the upper bound is specified (1000) and the indication the variable has the upper bound is set (0).
    AddVariable(5, 0, 1000, 0, 0);
  3. Define a new variable that has cost of 2.5 and doesn’t have any bounds, it’s called “free variable”. In this case the indications the variable has not lower (1) and upper bounds is set (1).
    AddVariable(2.5, 0, 0, 1, 1);
  4. Define a new variable that has cost of 1 and should be any number in between 10 and 150.
    AddVariable(1, 10, 150, 0, 0);
  5. Define a new variable that has cost of 3 and should have only one value 20. This variable is called “fixed variable” and defined be setting lower and upper bound to the same value.
    AddVariable(1, 20, 20, 0, 0);

Example 2. Creating new variables using pair of SetVariableCount and SetVariable functions. This is the only way to specify linear programs with more than 5,000 variables.

Create 10,000 variables at once:
SetVariableCount(10000);

Setup properties for first five variables from the previous example. The first parameter indicates the index (in bold) of the variable and the rest of parameters are the same as for AddVariable function:

SetVariable(0, 5, 0, 0, 0, 1); SetVariable(1, 5, 0, 1000, 0, 0); SetVariable(2, 2.5, 0, 0, 1, 1); SetVariable(3, 1, 10, 150, 0, 0); SetVariable(4, 1, 20, 20, 0, 0);

Function SetVariable also can be used to change some properties of the variable for the existing LP after the calculation was done. Let say to change the cost of the third variable (Index = 2) from existing value of 2.5 to -4.1 one should call:

SetVariable(2, -4.1, 0, 0, 1, 1);

Home | Contact Us | Request to publish your help manuals | Request to remove your help manuals