scpsolver.qpsolver
Class QuadraticProgram

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

public class QuadraticProgram
extends MathematicalProgram
implements ConstrainedProblem

Author:
planatsc

Field Summary
 
Fields inherited from class scpsolver.problems.MathematicalProgram
c, constraints, isboolean, isinteger, lowerbound, minproblem, upperbound
 
Constructor Summary
QuadraticProgram(double[][] q)
           
QuadraticProgram(double[][] q, double[] pc)
           
QuadraticProgram(Matrix q, SparseVector c)
           
 
Method Summary
 boolean addConstraint(Constraint 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.
 int getDimension()
          Returns the dimension of the mathematical problem, i.e. the number of free variables of the problem.
 java.lang.String getName()
          Gets a string containing the type of problem that is formulated with a given instance.
 Matrix getQ()
           
 java.util.ArrayList<Constraint> getViolatedContraints(double[] x)
           
 boolean isFeasable(double[] x)
          Determines whether all constrains are fulfilled at input value x.
 boolean isMinProblem()
          Checks, whether the target function of this problem is to be minimized or maximized.
static void main(java.lang.String[] args)
           
 void setMinProblem(boolean bool)
          Determines if the target function of this problem is to be minimized or maximized.
 void setQ(double[][] q)
           
 void setQ(Matrix q)
           
 
Methods inherited from class scpsolver.problems.MathematicalProgram
getC, getIsboolean, getIsinteger, getLowerbound, getUpperbound, hasBounds, isMIP, makeDoubleArray, setC, setContinous, setInteger, setIsinteger, setLowerbound, setUpperbound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadraticProgram

public QuadraticProgram(Matrix q,
                        SparseVector c)

QuadraticProgram

public QuadraticProgram(double[][] q,
                        double[] pc)

QuadraticProgram

public QuadraticProgram(double[][] q)
Method Detail

getQ

public Matrix getQ()

setQ

public void setQ(Matrix q)

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

setQ

public void setQ(double[][] q)

addConstraint

public boolean addConstraint(Constraint c)

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

getViolatedContraints

public java.util.ArrayList<Constraint> getViolatedContraints(double[] x)

getDimension

public int getDimension()
Description copied from class: MathematicalProgram
Returns the dimension of the mathematical problem, i.e. the number of free variables of the problem.

Specified by:
getDimension in interface Problem
Overrides:
getDimension in class MathematicalProgram
Returns:
the number of target variables

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:

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

isMinProblem

public boolean isMinProblem()
Description copied from class: MathematicalProgram
Checks, whether the target function of this problem is to be minimized or maximized.

Specified by:
isMinProblem in interface Problem
Overrides:
isMinProblem in class MathematicalProgram
Returns:
true, if the target function is to be minimized, otherwise false

setMinProblem

public void setMinProblem(boolean bool)
Description copied from class: MathematicalProgram
Determines if the target function of this problem is to be minimized or maximized.

Specified by:
setMinProblem in interface Problem
Overrides:
setMinProblem in class MathematicalProgram
Parameters:
bool - true, if the target function is to be minimized, otherwise false

main

public static void main(java.lang.String[] args)