edu.washington.cs.supple.render.utility
Class RegretCalculator

java.lang.Object
  extended byedu.washington.cs.supple.render.utility.RegretCalculator
All Implemented Interfaces:
FactoredCostCalculator

public class RegretCalculator
extends java.lang.Object
implements FactoredCostCalculator

Author:
kgajos A set of utilities for calculating regret

Field Summary
static int GAP
           
static int MINIMAX
           
static int OPTIMISTIC
           
static int PESIMISTIC
           
 
Constructor Summary
RegretCalculator()
           
 
Method Summary
 double calculateCost(int strategy, Solution solution, FactoredCostFunction costFunction)
          Calculates the cost of an entire solution
 float calculateCost(int strategy, Widget reference, java.util.Collection feasibleWidgets, java.util.Collection factors)
          Computes maximum regret for a reference widget and a domain of feasible widgets
protected  float calculateFactorContribution(int strategy, Factor factor, java.util.Collection widgetBags)
          Calculates contribution of a particular factor to the overall cost
 float calculateFactorContribution(int strategy, Factor factor, WidgetBag curBag)
          Calculates contributions of individual factors to the overall cost given a particular widget bag
 FactorStatistics calculateFactorStatistics(int strategy, java.util.Collection factors, java.util.Collection widgetBags)
          Calculates contributions of individual factors to the overall cost
protected  float calculateMaxRegret(Widget reference, java.util.Collection feasibleWidgets, java.util.Collection factors)
          Computes maximum regret for a reference widget and a domain of feasible widgets
protected  float calculateOPCost(int strategy, Widget widget, java.util.Collection factors)
          Calculates optimistic or pesimistic cost for a widget
protected  float calculateRegret(Widget reference, Widget otherWidget, java.util.Collection factors)
          Computes regret for a specific pair of widgets given a set of relevant factors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMAX

public static final int MINIMAX
See Also:
Constant Field Values

OPTIMISTIC

public static final int OPTIMISTIC
See Also:
Constant Field Values

PESIMISTIC

public static final int PESIMISTIC
See Also:
Constant Field Values

GAP

public static final int GAP
See Also:
Constant Field Values
Constructor Detail

RegretCalculator

public RegretCalculator()
Method Detail

calculateRegret

protected float calculateRegret(Widget reference,
                                Widget otherWidget,
                                java.util.Collection factors)
Computes regret for a specific pair of widgets given a set of relevant factors

Parameters:
reference - the reference widget
otherWidget - an alternative widget
factors - a collection of factors from the utility function
Returns:
the regret

calculateMaxRegret

protected float calculateMaxRegret(Widget reference,
                                   java.util.Collection feasibleWidgets,
                                   java.util.Collection factors)
Computes maximum regret for a reference widget and a domain of feasible widgets

Parameters:
reference - reference widget
feasibleWidgets - all feasible widgets
factors - a collection of factors
Returns:
the max regret

calculateOPCost

protected float calculateOPCost(int strategy,
                                Widget widget,
                                java.util.Collection factors)
Calculates optimistic or pesimistic cost for a widget

Parameters:
strategy - a strategy (has to be either Optimistic or Pesimistifc)
widget - widget for which we are calculating cost
factors - factors to be involved in the computation
Returns:
cost

calculateCost

public float calculateCost(int strategy,
                           Widget reference,
                           java.util.Collection feasibleWidgets,
                           java.util.Collection factors)
Computes maximum regret for a reference widget and a domain of feasible widgets

Specified by:
calculateCost in interface FactoredCostCalculator
Parameters:
strategy - a strategy for calculating cost (minimax regret, optimistic, pesimistic)
reference - reference widget
feasibleWidgets - all feasible widgets
factors - a collection of factors
Returns:
the max regret

calculateFactorContribution

protected float calculateFactorContribution(int strategy,
                                            Factor factor,
                                            java.util.Collection widgetBags)
Calculates contribution of a particular factor to the overall cost

Parameters:
strategy - strategy to be used
factor - factor to be analyzed
widgetBags - widget bags from a solution (they must be set)
Returns:
this factor's contribution

calculateFactorStatistics

public FactorStatistics calculateFactorStatistics(int strategy,
                                                  java.util.Collection factors,
                                                  java.util.Collection widgetBags)
Calculates contributions of individual factors to the overall cost

Parameters:
strategy - strategy to be used
factors - factors to be analyzed
widgetBags - widget bags from a solution (they must be set)
Returns:
a data structure summarizing the statistics of different factors

calculateFactorContribution

public float calculateFactorContribution(int strategy,
                                         Factor factor,
                                         WidgetBag curBag)
Calculates contributions of individual factors to the overall cost given a particular widget bag

Parameters:
strategy - strategy to be used
factor - factor to be analyzed
Returns:
contrubution of this factor to this one widget bag

calculateCost

public double calculateCost(int strategy,
                            Solution solution,
                            FactoredCostFunction costFunction)
Description copied from interface: FactoredCostCalculator
Calculates the cost of an entire solution

Specified by:
calculateCost in interface FactoredCostCalculator
Parameters:
strategy - an optional argument if more than one variant of a method is possible
solution - a solution to be evaluated
costFunction - the cost function to be used
Returns:
the cost