Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

simplex_clp.c File Reference

Implementation of the functions operating on TSimplex using the Clp backend. More...

#include "simplex.h"
#include "error.h"
#include "geom.h"
#include "defines.h"
#include <float.h>
#include <math.h>
#include <string.h>

Go to the source code of this file.

Functions

void SimplexCreate (double epsilon, unsigned int ncols, TSimplex *s)
 Constructor.
void ResetSimplex (TSimplex *s)
 Resets the simplex structure.
unsigned int SimplexNColumns (TSimplex *s)
 Gets the number of columns (i.e., variables) of the simplex structure.
unsigned int SimplexNRows (TSimplex *s)
 Gets the number of rows (i.e., constraints) of the simplex structure.
void SimplexSetColBounds (unsigned int ncol, Tinterval *i, TSimplex *s)
 Sets the bounds for a given column (i.e., variable).
void SimplexGetColBounds (unsigned int ncol, Tinterval *i, TSimplex *s)
 Gets the bounds for a given column (i.e., variable).
void SimplexGetColConstraint (unsigned int ncol, TLinearConstraint *lc, TSimplex *s)
 Gets a column from the simplex in the form of a linear constraint.
boolean SimplexColEmpty (unsigned int ncol, TSimplex *s)
 Checks if a simplex column is empty.
double SimplexGetColPrimal (unsigned int ncol, TSimplex *s)
 Gets a column primal value after solving the simplex.
double SimplexGetColDual (unsigned int ncol, TSimplex *s)
 Gets a column dual value after solving the simplex.
void SimplexSetRowBounds (unsigned int nrow, Tinterval *i, TSimplex *s)
 Sets the bounds for a given row (i.e., constraint).
void SimplexGetRowBounds (unsigned int nrow, Tinterval *i, TSimplex *s)
 Gets the bounds for a given row (i.e., constraint).
void SimplexGetRowConstraint (unsigned int nrow, TLinearConstraint *lc, TSimplex *s)
 Gets a row constraint from the simplex.
double SimplexGetRowPrimal (unsigned int nrow, TSimplex *s)
 Gets a row primal value after solving the simplex.
double SimplexGetRowDual (unsigned int nrow, TSimplex *s)
 Gets a row dual value after solving the simplex.
void SimplexAddNewConstraintRaw (TLinearConstraint *lc, TSimplex *s)
 Adds a row (i.e., a constraint) to the simplex.
void SimplexSetOptimizationFunction (TLinearConstraint *obj, TSimplex *s)
 Sets a new objective function.
void SimplexGetOptimizationFunction (TLinearConstraint *obj, TSimplex *s)
 Gets a current objective function.
double SimplexGetOptimalValueRaw (TSimplex *s)
 Gets the optimal value after optimizing the problem.
unsigned int SimplexSolve (TSimplex *s)
 Determines an optimal value.
void SimplexDelete (TSimplex *s)
 Destructor.

Detailed Description

Implementation of the functions operating on TSimplex using the Clp backend.

See also:
TSimplex, simplex.h, simplex_glpk.c, simplex_lpsolve.c.

Definition in file simplex_clp.c.


Function Documentation

void SimplexCreate ( double  epsilon,
unsigned int  ncols,
TSimplex s 
)

Creates a simplex structure with a given number of columns (i.e., variables) but with no rows (i.e., constraints).

Parameters:
epsilon Threshold to decide if a value is too small to be added to the tableau. It is also used to set up internal simplex parameters.
ncols Number of columns for the tableau.
s The simplex structure.

Definition at line 22 of file simplex_clp.c.

References TSimplex::fakeRows, INF, TSimplex::lower, TSimplex::lp, NEW, TSimplex::obj, SIMPLEX_TIMEOUT, and TSimplex::upper.

void ResetSimplex ( TSimplex s  ) 

Removes the rows (i.e., constraints) from the simplex structure.

Parameters:
s The simplex structure.

Definition at line 96 of file simplex_clp.c.

unsigned int SimplexNColumns ( TSimplex s  ) 

Gets the number of columns (i.e., variables) of the simplex structure.

