mil.af.afit.router
Class PriorityModel

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mil.af.afit.router.PriorityModel
All Implemented Interfaces:
java.util.Observer, java.io.Serializable

public class PriorityModel
extends java.util.Observable
implements java.util.Observer, java.io.Serializable

This records how a user wishes to treat priorities. For example a user may never want to trade even 100 priority 2 sites for a priority 1 site, or maybe five priority 2 sites are worth one priority 1 site. Whatever the case, PriorityModel tracks the relative worth of the priorities specified by the sites in the kernel's site list.

Since:
1.0
See Also:
Site, SiteList, PriorityModelList, Serialized Form

Field Summary
static int NEAR_INF
          A relative worth equal to or greater than this number is considered infinity.
 
Constructor Summary
PriorityModel(PriorityModel shellFromThis)
          Constructs a shell of a priority model from the passed priority model.
PriorityModel(java.lang.String name, Kernel kernel)
          Constructs a priority model with a default relative worth of infinity.
PriorityModel(java.lang.String name, Kernel kernel, int defaultRelativeWorth, boolean isEditable)
          Constructs a priority model with the specifie default relative worth and editable state.
 
Method Summary
 int[] getAllRelativeWorths()
          Returns all of relative worths.
 int getDefaultRelativeWorth()
          Returns the default relative worth.
 java.lang.String getName()
          Returns the name of the model.
 int[] getPriorities()
          Returns an array of priorities currently in the site list
 int getRelativeWorthAt(int index)
          Returns a specific relative worth.
 int[] getRelativeWorths()
          Returns an array of relative worths.
 void initializeAfterDeserialization(Kernel kernel)
          Registers with the kernel and updates self based on the site list.
static int intValue(java.lang.String s)
          Converts a string relative worth to an int value.
 boolean isEditable()
          Returns whether or not this model is marked as editable.
 boolean isEnabled()
          Whether or not the model is marked as enabled.
 PriorityModel makeShell()
          Returns a shell of this model.
 void setEnabled(boolean state)
          Sets whether or not the model is enabled.
 void setIsEditable(boolean state)
          Sets whether or not this model is marked as editable.
 void setName(java.lang.String name)
          Sets the name of the model.
 void setRelativeWorthAt(int worth, int index)
          Sets a specific relative worth for the model.
 void setRelativeWorths(int[] worths)
          Sets the relative worths for the model.
static java.lang.String textValue(int n)
          Converts a relative worth to a text value.
 java.lang.String toString()
           
 void update(java.util.Observable thing, java.lang.Object arg)
          Listens for updates to the kernel and its SiteList
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEAR_INF

public static final int NEAR_INF
A relative worth equal to or greater than this number is considered infinity.
Since:
1.0
Constructor Detail

PriorityModel

public PriorityModel(java.lang.String name,
                     Kernel kernel)
Constructs a priority model with a default relative worth of infinity.
Parameters:
name - name of priority model
kernel - kernel being used
Since:
1.0

PriorityModel

public PriorityModel(java.lang.String name,
                     Kernel kernel,
                     int defaultRelativeWorth,
                     boolean isEditable)
Constructs a priority model with the specifie default relative worth and editable state.
Parameters:
name - name of priority model
kernel - kernel being used
defaultRelativeWorth - default relative worth for model
isEditable - whether or not this model's worths can be changed
Since:
1.0

PriorityModel

public PriorityModel(PriorityModel shellFromThis)
Constructs a shell of a priority model from the passed priority model. A shell has all of the relative worths specified by the original, but it is not registered with the kernel.
Parameters:
shellFromThis - priority model from which to construct a shell
Since:
1.0
Method Detail

initializeAfterDeserialization

public final void initializeAfterDeserialization(Kernel kernel)
Registers with the kernel and updates self based on the site list.
Parameters:
kernel - the kernel to register with
Since:
1.0

getDefaultRelativeWorth

public final int getDefaultRelativeWorth()
Returns the default relative worth.
Returns:
the default relative worth
Since:
1.0

getAllRelativeWorths

public final int[] getAllRelativeWorths()
Returns all of relative worths. The first element of the array is the relative worth of the highest priority to the next highest priority. This continues through the array. This array may store values beyond the range of priorities currently represented in the site list. When priorities that were taken out of the site list are added again, the priority model will still save the original values.
Returns:
all of the relative worths
Since:
1.0

makeShell

public final PriorityModel makeShell()
Returns a shell of this model. A shell is not registered with the kernel.
Returns:
shell of this model
Since:
1.0

isEnabled

public final boolean isEnabled()
Whether or not the model is marked as enabled. This is used when the kernel begins solving.
Returns:
whether or not the model is enabled
Since:
1.0

setEnabled

public final void setEnabled(boolean state)
Sets whether or not the model is enabled. This is used when the kernel begins solving.
Parameters:
state - whether or not the model is enabled
Since:
1.0

getName

public final java.lang.String getName()
Returns the name of the model.
Returns:
name of the model
Since:
1.0

getPriorities

public final int[] getPriorities()
Returns an array of priorities currently in the site list
Returns:
array of priorities
Since:
1.0

getRelativeWorths

public final int[] getRelativeWorths()
Returns an array of relative worths. The first element of the array is the relative worth of the highest priority to the next highest priority. This continues through the array. The size of this array will be one less than the number of priorities.
Returns:
relative worths
Since:
1.0

getRelativeWorthAt

public final int getRelativeWorthAt(int index)
Returns a specific relative worth. The first element of the array is the relative worth of the highest priority to the next highest priority. This continues through the array.
Parameters:
index - position of relative worth to return
Returns:
relative worth
Since:
1.0

setName

public final void setName(java.lang.String name)
Sets the name of the model.
Parameters:
name - name of the model
Since:
1.0

setRelativeWorths

public final void setRelativeWorths(int[] worths)
Sets the relative worths for the model.
Parameters:
worths - new relative worths for the model
Since:
1.0

setRelativeWorthAt

public final void setRelativeWorthAt(int worth,
                                     int index)
Sets a specific relative worth for the model.
Parameters:
worths - new relative worth
index - position of new relative worth
Since:
1.0

setIsEditable

public final void setIsEditable(boolean state)
Sets whether or not this model is marked as editable.
Parameters:
state - whether or not this model is marked as editable
Since:
1.0

isEditable

public final boolean isEditable()
Returns whether or not this model is marked as editable.
Returns:
whether or not this model is marked as editable
Since:
1.0

textValue

public static final java.lang.String textValue(int n)
Converts a relative worth to a text value. A value greater than NEAR_INF will be considered infinity
Parameters:
n - number to convert
Returns:
relative worth as string
Since:
1.0

intValue

public static final int intValue(java.lang.String s)
Converts a string relative worth to an int value.
Parameters:
s - string to convert
Returns:
relative worth as an int
Since:
1.0

update

public void update(java.util.Observable thing,
                   java.lang.Object arg)
Listens for updates to the kernel and its SiteList
Specified by:
update in interface java.util.Observer

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object