SAR<em>bayes</em>: SORAL Documentation
(SARBayes) Main Related Pages Class List Hierarchy Methods Files

CharnesCooper Class Reference

#include <Alloc-CC.h>

Inheritance diagram for CharnesCooper:

Inheritance graph
[legend]
Collaboration diagram for CharnesCooper:

Collaboration graph
[legend]
List of all members.

Detailed Description

The Charnes-Cooper allocation class.

CharnesCooper:

Implements the Charnes-Cooper allocation algorithm. The allocation is stored in a matrix (Array2D). More details in the file header.

Author : Michael Eldridge

Definition at line 81 of file Alloc-CC.h.

Public Member Functions

 CharnesCooper (const int p_no_resources, const int p_no_areas, const Array2D &p_effectiveness, const valarray< double > p_available, const valarray< double > p_POC)
 Constructor calls calcAllocation and uses Array2D to store allocation.


Protected Member Functions

void calcAllocation ()
 Calculate the allocation using the Charnes Cooper algorithm.

ActiveAreafirstArea (void) const
 Returns the area number of the first area in this allocation.

ActiveAreanextArea (const int currentArea) const
 Given an area number, returns the next area that has something assigned to it.

AreaAssignmentfirstArea (const int Resource) const
 Returns the area number of the first area in this allocation.

AreaAssignmentnextArea (const int Resource, const int currentArea) const
 Given a resource and an area number, returns the next area to which this resource is assigned.

ResourceAssignmentfirstRes (const int Area) const
 Given an area, it returns the first resource assigned to that area.

ResourceAssignmentnextRes (const int Area, const int currentResource) const
 Given a resource and an area, it returns the next ResourceAssignment for that area.

double calcInitialPSR (const int resourceNum, const int areaNum)
 Calculates the initial Probable Success Rate used in CC.


Private Member Functions

 CharnesCooper (const CharnesCooper &p_allocation)
CharnesCooper & operator= (const CharnesCooper &p_allocation)
void quickSort (int items[], int arraySize)
 Top level of quickSort algorithm. The recursive part is in qSort.

void qSort (int items[], int left, int right)
 Recursive part of quickSort algorithm.


Private Attributes

Array2D myAssignments
 The set of assignments, stored as a dynamically allocated matrix.

double myAvailable
 The amount of our resource still available.


Friends

class AreaIterator
 So that the AreaIterator can access the first & next functions.

class ResourceIterator
 So that the ResourceIterator can access the first & next functions.

class ActiveAreasIterator
 So that the ActiveAreasIterator can access the first & next functions.


Constructor & Destructor Documentation

CharnesCooper::CharnesCooper const int    p_no_resources,
const int    p_no_areas,
const Array2D   p_effectiveness,
const valarray< double >    p_endurance,
const valarray< double >    p_POC
 

Constructor calls calcAllocation and uses Array2D to store allocation.

Constructor for the Charnes Cooper allocation object. (File description and header file description have more information about the algorithm.)

Author : Michael Eldridge

Definition at line 79 of file Alloc-CC.cpp.

References calcAllocation().


Member Function Documentation

void CharnesCooper::calcAllocation void    [protected, virtual]
 

Calculate the allocation using the Charnes Cooper algorithm.

calcAllocationCharnesCooper()

Note: Charnes Cooper only uses 1 resource

Uses the Charnes-Cooper algorithm to calculate the optimal assignment of resource 0 to the set of areas. The remaining search endurance (time the resource is still available for) is stored in myAvailable.

This set of assignments is stored in myAssignments.

If resource 0 is useless (for every area, either POC is zero, or its effectiveness in that area is zero), no allocation is made (resource 0 is assigned to each area for 0 hours).

Author: Gareth Thompson

Implements Allocation.

Definition at line 385 of file Alloc-CC.cpp.

References calcInitialPSR(), myAssignments, myAvailable, Allocation::myEffectiveness, Allocation::myNumAreas, and quickSort().

Referenced by CharnesCooper().

double CharnesCooper::calcInitialPSR const int    resourceNum,
const int    areaNum
[inline, protected]
 

Calculates the initial Probable Success Rate used in CC.

