org.ojalgo.optimisation
Class VariablesBasedModel

java.lang.Object
  extended by org.ojalgo.optimisation.VariablesBasedModel
All Implemented Interfaces:
OptimisationModel
Direct Known Subclasses:
KnapsackModel, QuadraticModel

public abstract class VariablesBasedModel
extends Object

Basic instructions:

  1. Define (create) a set of variables. Each variable may have a lower as well as an upper limit and a cost associated with it.
  2. Create a model using that set of variables.
  3. Add expressions to the model. The model is the expression factory. Each expression can act as both a constraint and as a part of the objective.
  4. Instanciate a solver using the model.
  5. Solve!

Author:
apete

Constructor Summary
VariablesBasedModel(Set<? extends Variable> someVariables)
           
VariablesBasedModel(Variable[] someVariables)
           
 
Method Summary
 CompoundFunction<BigDecimal> extractObjective()
           
 int getComplexity()
           
abstract  OptimisationSolver getDefaultSolver()
          No need to implement an OptimisationModel if there is not at least one matching OptimisationSolver.
 int getDim()
           
 Expression getExpression(int anIndex)
           
 Expression[] getExpressions()
           
 BigDecimal getValue()
           
 Variable getVariable(int anIndex)
           
 Variable[] getVariables()
           
 boolean isMaximisation()
           
 boolean isMinimisation()
           
 void setMaximisation(boolean aFlag)
          Marks the model to be a maximisation problem, or not.
 void setMinimisation(boolean aFlag)
          Marks the model to be a minimisation problem, or not.
 String toString()
           
abstract  boolean validate()
          GenericModel is meant to be extended in parallel with GenericSolver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ojalgo.optimisation.OptimisationModel
maximise, minimise
 

Constructor Detail

VariablesBasedModel

public VariablesBasedModel(Set<? extends Variable> someVariables)

VariablesBasedModel

public VariablesBasedModel(Variable[] someVariables)
Method Detail

extractObjective

public CompoundFunction<BigDecimal> extractObjective()

getComplexity

public int getComplexity()

getDefaultSolver

public abstract OptimisationSolver getDefaultSolver()
Description copied from interface: OptimisationModel
No need to implement an OptimisationModel if there is not at least one matching OptimisationSolver.


getDim

public int getDim()

getExpression

public Expression getExpression(int anIndex)

getExpressions

public Expression[] getExpressions()

getValue

public final BigDecimal getValue()
Returns:
The current objective function value

getVariable

public Variable getVariable(int anIndex)

getVariables

public Variable[] getVariables()

toString

public final String toString()
Overrides:
toString in class Object

validate

public abstract boolean validate()
                          throws RecoverableCondition
GenericModel is meant to be extended in parallel with GenericSolver. This method ensures that the model is built in a way the solver can handle.
If the solver can handle a 'relaxed' version of the model this method may return false instead of throwing a RecoverableCondition. A typical case when this method should return false is if variables are declared as integer, but the solver cannot handle this (it simply disregards that constraint).

Returns:
True if the corresponding solver can solve the problem specified by the model without errors or omissions - otherwise false.
Throws:
RecoverableCondition - If the model can be fixed during program execution (perhaps by removing a constraint).
ProgrammingError - If the solver cannot deal with the model.

isMaximisation

public final boolean isMaximisation()
Specified by:
isMaximisation in interface OptimisationModel
Returns:
true if this model is a maximisation problem, and false if it's a minimisation problem

isMinimisation

public final boolean isMinimisation()
Specified by:
isMinimisation in interface OptimisationModel
Returns:
true if this model is a minimisation problem, and false if it's a maximisation problem

setMaximisation

public final void setMaximisation(boolean aFlag)
Description copied from interface: OptimisationModel
Marks the model to be a maximisation problem, or not. Minimisation is the default.

Specified by:
setMaximisation in interface OptimisationModel

setMinimisation

public final void setMinimisation(boolean aFlag)
Description copied from interface: OptimisationModel
Marks the model to be a minimisation problem, or not. Minimisation is the default.

Specified by:
setMinimisation in interface OptimisationModel