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

UserDef Class Reference

#include <UserDef.h>

Inheritance diagram for UserDef:

Inheritance graph
[legend]
Collaboration diagram for UserDef:

Collaboration graph
[legend]
List of all members.

Detailed Description

The user-defined Allocation class. User may create his own allocation here.

UserDef:

Allocation class for user-specified allocations. This class allows the user to create an allocation from scratch, or to import an existing allocation and tweak it. This class is needed because search managers will almost always be aware of more constraints than the current program can handle.

Note: The calcAllocation function does nothing in UserDef.

Author : Andre Oboler


Public Member Functions

 UserDef (const int p_no_resources, const int p_no_areas, const Array2D &p_effectiveness, const valarray< double > p_available, const valarray< double > p_POC)
 Make a user-defined allocn: ie an empty allocn matrix of the correct size.

 UserDef (const UserDef &p_allocation)
 UserDef (Allocation &oldAllocation)
 Create a UserDef Allocation from an existing allocation (of another type).

 ~UserDef ()
 Empty destructor for UserDef.

void clearAll ()
 Clears all existing allocations.

void clearArea (const int area)
 Unassigns all resources in an area.

void calcAllocation (void)
 In UserDef, calcAllocation does nothing.

void clearResource (const int resource)
 Unassigns all of a resource, making it unallocated.

void remove (const int fromArea, const int resource, const double amount)
 Remove part of this resource (to the unallocated pool).

void remove (const int fromArea, const int resource)
 Remove all of this resource (to the unallocated pool).

void add (const int toArea, const int resource, const double amount)
 Assign some of this resource from unallocated pool to area toArea.

void add (const int toArea, const int resource)
 Assign whatever remains of this resource to area toArea.

void move (const int fromArea, const int toArea, const int resource)
 Moves an amount of a resource between areas.

void move (const int fromArea, const int toArea, const int resource, const double amount)
 Moves an amount of a resource between areas.


Protected Member Functions

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 with an assignment.

AreaAssignmentfirstArea (const int resource) const
 Returns the first AreaAssignment for a given resource.

AreaAssignmentnextArea (const int resource, const int currentArea) const
 Given a resource and area, returns next AreaAssignment for this resource.

ResourceAssignmentfirstRes (const int area) const
 Given an area, returns the first resource assigned there.

ResourceAssignmentnextRes (const int area, const int currentResource) const
 Given a resource & area, returns the next resource assigned there.


Friends

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

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

class ActiveAreasIterator
 So that the ActiveAreasIterator can access the first and next fnctns.


Constructor & Destructor Documentation

UserDef::UserDef const int  p_no_resources,
const int  p_no_areas,
const Array2D p_effectiveness,
const valarray< double >  p_available,
const valarray< double >  p_POC
 

Make a user-defined allocn: ie an empty allocn matrix of the correct size.

The from-scratch constructor. Makes a user-defined allocation: an empty allocation matrix of the right size. The user may fill this with the methods of UserDef.

UserDef::UserDef Allocation oldAllocation  ) 
 

Create a UserDef Allocation from an existing allocation (of another type).

Makes a user-defined allocation from an existing allocation (of any type). The user may then modify this allocation. 18apr03: crt simplified & debugged 01may03: crt even further simplified thx to njh


Member Function Documentation

void UserDef::add const int  toArea,
const int  resource
 

Assign whatever remains of this resource to area toArea.

Assign whatever remains (unallocated) of this resource to the requested area. Specifically, moves all of a resource from UNALLOCATED_AREA to another area.

Author: Andre Oboler (ASO)

void UserDef::add const int  toArea,
const int  resource,
const double  amount
 

Assign some of this resource from unallocated pool to area toArea.

Assign some of a resource to the specified area. Move a resource from the unallocated area to another area.

Author: Andre Oboler (ASO)

void UserDef::calcAllocation void   )  [virtual]
 

In UserDef, calcAllocation does nothing.

UserDef provides "calcAllocaton" just to keep the coding standard. Since the allocation "algorithm" for UserDef is wired through the keyboard (ie, it's the user), this routine does nothing.

Implements Allocation.

void UserDef::clearAll  ) 
 

Clears all existing allocations.

Clears all existing allocations, moving all resources in all areas back to the unallocated pool.

Author: Andre Oboler (ASO)

void UserDef::clearArea const int  area  ) 
 

Unassigns all resources in an area.

Unassigns all resources in area. Specifically, it moves all resources in area to UNALLOCATED_AREA.

Note: This code could use the first area and next area function but that adds extra overhead (in calling the functions) for no apparent again.

Author: Andre Oboler (ASO)

void UserDef::clearResource const int  resource  ) 
 

Unassigns all of a resource, making it unallocated.

Unassigns all of a resource.

Moves all instances of a resource to the unallocated area.

Author: Andre Oboler (ASO)

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

Returns the first AreaAssignment for a given resource.

Returns the first AreaAssignment (an area and a time) for a given resource.

If this resource is not assigned to any area, returns NULL.

If the resource is invalid, returns NULL.

Todo:
It should throw an exception if the resource is invalid.
Author: Andre Oboler (ASO)

Implements Allocation.

ActiveArea * UserDef::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.

Author: Andre Oboler (ASO)

Implements Allocation.

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

Given an area, returns the first resource assigned there.

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:
: Throw exception on invalid input
Author: Andre Oboler (ASO)

Todo:
Throw exception here.

Implements Allocation.

void UserDef::move const int  fromArea,
const int  toArea,
const int  resource,
const double  amount
 

Moves an amount of a resource between areas.

Moves amount of resource from fromArea to toArea. This is the basic movement code, all other movement code should call this to ensure the range checking only needs to be coded once and changed once if the specs change.

Author: Andre Oboler (ASO)

void UserDef::move const int  fromArea,
const int  toArea,
const int  resource
 

Moves an amount of a resource between areas.

Move all of this resource from fromArea to toArea.

Author: Andre Oboler (ASO)

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

Given a resource and area, returns next AreaAssignment for this resource.

Given a resource and an area, returns the next area (and time) that this resource is assigned to.

If there are no more areas or if the resource is not assigned to any more areas, returns NULL.

Todo:
: Throw exception on invalid input
Author: Andre Oboler (ASO)

Todo:
Throw exception here.

Implements Allocation.

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

Given an area number, returns the next area with an assignment.

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

If there is no following area has resources assigned to it, the function returns NULL.

NOTE: This function searches by AREA, that is, it searches through all resources in area N before trying area N+1. Etc.

Todo:
: Throw exception on invalid input.
Author: Andre Oboler (ASO)

Todo:
Throw exception here.

Implements Allocation.

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

Given a resource & area, returns the next resource assigned there.

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:
: Throw exception on invalid input.
Author: Andre Oboler (ASO)

Todo:
Throw exception here.

Implements Allocation.

void UserDef::remove const int  fromArea,
const int  resource
 

Remove all of this resource (to the unallocated pool).

Unassign all of a resource from the specified area. That is, move all of a resource from a specified area to UNALLOCATED_AREA

Author: Andre Oboler (ASO)

void UserDef::remove const int  fromArea,
const int  resource,
const double  amount
 

Remove part of this resource (to the unallocated pool).

Unassigns a specified amount of the specified resource. That is, moves some of a resource from an area back to the UNALLOCATED_AREA.

Author: Andre Oboler (ASO)


The documentation for this class was generated from the following files:
Generated on Tue Jul 29 03:09:42 2003 for SORAL by dOxygen 1.3.2
(SARBayes) Main Related Pages Class List Hierarchy Methods Files