edu.usc.cse.desi.algorithm
Class GreedyAlgorithm

java.lang.Object
  extended byedu.usc.cse.desi.algorithm.AbstractAlgorithm
      extended byedu.usc.cse.desi.algorithm.GreedyAlgorithm

public class GreedyAlgorithm
extends AbstractAlgorithm

Author:
NeLs Started on Oct 4, 2004 This is the greedy algorithm, probably the only algorithm that will be implemented for a while (Well besides Exact). As you will notice most of its implementation relies on the existing code from DeSi 1.0. This is fine for this case because it will fill in some arrays and then those results will be applied to the DESIViewModel.

Field Summary
 double compFreqFactor
           
 double compMemFactor
           
private  java.util.List compsList
           
 double hostMemFactor
           
 double hostRelFactor
           
private  java.util.List hostsList
           
(package private)  int numOfMappedComps
           
(package private)  int numOfMappedHosts
           
 
Constructor Summary
GreedyAlgorithm()
           
 
Method Summary
protected  DESIViewModel executeAlgo(DESIViewModel cur_model)
          THis is the most important method of the class.
 int findFirstComponent(double[] compsRank, int curHost, int[] currentlyMapped)
           
 int findMax(double[] a, int length)
           
 double findMaxFreqOfComps()
           
 double findMaxFreqOfUnmappedComps(int[] currentlyMapped)
           
 double findMaxMemOfUnmappedComps(int[] currentlyMapped)
           
 double findMaxMemOfUnmappedHosts(int[] currentlyMappedHosts)
           
 double findMaxRelOfHosts()
           
 double findMaxRelOfUnmappedHosts(int[] currentlyMappedHosts)
           
 int findMin(double[] a, int length)
           
private  int findNextBestComp(int[] currentlyMapped, double maxMem, int currentHost)
           
private  int findNextBestHost(int[] currentlyMappedHosts)
           
 boolean locationConstraintSatisfied(int[] currentlyMapped, int currentHost, int comp)
           
 
Methods inherited from class edu.usc.cse.desi.algorithm.AbstractAlgorithm
run, run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hostRelFactor

public double hostRelFactor

hostMemFactor

public double hostMemFactor

compFreqFactor

public double compFreqFactor

compMemFactor

public double compMemFactor

numOfMappedHosts

int numOfMappedHosts

numOfMappedComps

int numOfMappedComps

compsList

private java.util.List compsList

hostsList

private java.util.List hostsList
Constructor Detail

GreedyAlgorithm

public GreedyAlgorithm()
Method Detail

executeAlgo

protected DESIViewModel executeAlgo(DESIViewModel cur_model)
THis is the most important method of the class. It gets called when the algorithm is run. I overrode this method:

Specified by:
executeAlgo in class AbstractAlgorithm
Parameters:
cur_model - DESIViewModel - The current model of the system.
Returns:
DESIViewModel - The affected model of the system.
See Also:
AbstractAlgorithm.executeAlgo(edu.usc.cse.desi.model.view.DESIViewModel)

findNextBestComp

private int findNextBestComp(int[] currentlyMapped,
                             double maxMem,
                             int currentHost)

findNextBestHost

private int findNextBestHost(int[] currentlyMappedHosts)

findMaxFreqOfComps

public double findMaxFreqOfComps()

findMaxRelOfHosts

public double findMaxRelOfHosts()

findMaxFreqOfUnmappedComps

public double findMaxFreqOfUnmappedComps(int[] currentlyMapped)

findMaxMemOfUnmappedComps

public double findMaxMemOfUnmappedComps(int[] currentlyMapped)

findMaxRelOfUnmappedHosts

public double findMaxRelOfUnmappedHosts(int[] currentlyMappedHosts)

findMaxMemOfUnmappedHosts

public double findMaxMemOfUnmappedHosts(int[] currentlyMappedHosts)

findMax

public int findMax(double[] a,
                   int length)

findMin

public int findMin(double[] a,
                   int length)

findFirstComponent

public int findFirstComponent(double[] compsRank,
                              int curHost,
                              int[] currentlyMapped)

locationConstraintSatisfied

public boolean locationConstraintSatisfied(int[] currentlyMapped,
                                           int currentHost,
                                           int comp)