edu.usc.cse.desi.algorithm
Class AbstractAlgorithm

java.lang.Object
  extended byedu.usc.cse.desi.algorithm.AbstractAlgorithm
Direct Known Subclasses:
ExactAlgorithm, FirstTestAlgo, GreedyAlgorithm

public abstract class AbstractAlgorithm
extends java.lang.Object

This class is the super type for all algorithms that can be run in DeSi.

Author:
NeLs Started on Jul 29, 2004

Constructor Summary
AbstractAlgorithm()
           
 
Method Summary
protected abstract  DESIViewModel executeAlgo(DESIViewModel cur_model)
          To implement an algorithm override this method.
 DESIViewModel run(DESIViewModel cur_model, boolean clone)
          This method is not meant to be overridden.
static DESIViewModel run(java.lang.String algo_name, DESIViewModel cur_model)
          This method can be called to create and run an algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAlgorithm

public AbstractAlgorithm()
Method Detail

run

public static final DESIViewModel run(java.lang.String algo_name,
                                      DESIViewModel cur_model)
This method can be called to create and run an algorithm. It works some- what like a factory in that it dynamically create an Algorithm object based on the type name passed. This method will then call run on that algorithm and pass true for the clone parameter.

Parameters:
algo_name - String - The fully qualified name of the algorithm that you want to run. This algo must be a subclass of this class.
cur_model - DESIViewModel - The current model.
Returns:
DESIViewModel - A new DESIViewModel that is the result of the algo.

run

public final DESIViewModel run(DESIViewModel cur_model,
                               boolean clone)
This method is not meant to be overridden. It is the method that will be called by DeSi in order to run the algorithms. You pass it

Parameters:
cur_model - DESIViewModel - The current model of the system.
clone - boolean - True if it should make a copy of the model, false if it should work on the given model.
Returns:
DESIViewModel - The model after the algo has run. May be a copy or may be the original reference.

executeAlgo

protected abstract DESIViewModel executeAlgo(DESIViewModel cur_model)
To implement an algorithm override this method. Given the current model of the system, return a model of the system after the algo has been run. This method is designed so that the overrider can make changes to the passed model. No matter what they decide to do, the new model must be returned.

Parameters:
cur_model - DESIViewModel - The current model of the system.
Returns:
DESIViewModel - The affected model of the system.