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

TestBed.cpp File Reference


Detailed Description

This is a testbed to check SORAL on several known cases.

We have defined several test cases to check some boundary conditions and proper numerical results. This file runs SORAL over those cases (9 at the time of writing this header).

Right now the tests are hardcoded into main(). Eventually it should probably read them from a file, but that's a low priority change. The main goal is to have quick automated testing so we can see if our modifications have broken anything numerically.

Variables: p = Initial Probability Map w = Effectiveness vector T = Endurance vector

Version History

 *-----+----------+-----+-----------------------------------------------------
 * Who |   When   | Ver | What
 *-----+----------+-----+-----------------------------------------------------
 * ASO | 18jan03  |  1  | Created
 *-----+----------+-----+-----------------------------------------------------
 * crt |  7apr03  |  2  | Put in full test suite.
 *-----+----------+-----+-----------------------------------------------------
 * crt |  1may03  |  3  | Changed for itors returning objects not pointers
 *-----+----------+-----+-----------------------------------------------------
 * 

Definition in file TestBed.cpp.

#include <iostream>
#include <vector>
#include <math.h>
#include <limits>
#include "containr.h"
#include "Allocatn.h"
#include "Array2D.h"
#include "Alloc-W.h"
#include "Alloc-CC.h"
#include "UserDef.h"

Include dependency graph for TestBed.cpp:

Include dependency graph

Go to the source code of this file.

Enumerations

enum  allocationType { CHARNES, WASHBURN }
 Standard allocation types for easy reference.


Functions

void printAssignments (const Allocation &theAllocation)
 Prints the assignments in an Allocation.

bool testCase (const allocationType whichAllocation, const int caseNum, const int num_areas, const int num_resources, const valarray< double > poc, const valarray< double > endurance, const Array2D &eff, const Array2D &answer)
 Takes a case, creates an allocation, and compares the answer.

bool matches (const Allocation &theAlloc, const Array2D &answer, const int numAreas, const int numResources)
 Determines if an allocation approximately matches an answer.

int main (int argc, int argv[])

Variables

char * allocationNames [] = {"Charnes Cooper", "Washburn"}
 Standard strings for the allocation names, to use with enum.


Function Documentation

int main int    argc,
int    argv[]
 

POC

Endurance (time, hence T)

Effectiveness (a function of sweep width, hence w)

Answer

Return standard values in accord with. http://www.itworld.com/nl/lnx_tip/08092002/

Definition at line 92 of file TestBed.cpp.

References testCase().

bool matches const Allocation   theAllocation,
const Array2D   answer,
const int    numAreas,
const int    numResources
 

Determines if an allocation approximately matches an answer.

Takes a calculated allocation and compares it to a known correct answer to see if they match within some tolerance. Because Allocation does not provide getNumAreas and getNumResources, it must also be passed those values.

We could avoid those values by using the ActiveAreasIterator, but that could miss some areas. We need to check that all inactive areas should have been so. That means we can't use ActiveAreasIterator, which, of course, skips inactive areas.

Defines its own numerical tolerance tol at some intuitively appealing level, rather than using a more rigorous level of comparison.

Todo:
Use a more rigorous tol.
crt 7apr03

Definition at line 516 of file TestBed.cpp.

References ResourceIterator::atEnd(), ResourceAssignment::getResourceNum(), and ResourceAssignment::getTime().

Referenced by testCase().

void printAssignments const Allocation   theAllocation
 

Prints the assignments in an Allocation.

Prints all and only the assignments in an Allocation, by using the standard iterator paradigm: start with ActiveAreasIterator and proceed from there.

Since this program now compares answers numerically, and only prints the offending allocations, maybe we can remove this function, which now lives usefully in sample.cpp?

Todo:
Remove printAssignments from here?
Author: Andre Oboler

bool testCase const allocationType    whichAllocation,
const int    caseNum,
const int    num_areas,
const int    num_resources,
const valarray< double >    poc,
const valarray< double >    endurance,
const Array2D   effectiveness,
const Array2D   answer
 

Takes a case, creates an allocation, and compares the answer.

Takes a case, defined by its essential variables, creates an allocation of the requested type, and then checks that the results of that allocation match the answer supplied by the case.

Relies on the enum allocationType for choosing which allocation to run.

Calls matches to check for approximate match, to a tolerance defined in matches.

crt 7apr03

Definition at line 433 of file TestBed.cpp.

References UserDef::add(), allocationNames, matches(), and UserDef::remove().

Referenced by main().


Generated on Fri May 9 17:04:21 2003 for SORAL by dOxygen 1.3-rc3
(SARBayes) Main Related Pages Class List Hierarchy Methods Files