dk.deepthought.sidious.rules
Class Rule

java.lang.Object
  extended by dk.deepthought.sidious.rules.Rule
Direct Known Subclasses:
ConstrainingRule, HeatExpensesRule, MorningDropRule, PhotosynthesisRule, TemperatureRule

public abstract class Rule
extends java.lang.Object

This is the base class for representing a Rule. It is designed to be extended by classes defining rules of the system.

Rules can be goal-oriented and work towards a specific goal. They can also represent a conflict or an expense.

Author:
Deepthought

Field Summary
private  SuperLinkID parentID
          The ID of the originating PlanRequester.
 
Constructor Summary
Rule()
           
 
Method Summary
abstract  double desire(State currentState, State newState, Step step)
          Method returns the calculated desire associated with the change from currentState to newState.
protected  double getAdjustableSetting(Step step, SuperLinkID id)
          Returns the setting of an adjustable contained in the step identified by the id.
protected  double getAdjustableSettingFromParent(SuperLinkID adjustableID)
          Method returns the setting of the input adjustable.
 java.lang.String getExplanation()
          Gets the explanation/reasoning from a rule.
abstract  java.util.Collection<Goal> getGoals()
          Method returns a collection of immediate goals.
 SuperLinkID getParentID()
          Gets the parent id of this rule.
protected  double getSensorValue(State state, SuperLinkID sensorID)
          Method returns the value of the input sensorID in the input state.
 void setParentID(SuperLinkID parentID)
          Sets the parent id for this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parentID

private SuperLinkID parentID
The ID of the originating PlanRequester.

Constructor Detail

Rule

public Rule()
Method Detail

getGoals

public abstract java.util.Collection<Goal> getGoals()
Method returns a collection of immediate goals.

If there are no immediate goals, an empty collection is returned.

Returns:
the goals of this rule

desire

public abstract double desire(State currentState,
                              State newState,
                              Step step)
Method returns the calculated desire associated with the change from currentState to newState.

The calculated desire must evaluate to [0,1], where 0 represents no desire for changing state, and 1 represents maximum desire for change.

Some rules are allowed to evaluate to values (much) larger than 1. This exception is only allowed if the outcome of not respecting the rule is fatal.

Parameters:
currentState - the current state
newState - the new state
step - the step
Returns:
the calculated desire

getExplanation

public java.lang.String getExplanation()
Gets the explanation/reasoning from a rule.

Override this method if a more detailed explanation is needed.

Returns:
The explanation.

getParentID

public SuperLinkID getParentID()
Gets the parent id of this rule.

Returns:
the parentID

setParentID

public void setParentID(SuperLinkID parentID)
Sets the parent id for this rule.

Parameters:
parentID - the parentID to set

getSensorValue

protected double getSensorValue(State state,
                                SuperLinkID sensorID)
Method returns the value of the input sensorID in the input state. If the sensor isn't represented in the state, 0 is returned.

Parameters:
state - the state
sensorID - the id
Returns:
the value of the sensor

getAdjustableSettingFromParent

protected double getAdjustableSettingFromParent(SuperLinkID adjustableID)
Method returns the setting of the input adjustable.

Parameters:
adjustableID - id of the adjustable
Returns:
the setting

getAdjustableSetting

protected double getAdjustableSetting(Step step,
                                      SuperLinkID id)
Returns the setting of an adjustable contained in the step identified by the id.

Parameters:
step - the step
id - the id
Returns:
the setting


Copyright © Deepthought Development - All Rights Reserved.