org.drools.planner.core.score.buildin.simpledouble
Class DefaultSimpleDoubleScore

java.lang.Object
  extended by org.drools.planner.core.score.AbstractScore<SimpleDoubleScore>
      extended by org.drools.planner.core.score.buildin.simpledouble.DefaultSimpleDoubleScore
All Implemented Interfaces:
Serializable, Comparable<SimpleDoubleScore>, SimpleDoubleScore, Score<SimpleDoubleScore>

public final class DefaultSimpleDoubleScore
extends AbstractScore<SimpleDoubleScore>
implements SimpleDoubleScore

Default implementation of SimpleDoubleScore.

This class is immutable.

See Also:
SimpleDoubleScore, Serialized Form

Constructor Summary
DefaultSimpleDoubleScore(double score)
           
 
Method Summary
 SimpleDoubleScore add(SimpleDoubleScore augment)
          Returns a Score whose value is (this + augment).
 int compareTo(SimpleDoubleScore other)
           
 SimpleDoubleScore divide(double divisor)
          Returns a Score whose value is (this / divisor).
 boolean equals(Object o)
           
 double getScore()
          The total of the broken negative constraints and fulfilled postive hard constraints.
 int hashCode()
           
 SimpleDoubleScore multiply(double multiplicand)
          Returns a Score whose value is (this * multiplicand).
static DefaultSimpleDoubleScore parseScore(String scoreString)
           
 SimpleDoubleScore subtract(SimpleDoubleScore subtrahend)
          Returns a Score whose value is (this - subtrahend).
 double[] toDoubleArray()
          Returns an array of doubles representing the Score.
 String toString()
           
static DefaultSimpleDoubleScore valueOf(double score)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultSimpleDoubleScore

public DefaultSimpleDoubleScore(double score)
Method Detail

parseScore

public static DefaultSimpleDoubleScore parseScore(String scoreString)

valueOf

public static DefaultSimpleDoubleScore valueOf(double score)

getScore

public double getScore()
Description copied from interface: SimpleDoubleScore
The total of the broken negative constraints and fulfilled postive hard constraints. Their weight is included in the total. The score is usually a negative number because most use cases only have negative constraints.

Specified by:
getScore in interface SimpleDoubleScore
Returns:
higher is better, usually negative, 0 if no constraints are broken/fulfilled

add

public SimpleDoubleScore add(SimpleDoubleScore augment)
Description copied from interface: Score
Returns a Score whose value is (this + augment).

Specified by:
add in interface Score<SimpleDoubleScore>
Parameters:
augment - value to be added to this Score
Returns:
this + augment

subtract

public SimpleDoubleScore subtract(SimpleDoubleScore subtrahend)
Description copied from interface: Score
Returns a Score whose value is (this - subtrahend).

Specified by:
subtract in interface Score<SimpleDoubleScore>
Parameters:
subtrahend - value to be subtracted from this Score
Returns:
this - subtrahend, rounded as necessary

multiply

public SimpleDoubleScore multiply(double multiplicand)
Description copied from interface: Score
Returns a Score whose value is (this * multiplicand). When rounding is needed, it should be floored (as defined by Math.floor(double).

Specified by:
multiply in interface Score<SimpleDoubleScore>
Parameters:
multiplicand - value to be multiplied by this Score.
Returns:
this * multiplicand

divide

public SimpleDoubleScore divide(double divisor)
Description copied from interface: Score
Returns a Score whose value is (this / divisor). When rounding is needed, it should be floored (as defined by Math.floor(double).

Specified by:
divide in interface Score<SimpleDoubleScore>
Parameters:
divisor - value by which this Score is to be divided
Returns:
this / divisor

toDoubleArray

public double[] toDoubleArray()
Description copied from interface: Score
Returns an array of doubles representing the Score. When rounding is needed, each rounding should be floored (as defined by Math.floor(double).

A greater score level uses a lower array index than a lesser score level. The length of the returned array is stable for a specific Score implementation. For example: -0hard/-7soft returns new double{-0.0, -7.0}

Specified by:
toDoubleArray in interface Score<SimpleDoubleScore>
Returns:
never null

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(SimpleDoubleScore other)
Specified by:
compareTo in interface Comparable<SimpleDoubleScore>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2011 JBoss by Red Hat. All Rights Reserved.