scpsolver.problems
Class MathematicalProgram

java.lang.Object
  extended by scpsolver.problems.MathematicalProgram
Direct Known Subclasses:
LinearProgram, QuadraticProgram, StochasticProgram

public abstract class MathematicalProgram
extends java.lang.Object

Generalization of a mathematical optimization problem.

Author:
schober

Field Summary
protected  SparseVector c
          Vector of the coefficients of the linear target function
protected  java.util.ArrayList<Constraint> constraints
          The list of constraints for the given problem.
protected  boolean[] isboolean
           
protected  boolean[] isinteger
          Controls, which variable is a double or an integer/boolean.
protected  double[] lowerbound
          An array containing the lower bounds of the variables.
protected  boolean minproblem
          Indicates wether the linear program is a minimize or maximize problem.
protected  double[] upperbound
          An array containing the upper bounds of the variables.
 
Constructor Summary
MathematicalProgram()
          Creates an empty mathematical problem.
 
Method Summary
 double[] getC()
          Gets the coefficient vector for a linear target function.
 int getDimension()
          Returns the dimension of the mathematical problem, i.e. the number of free variables of the problem.
 boolean[] getIsboolean()
           
 boolean[] getIsinteger()
          Returns an array indicating integer variables and real variables.
 double[] getLowerbound()
          Returns the vector containing the lower bounds for all target variables.
 double[] getUpperbound()
          Returns the vector containing the upper bounds for all target variables.
 boolean hasBounds()
          Checks if lower or upper bounds are set for the target variables of this problem.
 boolean isMinProblem()
          Checks, whether the target function of this problem is to be minimized or maximized.
 boolean isMIP()
          Checks if this model represents a mixed integer problem or real problem.
static double[] makeDoubleArray(int l, double d)
          Creates an array of length l containing the value d at every position.
 void setC(Matrix pc)
          Sets the coefficients of the linear target function.
 void setContinous(int i)
          Marks a variable as real number.
 void setInteger(int i)
          Marks a variable as integer.
 void setIsinteger(boolean[] isinteger)
          Marks target variables to be integer, i.e. variables that must take integer values for valid solutions.
 void setLowerbound(double[] lowerbound)
          Sets the lower bounds off all target variables.
 void setMinProblem(boolean bool)
          Determines if the target function of this problem is to be minimized or maximized.
 void setUpperbound(double[] upperbound)
          Sets the upper bounds off all target variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c

protected SparseVector c
Vector of the coefficients of the linear target function


constraints

protected java.util.ArrayList<Constraint> constraints
The list of constraints for the given problem.


isinteger

protected boolean[] isinteger
Controls, which variable is a double or an integer/boolean. Note: if a variable is boolean, then it's only marked integer and special boolean constraints are added.


isboolean

protected boolean[] isboolean

minproblem

protected boolean minproblem
Indicates wether the linear program is a minimize or maximize problem.


upperbound

protected double[] upperbound
An array containing the upper bounds of the variables. If no upper bound is set, then Double.MAX_VALUE is used.


lowerbound

protected double[] lowerbound
An array containing the lower bounds of the variables. If no lower bound is set, then Double.MIN_VALUE is used.

Constructor Detail

MathematicalProgram

public MathematicalProgram()
Creates an empty mathematical problem.

Method Detail

setInteger

public void setInteger(int i)
Marks a variable as integer.

Parameters:
i - The index of the variable

setContinous

public void setContinous(int i)
Marks a variable as real number.

Parameters:
i - The index of the variable.

getC

public double[] getC()
Gets the coefficient vector for a linear target function.

Returns:
c the coefficients of the target function

setC

public void setC(Matrix pc)
Sets the coefficients of the linear target function.

Parameters:
c - the c to set

getDimension

public int getDimension()
Returns the dimension of the mathematical problem, i.e. the number of free variables of the problem.

Returns:
the number of target variables

isMIP

public boolean isMIP()
Checks if this model represents a mixed integer problem or real problem. A mixed integer problem is mathematical problem, in which at least one variable may only take integer values.

Returns:
true, if at least one variable has to be an integer, otherwise false

isMinProblem

public boolean isMinProblem()
Checks, whether the target function of this problem is to be minimized or maximized.

Returns:
true, if the target function is to be minimized, otherwise false

setMinProblem

public void setMinProblem(boolean bool)
Determines if the target function of this problem is to be minimized or maximized.

Parameters:
bool - true, if the target function is to be minimized, otherwise false

hasBounds

public boolean hasBounds()
Checks if lower or upper bounds are set for the target variables of this problem.

Returns:
true, if any of the lower or upper bounds are set, otherwies false

getLowerbound

public double[] getLowerbound()
Returns the vector containing the lower bounds for all target variables.

Returns:
the lower bounds of the target variables

setLowerbound

public void setLowerbound(double[] lowerbound)
Sets the lower bounds off all target variables. The length of the parameter array must be equal to the result of getDimension. Note also, that this sets the lower bound for all target variables at once. If no lower bound for a given variable is desired, then the array should contain the value Double.MIN_VALUE at this postion.

Parameters:
lowerbound - an array containing the lower bounds of all free variables

getUpperbound

public double[] getUpperbound()
Returns the vector containing the upper bounds for all target variables.

Returns:
the lower bounds of the target variables

makeDoubleArray

public static double[] makeDoubleArray(int l,
                                       double d)
Creates an array of length l containing the value d at every position.

Parameters:
l - the length of the desired array
d - the value at every position of the array
Returns:
an array of length l containing all d values

setUpperbound

public void setUpperbound(double[] upperbound)
Sets the upper bounds off all target variables. The length of the parameter array must be equal to the result of getDimension. Note also, that this sets the upper bound for all target variables at once. If no upper bound for a given variable is desired, then the array should contain the value Double.MAX_VALUE at this postion.

Parameters:
upperbound - an array containing the upper bounds of all free variables

setIsinteger

public void setIsinteger(boolean[] isinteger)
Marks target variables to be integer, i.e. variables that must take integer values for valid solutions. All variables are set at one method call. Variables that are required to take integer values only for solutions should be marked true, whereas positions of variables which may also take real values in possible solutions are to be marked false.

Parameters:
isinteger - an array of the length equal to the dimension with values indicating which variables shall take integer values and which can take real values

getIsinteger

public boolean[] getIsinteger()
Returns an array indicating integer variables and real variables. Positions of integer variables are marked true, positions of real variables are marked false.

Returns:
an array containing indicators, which variables ought to be integer and which may take real values

getIsboolean

public boolean[] getIsboolean()