org.drools.planner.core.score.buildin.hardandsoftlong
Class DefaultHardAndSoftLongScore

java.lang.Object
  extended by org.drools.planner.core.score.AbstractScore<HardAndSoftLongScore>
      extended by org.drools.planner.core.score.buildin.hardandsoftlong.DefaultHardAndSoftLongScore
All Implemented Interfaces:
Serializable, Comparable<HardAndSoftLongScore>, HardAndSoftLongScore, Score<HardAndSoftLongScore>

public final class DefaultHardAndSoftLongScore
extends AbstractScore<HardAndSoftLongScore>
implements HardAndSoftLongScore

Default implementation of HardAndSoftLongScore.

This class is immutable.

See Also:
HardAndSoftLongScore, Serialized Form

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

Constructor Detail

DefaultHardAndSoftLongScore

public DefaultHardAndSoftLongScore(long hardScore)

DefaultHardAndSoftLongScore

public DefaultHardAndSoftLongScore(long hardScore,
                                   long softScore)
Method Detail

parseScore

public static DefaultHardAndSoftLongScore parseScore(String scoreString)

valueOf

public static DefaultHardAndSoftLongScore valueOf(long hardScore)

valueOf

public static DefaultHardAndSoftLongScore valueOf(long hardScore,
                                                  long softScore)

getHardScore

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

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

getSoftScore

public long getSoftScore()
Description copied from interface: HardAndSoftLongScore
The total of the broken negative soft constraints and fulfilled positive soft constraints. Their weight is included in the total. The soft score is usually a negative number because most use cases only have negative constraints.

In a normal score comparison, the soft score is irrelevant if the 2 scores don't have the same hard score.

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

isFeasible

public boolean isFeasible()
Specified by:
isFeasible in interface HardAndSoftLongScore
Returns:
true if the HardAndSoftLongScore.getHardScore() is 0L or higher

add

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

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

subtract

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

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

multiply

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

divide

public HardAndSoftLongScore 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<HardAndSoftLongScore>
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<HardAndSoftLongScore>
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(HardAndSoftLongScore other)
Specified by:
compareTo in interface Comparable<HardAndSoftLongScore>

toString

public String toString()
Overrides:
toString in class Object


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