Calculates the initial PSR (Probable Success Rate) upon which the Charnes-Cooper algorithm is based. If W = sweep width (this resource, in this area) v = velocity (this resource, in this area) A = area size (m^2 or km^2 or whatever units v is in) p = POC or POA (this area) Effectiveness = Wv/A, so: PSR = Wvp/A = Wv * (p/A) = Wv * Pden where Pden is the probability density of the area. So PSR is the rate at which probability is swept up. For one resource, if you search highest-PSR areas first, you win. Maximal change in probability per time.

Definition at line 129 of file Alloc-CC.h.

References Allocation::myEffectiveness, and Allocation::myPOC.

Referenced by calcAllocation(), and qSort().

AreaAssignment * CharnesCooper::firstArea const int    resource const [protected, virtual]
 

Returns the area number of the first area in this allocation.

Returns the first AreaAssignment (an area and a time) that a given resource was assigned to.

If the resource does not exist in this allocation, it returns NULL.

Todo:
: It would be better if it threw an exception
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 141 of file Alloc-CC.cpp.

References myAssignments, and Allocation::myNumAreas.

ActiveArea * CharnesCooper::firstArea void    const [protected, virtual]
 

Returns the area number of the first area in this allocation.

Returns the area number of the first area in this allocation.

If the allocation is empty, returns NULL.

Todo:
: It would be better if it threw an exception
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 107 of file Alloc-CC.cpp.

References myAssignments, Allocation::myNumAreas, and Allocation::myNumResources.

ResourceAssignment * CharnesCooper::firstRes const int    area const [protected, virtual]
 

Given an area, it returns the first resource assigned to that area.

Given an area, it returns the first resource assigned to that area (returned as a ResourceAssignment with the resource and time).

If there are no resources, it returns NULL

Todo:
: It would be better if it through exceptions, or used enums.
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 247 of file Alloc-CC.cpp.

References myAssignments, and Allocation::myNumResources.

AreaAssignment * CharnesCooper::nextArea const int    resource,
const int    currentArea
const [protected, virtual]
 

Given a resource and an area number, returns the next area to which this resource is assigned.

Given a resource and an area number, returns the next area (returned as an AreaAssignment of area and time) to which _this_ resource is assigned.

If this resource is not assigned to any more areas, the function returns NULL.

Todo:
: It would be better if it threw exceptions or enum NO_MORE_AREAS?
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 213 of file Alloc-CC.cpp.

References myAssignments, and Allocation::myNumAreas.

ActiveArea * CharnesCooper::nextArea const int    currentArea const [protected, virtual]
 

Given an area number, returns the next area that has something assigned to it.

Given an area number, returns the next area that has something assigned to it in this set of allocations.

If there is no other area with an allocation of resources greater than 0, the function returns NULL. NOTE: This function searches by AREA: ie it searches through all of area N and all resources before searching through area N+1 and all resources. Etc.

Todo:
: It would be better if it threw exceptions?
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 175 of file Alloc-CC.cpp.

References myAssignments, Allocation::myNumAreas, and Allocation::myNumResources.

ResourceAssignment * CharnesCooper::nextRes const int    area,
const int    currentResource
const [protected, virtual]
 

Given a resource and an area, it returns the next ResourceAssignment for that area.

Given a resource and an area, it returns the next resource assigned to that area (as a ResourceAssignment).

If there are no next resources, it returns NULL.

Todo:
: Perhaps we should NOT suggest that this one throw an exception. Maybe return a "warning" exception: "No more resources"
Author: Andre Oboler (ASO)

Implements Allocation.

Definition at line 282 of file Alloc-CC.cpp.

References myAssignments, and Allocation::myNumResources.

void CharnesCooper::quickSort int    items[],
int    arraySize
[private]
 

Top level of quickSort algorithm. The recursive part is in qSort.

Sorts a list of ints (which are the index numbers of a set of areas) into decending order by their area's PSR values.

Reminder: Quicksort is on average O(n log n), but in the worst case will be O(n^2). The worst case is when the list is already sorted. So... DO NOT use this function additional times just to "ensure" the list is ordered.

Definition at line 315 of file Alloc-CC.cpp.

References qSort().

Referenced by calcAllocation().


The documentation for this class was generated from the following files:
Generated on Fri May 9 17:04:33 2003 for SORAL by dOxygen 1.3-rc3
(SARBayes) Main Related Pages Class List Hierarchy Methods Files