org.drools.planner.core.score.buildin.simple
Class DefaultSimpleScore

java.lang.Object
  extended by org.drools.planner.core.score.AbstractScore<SimpleScore>
      extended by org.drools.planner.core.score.buildin.simple.DefaultSimpleScore
All Implemented Interfaces:
Serializable, Comparable<SimpleScore>, SimpleScore, Score<SimpleScore>

public final class DefaultSimpleScore
extends AbstractScore<SimpleScore>
implements SimpleScore

Default implementation of SimpleScore.

This class is immutable.

See Also:
SimpleScore, Serialized Form

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

Constructor Detail

DefaultSimpleScore

public DefaultSimpleScore(int score)
Method Detail

parseScore

public static DefaultSimpleScore parseScore(String scoreString)

valueOf

public static DefaultSimpleScore valueOf(int score)

getScore

public int getScore()
Description copied from interface: SimpleScore
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 SimpleScore
Returns:
higher is better, usually negative, 0 if no constraints are broken/fulfilled

add

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

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

subtract

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

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

multiply

public SimpleScore 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<SimpleScore>
Parameters:
multiplicand - value to be multiplied by this Score.
Returns:
this * multiplicand

divide

public SimpleScore 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<SimpleScore>
Parameters:
divisor - value by which this Score is to be divided
Returns:
this / divisor

toDoubleLevels

public double[] toDoubleLevels()
Description copied from interface: Score
Returns an array of doubles representing the Score. Each double represents 1 score level. A greater score level uses a lower array index than a lesser score level.

When rounding is needed, each rounding should be floored (as defined by Math.floor(double). The length of the returned array must be stable for a specific Score implementation.

For example: -0hard/-7soft returns new double{-0.0, -7.0}

Specified by:
toDoubleLevels in interface Score<SimpleScore>
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(SimpleScore other)
Specified by:
compareTo in interface Comparable<SimpleScore>

toString

public String toString()
Overrides:
toString in class Object


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