Parameters:
s The simplex structure.
Returns:
The number of columns (i.e., variables) of the simplex structure.

Definition at line 102 of file simplex_clp.c.

References TSimplex::lp.

unsigned int SimplexNRows ( TSimplex s  ) 

Gets the number of rows (i.e., constraints) of the simplex structure.

Parameters:
s The simplex structure.
Returns:
The number of rows (i.e., constraints) of the simplex structure.

Definition at line 107 of file simplex_clp.c.

References TSimplex::fakeRows, and TSimplex::lp.

void SimplexSetColBounds ( unsigned int  ncol,
Tinterval i,
TSimplex s 
)

Sets the bounds for a given column (i.e., variable).

Parameters:
ncol The column whose range we have to update.
i The new range for the column.
s The simplex structure.

Definition at line 113 of file simplex_clp.c.

References TSimplex::lower, LowerLimit(), TSimplex::lp, TSimplex::upper, and UpperLimit().

Here is the call graph for this function:

void SimplexGetColBounds ( unsigned int  ncol,
Tinterval i,
TSimplex s 
)

Gets the bounds for a given column (i.e., variable).

Parameters:
ncol The column whose range we have to update.
i The output range with the column bounds.
s The simplex structure.

Definition at line 123 of file simplex_clp.c.

References TSimplex::lp, and NewInterval().

Here is the call graph for this function:

void SimplexGetColConstraint ( unsigned int  ncol,
TLinearConstraint lc,
TSimplex s 
)

Gets a column from the simplex in the form of a linear constraint.

Parameters:
ncol The column whose constraint we want to get.
lc The output linear constraint.
s The simplex structure.

Definition at line 133 of file simplex_clp.c.

References AddTerm2LinearConstraint(), InitLinearConstraint(), TSimplex::lp, SetLinearConstraintError(), and SimplexGetColBounds().

Here is the call graph for this function:

boolean SimplexColEmpty ( unsigned int  ncol,
TSimplex s 
)

Gets a column constraint from the simplex.

Parameters:
ncol The column whose constraint we want to get.
s The simplex structure.
Returns:
TRUE if the simplex column is empty.

Definition at line 159 of file simplex_clp.c.

References TSimplex::lp.

double SimplexGetColPrimal ( unsigned int  ncol,
TSimplex s 
)

Gets a column primal value after solving the simplex.

Parameters:
ncol The column whose primal value we need.
s The simplex structure.
Returns:
The primal value for the column.

Definition at line 168 of file simplex_clp.c.

References TSimplex::lp.

double SimplexGetColDual ( unsigned int  ncol,
TSimplex s 
)

Gets a column dual value after solving the simplex.

Parameters:
ncol The column whose dual value we need.
s The simplex structure.
Returns:
The primal value for the column.

Definition at line 177 of file simplex_clp.c.

References TSimplex::lp.

void SimplexSetRowBounds ( unsigned int  nrow,
Tinterval i,
TSimplex s 
)

Sets the bounds for a given row (i.e., constraint).

Parameters:
nrow The column whose range we have to update.
i The new range for the row.
s The simplex structure.

Definition at line 187 of file simplex_clp.c.

References Error(), TSimplex::fakeRows, LowerLimit(), TSimplex::lp, and UpperLimit().

Here is the call graph for this function:

void SimplexGetRowBounds ( unsigned int  nrow,
Tinterval i,
TSimplex s 
)

Gets the bounds for a given row (i.e., constraint).

Parameters:
nrow The column whose range we have to update.
i The output range with the column bounds.
s The simplex structure.

Definition at line 203 of file simplex_clp.c.

References TSimplex::fakeRows, TSimplex::lp, and NewInterval().

Here is the call graph for this function:

void SimplexGetRowConstraint ( unsigned int  nrow,
TLinearConstraint lc,
TSimplex s 
)

Gets a row constraint from the simplex.

Parameters:
nrow The row whose constraint we want to get.
lc The output linear constraint.
s The simplex structure.

Definition at line 213 of file simplex_clp.c.

