nars.entity
Class BudgetValue

java.lang.Object
  extended by nars.entity.BudgetValue
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Item

public class BudgetValue
extends java.lang.Object
implements java.lang.Cloneable

A triple of priority (current), durability (decay), and quality (long-term average).


Field Summary
protected  ShortFloat durability
          The percent of priority to be kept in a constant period
private static char MARK
          The charactor that marks the two ends of a budget value
protected  ShortFloat priority
          The relative share of time resource to be allocated
protected  ShortFloat quality
          The overall (context-independent) evaluation
private static char SEPARATOR
          The charactor that separates the factors in a budget value
 
Constructor Summary
BudgetValue()
          Default constructor
BudgetValue(BudgetValue v)
          Cloning constructor
BudgetValue(float p, float d, float q)
          Constructor with initialization
 
Method Summary
 boolean aboveThreshold()
          Whether the budget should get any processing at all
 java.lang.Object clone()
          Cloning method
 void decDurability(float v)
          Decrease durability value by a percentage of the remaining range
 void decPriority(float v)
          Decrease priority value by a percentage of the remaining range
 void decQuality(float v)
          Decrease quality value by a percentage of the remaining range
 float getDurability()
          Get durability value
 float getPriority()
          Get priority value
 float getQuality()
          Get quality value
 void incDurability(float v)
          Increase durability value by a percentage of the remaining range
 void incPriority(float v)
          Increase priority value by a percentage of the remaining range
 void incQuality(float v)
          Increase quality value by a percentage of the remaining range
 void merge(BudgetValue that)
          Merge one BudgetValue into another
 void setDurability(float v)
          Change durability value
 void setPriority(float v)
          Change priority value
 void setQuality(float v)
          Change quality value
 float summary()
          To summarize a BudgetValue into a single number in [0, 1]
 java.lang.String toString()
          Fully display the BudgetValue
 java.lang.String toString2()
          Briefly display the BudgetValue
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MARK

private static final char MARK
The charactor that marks the two ends of a budget value

See Also:
Constant Field Values

SEPARATOR

private static final char SEPARATOR
The charactor that separates the factors in a budget value

See Also:
Constant Field Values

priority

protected ShortFloat priority
The relative share of time resource to be allocated


durability

protected ShortFloat durability
The percent of priority to be kept in a constant period


quality

protected ShortFloat quality
The overall (context-independent) evaluation

Constructor Detail

BudgetValue

public BudgetValue()
Default constructor


BudgetValue

public BudgetValue(float p,
                   float d,
                   float q)
Constructor with initialization

Parameters:
p - Initial priority
d - Initial durability
q - Initial quality

BudgetValue

public BudgetValue(BudgetValue v)
Cloning constructor

Parameters:
v - Budget value to be cloned
Method Detail

clone

public java.lang.Object clone()
Cloning method

Overrides:
clone in class java.lang.Object

getPriority

public float getPriority()
Get priority value

Returns:
The current priority

setPriority

public void setPriority(float v)
Change priority value

Parameters:
v - The new priority

incPriority

public void incPriority(float v)
Increase priority value by a percentage of the remaining range

Parameters:
v - The increasing percent

decPriority

public void decPriority(float v)
Decrease priority value by a percentage of the remaining range

Parameters:
v - The decreasing percent

getDurability

public float getDurability()
Get durability value

Returns:
The current durability

setDurability

public void setDurability(float v)
Change durability value

Parameters:
v - The new durability

incDurability

public void incDurability(float v)
Increase durability value by a percentage of the remaining range

Parameters:
v - The increasing percent

decDurability

public void decDurability(float v)
Decrease durability value by a percentage of the remaining range

Parameters:
v - The decreasing percent

getQuality

public float getQuality()
Get quality value

Returns:
The current quality

setQuality

public void setQuality(float v)
Change quality value

Parameters:
v - The new quality

incQuality

public void incQuality(float v)
Increase quality value by a percentage of the remaining range

Parameters:
v - The increasing percent

decQuality

public void decQuality(float v)
Decrease quality value by a percentage of the remaining range

Parameters:
v - The decreasing percent

merge

public void merge(BudgetValue that)
Merge one BudgetValue into another

Parameters:
that - The other Budget

summary

public float summary()
To summarize a BudgetValue into a single number in [0, 1]

Returns:
The summary value

aboveThreshold

public boolean aboveThreshold()
Whether the budget should get any processing at all

to be revised to depend on how busy the system is

Returns:
The decision on whether to process the Item

toString

public java.lang.String toString()
Fully display the BudgetValue

Overrides:
toString in class java.lang.Object
Returns:
String representation of the value

toString2

public java.lang.String toString2()
Briefly display the BudgetValue

Returns:
String representation of the value with 2-digit accuracy