scpsolver.problems
Class StochasticProgram

java.lang.Object
  extended by scpsolver.problems.MathematicalProgram
      extended by scpsolver.problems.StochasticProgram
All Implemented Interfaces:
ConstrainedProblem, Problem

public class StochasticProgram
extends MathematicalProgram
implements ConstrainedProblem

This class represents a stochastic program, that is, a linear program that additionally includes different scenarios with given probabilities. This implementation assumes that the variables can be split into disjoint sets: a deterministic set of variables, which are not influenced by scenarios of certain probabilities (i.e. variables, which have the same values in all scenarios), and another set of variables which weights are not pre-determined. The theory of stochastic programming shows that the optimal solution of a stochastic optimization problem is not merely a weighted average of the underlying linear optimization problems, and is therefore entitled a representation of its own. On the other hand, a stochastic optimization problem can be transformed into a linear one. Although there are additional algorithms, which exploit the specific problem structure of stochastic optimization problems, the SCPSolver-suite does not take them into account yet. However, this class and the corresponding constraint classes help to easily formulate a stochastic problem and transform it automatically into its linear representation.

Author:
schober

Field Summary
 
Fields inherited from class scpsolver.problems.MathematicalProgram
c, constraints, isboolean, isinteger, lowerbound, minproblem, upperbound
 
Constructor Summary
StochasticProgram(double[] pc, double[] probs, double[][] scens)
          Creates a new stochastic problem with given deterministic weights, probabilities of different scenarios and variable weights in these scenarios.
StochasticProgram(SparseVector c, double[] probs, SparseVector[] scens)
           
 
Method Summary
 boolean addConstraint(LinearConstraint c)
           
 boolean addConstraint(StochasticConstraint c)
           
 double evaluate(double[] x)
          Returns the value of the function at position x.
 java.util.ArrayList<Constraint> getConstraints()
          Returns a list of all constrains a valid solution must keep.
 LinearProgram getExtensiveForm()
           
 java.lang.String getName()
          Gets a string containing the type of problem that is formulated with a given instance.
 boolean isFeasable(double[] x)
          Determines whether all constrains are fulfilled at input value x.
 void setLowerbound(double[] bounds)
          Sets the lower bounds off all target variables.
 void setUpperbound(double[] bounds)
          Sets the upper bounds off all target variables.
 
Methods inherited from class scpsolver.problems.MathematicalProgram
getC, getDimension, getIsboolean, getIsinteger, getLowerbound, getUpperbound, hasBounds, isMinProblem, isMIP, makeDoubleArray, setC, setContinous, setInteger, setIsinteger, setMinProblem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface scpsolver.problems.Problem
getDimension, isMinProblem, setMinProblem
 

Constructor Detail

StochasticProgram

public StochasticProgram(double[] pc,
                         double[] probs,
                         double[][] scens)
Creates a new stochastic problem with given deterministic weights, probabilities of different scenarios and variable weights in these scenarios.

Parameters:
pc - variable weights for the deterministic variables
probs - probabilites of the different scenarios
scens - variable weights for the non-deterministic variables

StochasticProgram

public StochasticProgram(SparseVector c,
                         double[] probs,
                         SparseVector[] scens)
Method Detail

addConstraint

public boolean addConstraint(LinearConstraint c)

addConstraint

public boolean addConstraint(StochasticConstraint c)

getConstraints

public java.util.ArrayList<Constraint> getConstraints()
Description copied from interface: ConstrainedProblem
Returns a list of all constrains a valid solution must keep.

Specified by:
getConstraints in interface ConstrainedProblem
Returns:
the constrains a valid solution must keep

setUpperbound

public void setUpperbound(double[] bounds)
Description copied from class: MathematicalProgram
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.

Overrides:
setUpperbound in class MathematicalProgram
Parameters:
bounds - an array containing the upper bounds of all free variables

setLowerbound

public void setLowerbound(double[] bounds)
Description copied from class: MathematicalProgram
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.

Overrides:
setLowerbound in class MathematicalProgram
Parameters:
bounds - an array containing the lower bounds of all free variables

isFeasable

public boolean isFeasable(double[] x)
Description copied from interface: ConstrainedProblem
Determines whether all constrains are fulfilled at input value x. isFeasable will iterate over all constrains of an optimization problem and check if all of them hold. isFeasable will then return true, otherwise it will return false.

The length of the array must be the same as the value returned by getDimension.

Specified by:
isFeasable in interface ConstrainedProblem
Parameters:
x - input variable vector
Returns:
true if all constrains hold, false otherwise

evaluate

public double evaluate(double[] x)
Description copied from interface: Problem
Returns the value of the function at position x. The length of the array must be the same as the value returned by getDimension.

Specified by:
evaluate in interface Problem
Parameters:
x - input variable vector for the target function
Returns:
the value of the function at position x

getName

public java.lang.String getName()
Description copied from interface: Problem
Gets a string containing the type of problem that is formulated with a given instance. E. g., the LinearProgram class returns "Linear Program".

Please note, that this method will not return the actual name of a given instance. If you have two instances of linear programs, a method call will yield the same result. Therefore, two different linear programs cannot be distinguish via this method and must be kept apart somehow differently.

Specified by:
getName in interface Problem
Returns:
the type of problem this instance describes

getExtensiveForm

public LinearProgram getExtensiveForm()