References AddTerm2LinearConstraint(), TSimplex::fakeRows, InitLinearConstraint(), TSimplex::lp, SetLinearConstraintError(), SimplexGetRowBounds(), and SimplexNColumns().

Here is the call graph for this function:

double SimplexGetRowPrimal ( unsigned int  nrow,
TSimplex s 
)

Gets a row primal value after solving the simplex.

Parameters:
nrow The row whose primal value we need.
s The simplex structure.
Returns:
The primal value for the row.

Definition at line 251 of file simplex_clp.c.

References TSimplex::fakeRows, and TSimplex::lp.

double SimplexGetRowDual ( unsigned int  nrow,
TSimplex s 
)

Gets a row dual value after solving the simplex.

Parameters:
nrow The row whose dual value we need.
s The simplex structure.
Returns:
The dual value for the row.

Definition at line 260 of file simplex_clp.c.

References TSimplex::fakeRows, and TSimplex::lp.

void SimplexAddNewConstraintRaw ( TLinearConstraint lc,
TSimplex s 
)

Adds a row (i.e., a constraint) to the simplex. This function adds the row without any process of the constraint.

The input linear constraint must have the bound properly expanded (see SimplexExpandBounds) before using this function.

Parameters:
lc The linear constraint to add to the simplex.
s The simplex structure.
See also:
SimplexAddNewConstraint

Definition at line 269 of file simplex_clp.c.

References GetLinearConstraintCoefficients(), GetLinearConstraintError(), GetLinearConstraintVariables(), GetNumTermsInLinearConstraint(), LowerLimit(), TSimplex::lp, PrintInterval(), PrintLinearConstraint(), SimplexNRows(), TRUE, and UpperLimit().

Here is the call graph for this function:

void SimplexSetOptimizationFunction ( TLinearConstraint obj,
TSimplex s 
)

Sets a new objective function. We always minimize the objective functions. To maximize just invert the linear constraint before setting it as an optimal function.

Parameters:
obj The linear constraint representing the new objective function.
s The simplex structure.
See also:
SimplexAddNewConstraint, InvertLinearConstraint.

Definition at line 296 of file simplex_clp.c.

References GetLinearConstraintCoefficient(), GetLinearConstraintVariable(), GetNumTermsInLinearConstraint(), TSimplex::lp, TSimplex::obj, and SimplexNColumns().

Here is the call graph for this function:

void SimplexGetOptimizationFunction ( TLinearConstraint obj,
TSimplex s 
)

Gets the current objective function.

Parameters:
obj The output linear constraint with the current objective function.
s The simplex structure.

Definition at line 322 of file simplex_clp.c.

References AddTerm2LinearConstraint(), InitLinearConstraint(), TSimplex::lp, and SimplexNColumns().

Here is the call graph for this function:

double SimplexGetOptimalValueRaw ( TSimplex s  ) 

Gets the optimal value after optimizing the problem. This function returns the value as given by the simplex engine in use. See SimplexGetOptimalValue for a procedure that adjusts this raw value to get a numerically safe optimal (i.e., it compensates for floating points rounding errors).

Parameters:
s The simplex structure.
Returns:
The optimal value.
See also:
SimplexGetOptimalValue

Definition at line 337 of file simplex_clp.c.

References TSimplex::lp.

unsigned int SimplexSolve ( TSimplex s  ) 

Determines an optimal value given a set of constraints and an objective function.

Parameters:
s The simplex structure.
Returns:
The state after solving: REDUCED_BOX, EMPTY_BOX, UNBOUNDED_BOX, ERROR_IN_PROCESS.

Definition at line 342 of file simplex_clp.c.

References EMPTY_BOX, ERROR_IN_PROCESS, TSimplex::fakeRows, TSimplex::lp, REDUCED_BOX, and UNBOUNDED_BOX.

void SimplexDelete ( TSimplex s  ) 

Deletes the TSimplex structure and frees the allocated memory.

Parameters:
s The simplex structure.

Definition at line 377 of file simplex_clp.c.

References TSimplex::lower, TSimplex::lp, TSimplex::obj, SimplexNRows(), and TSimplex::upper.

Here is the call graph for this function: