| java.lang.Object org.cougaar.lib.util.UTILAllocate
All known Subclasses: org.cougaar.glm.util.GLMAllocate,
UTILAllocate | public class UTILAllocate (Code) | | This class contains utility functions for allocations.
|
Method Summary | |
protected static String | ARtoString(int[] aspectTypes, double[] aspectValues) | public void | addQueryResultToAR(PlanElement pe, int aqType, String data) Adds data to an auxiliaryQuery. | public AllocationResult | cloneAllocResultAsSuccess(PlanningFactory ldmf, AllocationResult toClone) | protected AllocationResult | createAllocationResult(boolean isSuccess, PlanningFactory ldmf, int[] aspectarray, double[] resultsarray, double confidence)
Freeform allocation result creation. | public static List | enumToList(Enumeration e) | public static Vector | enumToVector(Enumeration e) | public boolean | exceedsPreferences(Task t, Date start, Date end, double cost) Handy utility function for checking a task's preferences against start and
end dates and cost. | public boolean | exceedsPreferences(Task t, Date start, Date end) Handy utility function for checking a task's preferences against start and
end dates. | public boolean | exceedsPreferences(Task t, AspectValue[] aspectValues) Check a task's preferences against given aspect values. | public boolean | exceedsPreferences(Task t, int[] aspectTypes, double[] aspectValues)
Check a task's preferences against given aspect values.
Throws an informative exception if somehow the
the aspect types being checked are not the same set as the task's
preferences. | public AspectValue[] | getAspects(Date start, Date end, double cost) Utility function for creating AspectValues from start, end date, and cost. | public AspectValue[] | getAspects(Date start, Date end, double cost, long quantity) Utility function for creating AspectValues from start, end date, cost and quantity. | public AspectValue[] | getAspectsFromArrays(int[] aspectarray, double[] resultsarray) | public AspectValue[] | getAspectsFromDates(Date start, Date end) Utility function for creating AspectValues from start and end date. | public boolean | isFailedPE(PlanElement pe) Checks plan element's allocation result to see if it's a failed
plan element. | public Vector | iterToVector(Iterator i) | public PlanElement | makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, Date start, Date end, double cost, double confidence, Role assignedRole) Creates an Allocation or FailedAllocation
depending on whether start and end dates or cost
exceed preference thresholds. | public PlanElement | makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, Date start, Date end, double confidence, Role assignedRole)
Creates an Allocation or FailedDisposition
with an allocationResult w/ isSuccess=False or True,
depending on whether any of the start and end dates
exceed preference thresholds. | public PlanElement | makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, AspectValue[] aspects, double confidence, Role assignedRole) Creates an Allocation or FailedDisposition
with an allocationResult w/ isSuccess=False or True,
depending on whether any of the aspect values of the
allocation exceed any preference thresholds. | public PlanElement | makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, int[] aspectarray, double[] resultsarray, double confidence, Role assignedRole)
Creates an Allocation or FailedDisposition with an
allocationResult w/ isSuccess=False or True,
depending on whether any of the aspect values of the
allocation exceed any preference thresholds. | public Disposition | makeFailedDisposition(UTILPlugin creator, PlanningFactory ldmf, Task t, AllocationResult failedAR) This should be used when the preference thresholds are exceeded, or
the cumulative
score for all preferences exceeds some threshold.
This form lets the tasked cluster say how the preferences were exceeded.
Parameters: ldmf - PlanningFactory for making the plan elements Parameters: t - Task that failed to be allocated Parameters: failedAR - AllocationResult stating how the preferences would have beenexceeded. | public Disposition | makeFailedDisposition(UTILPlugin ignoredCreator, PlanningFactory ldmf, Task task)
When you just can't allocate!
This should be used when the preference thresholds are exceeded, or
the cumulative
score for all preferences exceeds some threshold.
Generally the other makeFailedDisposition should be used --
the tasking/superior cluster should be told not just that the allocation failed,
but what aspect values made it fail. | protected void | print(AspectValue av, Preference pref, double score, AspectScoreRange definedRange, Enumeration validRanges) | protected static String | printTypeValue(int type, double value) | protected double | scoreAgainstPreferences(Task t, AllocationResult allocResult) | public double | scoreAgainstPreferences(Task t, Date start, Date end, double cost) | public double | scoreAgainstPreferences(Task t, Date start, Date end) Score of a task's preferences against start and
end dates. | public double | scoreAgainstPreferences(Task t, AspectValue[] aspectValues) Score a task's preferences against given aspect values. | public double | scoreAgainstPreferences(Task t, int[] aspectTypes, double[] aspectValues)
Score a task's preferences against given aspect values.
Throws an informative exception if somehow the
the aspect types being checked are not the same set as the task's
preferences. |
HIGHEST_CONFIDENCE | final public static double HIGHEST_CONFIDENCE(Code) | | |
MEDIUM_CONFIDENCE | final public static double MEDIUM_CONFIDENCE(Code) | | |
UTILAllocate | public UTILAllocate(Logger log)(Code) | | Set logger
|
ARtoString | protected static String ARtoString(int[] aspectTypes, double[] aspectValues)(Code) | | |
addQueryResultToAR | public void addQueryResultToAR(PlanElement pe, int aqType, String data)(Code) | | Adds data to an auxiliaryQuery.
Parameters: pe - the planelement of the task that issued the auxiliary query Parameters: aqType - the AuxiliaryQueryType Parameters: data - the data that answers the query |
createAllocationResult | protected AllocationResult createAllocationResult(boolean isSuccess, PlanningFactory ldmf, int[] aspectarray, double[] resultsarray, double confidence)(Code) | |
Freeform allocation result creation.
Protected because plugin should not need to call this.
Workaround for COUGAAR bug (MB5.2) where asking for aspect values
will throw null pointer exception.
Parameters: isSuccess - sets whether allocation obeyed preferences or not Parameters: ldmf - PlanningFactory for making the plan elements Parameters: aspectarray - - array of aspect type IDs (ints from AspectType) Parameters: resultsarray - - results for those aspects, in same order as aspect types Parameters: confidence - of allocation allocation result with aspect results |
exceedsPreferences | public boolean exceedsPreferences(Task t, Date start, Date end, double cost)(Code) | | Handy utility function for checking a task's preferences against start and
end dates and cost.
Parameters: t - task to check Parameters: start - date to check against preferences Parameters: end - date to check against preferences Parameters: cost - - the monetary cost of a potential allocation true if either the start or end dates or cost lie outside the task's preferences. |
exceedsPreferences | public boolean exceedsPreferences(Task t, Date start, Date end)(Code) | | Handy utility function for checking a task's preferences against start and
end dates.
Parameters: t - task to check Parameters: start - date to check against preferences Parameters: end - date to check against preferences true if either the start or end dates lie outside the task's preferences. |
exceedsPreferences | public boolean exceedsPreferences(Task t, int[] aspectTypes, double[] aspectValues)(Code) | |
Check a task's preferences against given aspect values.
Throws an informative exception if somehow the
the aspect types being checked are not the same set as the task's
preferences. E.g. if the task has only a START_TIME preference
and one of the allocation aspects is COST.
This should never happen -- one
should only assign aspects against a task's preferences.
If debug is set, warns to stdout if set of preferences types doesn't match set
of aspect values.
Parameters: t - task to check Parameters: aspectTypes - array of aspect types Parameters: aspectValues - array of aspect values boolean -- true if any preference is exceeded See Also: org.cougaar.planning.ldm.plan.AspectType |
getAspects | public AspectValue[] getAspects(Date start, Date end, double cost)(Code) | | Utility function for creating AspectValues from start, end date, and cost.
Parameters: start - date Parameters: end - date Parameters: cost - AspectValue array representing dates and cost. |
getAspects | public AspectValue[] getAspects(Date start, Date end, double cost, long quantity)(Code) | | Utility function for creating AspectValues from start, end date, cost and quantity.
Parameters: start - date Parameters: end - date Parameters: cost - Parameters: quantity - AspectValue array representing dates, cost, and quantity. |
getAspectsFromArrays | public AspectValue[] getAspectsFromArrays(int[] aspectarray, double[] resultsarray)(Code) | | Utility function for creating AspectValues from type and value arrays
Parameters: aspectarray - type array Parameters: resultsarray - value array AspectValue array |
getAspectsFromDates | public AspectValue[] getAspectsFromDates(Date start, Date end)(Code) | | Utility function for creating AspectValues from start and end date.
Parameters: start - date Parameters: end - date AspectValue array representing dates. |
makeAllocation | public PlanElement makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, Date start, Date end, double cost, double confidence, Role assignedRole)(Code) | | Creates an Allocation or FailedAllocation
depending on whether start and end dates or cost
exceed preference thresholds.
Parameters: ldmf - the PlanningFactory Parameters: plan - the log plan Parameters: t - the task to allocate Parameters: asset - the asset assigned to handle the task Parameters: start - - start date of allocation Parameters: end - - end date of allocation Parameters: cost - - the monetary cost of the allocation Parameters: confidence - in the allocation PlanElement = Allocation or a FailedDisposition |
makeAllocation | public PlanElement makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, Date start, Date end, double confidence, Role assignedRole)(Code) | |
Creates an Allocation or FailedDisposition
with an allocationResult w/ isSuccess=False or True,
depending on whether any of the start and end dates
exceed preference thresholds.
Automates the checking of an allocation against its preferences
Plugins should never have to create AllocationResults directly.
If you want to find the score of a task-allocation result pair
before making the REAL allocation, you can call scoreAgainstPreferences
(GSS).
Note that returned Allocations will ALWAYS have
an AllocationResult with isSuccess = TRUE.
FailedDispositions will ALWAYS have isSuccess = FALSE.
Parameters: ldmf - the PlanningFactory Parameters: plan - the log plan Parameters: t - the task to allocate Parameters: asset - the asset assigned to handle the task Parameters: start - - start date of allocation Parameters: end - - end date of allocation Parameters: confidence - in the allocation PlanElement = Allocation or a FailedDisposition |
makeAllocation | public PlanElement makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, AspectValue[] aspects, double confidence, Role assignedRole)(Code) | | Creates an Allocation or FailedDisposition
with an allocationResult w/ isSuccess=False or True,
depending on whether any of the aspect values of the
allocation exceed any preference thresholds.
This automates the checking of an allocation against its preferences.
Plugins should never have to create AllocationResults directly.
If you want to find the score of a task-allocation result pair
before making the REAL allocation, you can call scoreAgainstPreferences
(GSS).
Note that returned Allocations will ALWAYS have
an AllocationResult with isSuccess = TRUE.
FailedDispositions will ALWAYS have isSuccess = FALSE.
Parameters: ldmf - the PlanningFactory Parameters: plan - the log plan Parameters: t - the task to allocate Parameters: asset - the asset assigned to handle the task Parameters: aspects - AspectValue array -- aspect represented as aspectValues Parameters: confidence - in the allocation PlanElement = Allocation or a FailedDisposition |
makeAllocation | public PlanElement makeAllocation(UTILPlugin creator, PlanningFactory ldmf, Plan plan, Task t, Asset asset, int[] aspectarray, double[] resultsarray, double confidence, Role assignedRole)(Code) | |
Creates an Allocation or FailedDisposition with an
allocationResult w/ isSuccess=False or True,
depending on whether any of the aspect values of the
allocation exceed any preference thresholds.
Also will automatically create a FailedDisposition if the asset
passed in is null.
This automates the checking of an allocation against its preferences.
Plugins should never have to create AllocationResults directly.
If you want to find the score of a task-allocation result pair
before making the REAL allocation, you can call scoreAgainstPreferences
(GSS).
Note that returned Allocations will ALWAYS have
an AllocationResult with isSuccess = TRUE.
FailedDispositions will ALWAYS have isSuccess = FALSE.
Parameters: ldmf - the PlanningFactory Parameters: plan - the log plan Parameters: t - the task to allocate Parameters: asset - the asset assigned to handle the task (Ignored if failed allocation.) Parameters: aspectarray - - array of aspect types Parameters: resultsarray - - array of aspect values Parameters: confidence - in the allocation PlanElement = Allocation or a FailedDisposition |
makeFailedDisposition | public Disposition makeFailedDisposition(UTILPlugin creator, PlanningFactory ldmf, Task t, AllocationResult failedAR)(Code) | | This should be used when the preference thresholds are exceeded, or
the cumulative
score for all preferences exceeds some threshold.
This form lets the tasked cluster say how the preferences were exceeded.
Parameters: ldmf - PlanningFactory for making the plan elements Parameters: t - Task that failed to be allocated Parameters: failedAR - AllocationResult stating how the preferences would have beenexceeded. FailedDisposition See Also: UTILAllocate.makeFailedDisposition(PlanningFactory,Task) |
makeFailedDisposition | public Disposition makeFailedDisposition(UTILPlugin ignoredCreator, PlanningFactory ldmf, Task task)(Code) | |
When you just can't allocate!
This should be used when the preference thresholds are exceeded, or
the cumulative
score for all preferences exceeds some threshold.
Generally the other makeFailedDisposition should be used --
the tasking/superior cluster should be told not just that the allocation failed,
but what aspect values made it fail. This function does not let you specify
the aspect results.
Parameters: ignoredCreator - - currently ignored slot that could be used for debugging Parameters: ldmf - PlanningFactory for making the plan elements Parameters: task - Task that failed to be allocated FailedDisposition See Also: UTILAllocate.makeFailedDisposition(PlanningFactory,Task,AllocationResult) |
printTypeValue | protected static String printTypeValue(int type, double value)(Code) | | |
scoreAgainstPreferences | protected double scoreAgainstPreferences(Task t, AllocationResult allocResult)(Code) | | Score of a task's preferences against an allocation result
the total score of the allocation result against the task's preferences |
scoreAgainstPreferences | public double scoreAgainstPreferences(Task t, Date start, Date end, double cost)(Code) | | Score of a task's preferences against start and
end dates, and cost
Parameters: t - task to check Parameters: start - date to score against preferences Parameters: end - date to score against preferences Parameters: cost - - the monetary cost of a potential allocation double score |
scoreAgainstPreferences | public double scoreAgainstPreferences(Task t, Date start, Date end)(Code) | | Score of a task's preferences against start and
end dates.
Hoefully this form would be called most often...
Parameters: t - task to check Parameters: start - date to score against preferences Parameters: end - date to score against preferences double score |
scoreAgainstPreferences | public double scoreAgainstPreferences(Task t, int[] aspectTypes, double[] aspectValues)(Code) | |
Score a task's preferences against given aspect values.
Throws an informative exception if somehow the
the aspect types being checked are not the same set as the task's
preferences. E.g. if the task has only a START_TIME preference
and one of the allocation aspects is COST, then this method
will throw an exception. This should never happen -- one
should only assign aspects against a task's preferences.
Protects against COUGAAR bug : sometimes preference weight
gets lost... (ends up = 0).
Parameters: t - task to check Parameters: aspectTypes - array of aspect types Parameters: aspectValues - array of aspect values double -- score of these aspect values against the task's preferences See Also: org.cougaar.planning.ldm.plan.AspectType See Also: org.cougaar.planning.ldm.plan.AspectValue See Also: org.cougaar.planning.ldm.plan.Preference |
|
|