PROMETHEE Kernel. More...

#include <rpromkernel.h>

Inheritance diagram for RPromKernel:
[legend]
Collaboration diagram for RPromKernel:
[legend]

Public Member Functions

 RPromKernel (const char *name, size_t sol, size_t crit)
 
void ComputeEvalFunc (void)
 
virtual void ComputePrometheeII (void)
 
void AddCriterion (RPromCriterion *crit)
 
RPromCriterionGetCriterion (const RString &name) const
 
RPromCriterionGetCriterion (const size_t id) const
 
void AddSol (RPromSol *sol)
 
virtual RPromSolNewSol (void)
 
virtual RPromSolNewSol (const RString &name)
 
size_t GetNbSols (void) const
 
virtual void Assign (RPromSol *sol, RPromCriterion *crit, const double v)
 
virtual void Assign (const RString &sol, RPromCriterion *crit, const double v)
 
virtual void Assign (RPromSol *sol, const RString &crit, const double v)
 
virtual void Assign (const RString &sol, const RString &crit, const double v)
 
const RPromSolGetBestSol (void)
 
RCursor< RPromSolGetSols (void)
 
void CopySols (RContainer< RPromSol, false, false > &sols)
 
double GetMinFi (void)
 
double GetMaxFi (void)
 
size_t GetBestSolId (void)
 
void Clear (void)
 
void ClearSols (void)
 
void Print (bool normalized)
 
virtual ~RPromKernel (void)
 

Private Member Functions

void OrderSolutions (void)
 

Static Private Member Functions

static int sort_function_solutions (const void *a, const void *b)
 

Private Attributes

RString Name
 
RContainer< RPromSol, true, true > Solutions
 
RContainer< RPromSol, false,
false > 
OrderedSolutions
 
RContainer< RPromCriterion,
true, true > 
Criteria
 
bool MustReOrder
 

Detailed Description

PROMETHEE Kernel.

The RPromKernel provides a kernel to manage PROMETHEE session.

// Create kernel, solutions and criteria
RPromKernel Prom("Test",4,4);
RPromSol* Car1=Prom.NewSol("Car1");
RPromSol* Car2=Prom.NewSol("Car2");
RPromSol* Car3=Prom.NewSol("Car3");
RPromSol* Car4=Prom.NewSol("Car4");
RPromCriterion* Comfort;
Prom.AddCriterion(Price=new RPromLinearCriterion(RPromCriterion::Minimize,0.2,0.05,1.0,"Price"));
Prom.AddCriterion(Cons=new RPromLinearCriterion(RPromCriterion::Minimize,0.2,0.05,1.0,"Cons"));
Prom.AddCriterion(Comfort=new RPromLinearCriterion(RPromCriterion::Maximize,0.2,0.05,1.0,"Comfort"));
Prom.AddCriterion(Power=new RPromLinearCriterion(RPromCriterion::Maximize,0.2,0.05,1.0,"Power"));
// Assign Values
Prom.Assign(Car1,Price,8.75); Prom.Assign(Car1,Cons,6.2); Prom.Assign(Car1,Comfort,1.0); Prom.Assign(Car1,Power,30);
Prom.Assign(Car2,Price,13.75); Prom.Assign(Car2,Cons,7.5); Prom.Assign(Car2,Comfort,1.0); Prom.Assign(Car2,Power,50);
Prom.Assign(Car3,Price,25); Prom.Assign(Car3,Cons,8); Prom.Assign(Car3,Comfort,3.0); Prom.Assign(Car3,Power,80);
Prom.Assign(Car4,Price,62.5); Prom.Assign(Car4,Cons,20); Prom.Assign(Car4,Comfort,2.0); Prom.Assign(Car4,Power,120);
// Compute Prom
Prom.ComputePrometheeII();
// Print Fi
RCursor<RPromSol> Res(Prom.GetSols());
cout<<"Sol\tFiPlus\t\tFiMinus\t\tFi"<<endl;
cout.precision(3);
for(Res.Start();!Res.End();Res.Next())
cout<<"Car"<<Res()->GetId()+1<<"\t"<<Res()->GetFiPlus()<<"\t\t"<<Res()->GetFiMinus()<<"\t\t"<<Res()->GetFi()<<endl;

Constructor & Destructor Documentation

RPromKernel ( const char *  name,
size_t  sol,
size_t  crit 
)

Construct the kernel.

Parameters
nameThe name of the kernel.
solInitial maximal number of solutions.
critInitial maximal number of criteria.
virtual ~RPromKernel ( void  )
virtual

Destruct the kernel.

Member Function Documentation

void ComputeEvalFunc ( void  )

Compute the evaluation functions for the solutions.

virtual void ComputePrometheeII ( void  )
virtual

Calculate PROMETHEE II.

void AddCriterion ( RPromCriterion crit)

Add a new criterion.

Parameters
critPointer to the new criterion.
RPromCriterion* GetCriterion ( const RString name) const
Returns
a pointer to a given criterion.
Parameters
nameName of the criterion.
RPromCriterion* GetCriterion ( const size_t  id) const
Returns
a pointer to a given criterion.
Parameters
idIdentifier of the criterion.
void AddSol ( RPromSol sol)

Add a solution to the PROMETHEE kernel. Each solution must have an unique identifier. A way to manage that is to assign to each solution added an identifier equals to GetNbSols().

Parameters
solSolution to add.
virtual RPromSol* NewSol ( void  )
virtual

Create a new solution.

virtual RPromSol* NewSol ( const RString name)
virtual

Create a new solution.

Parameters
nameName of the solution.
size_t GetNbSols ( void  ) const
Returns
the number of solutions managed by the kernel.
virtual void Assign ( RPromSol sol,
RPromCriterion crit,
const double  v 
)
virtual

Assign a value to a criterion.

Parameters
solPointer to the solution.
critPointer to the criterion.
vValue.
virtual void Assign ( const RString sol,
RPromCriterion crit,
const double  v 
)
virtual

Assign a value to a criterion.

Parameters
solName of to the solution.
critPointer to the criterion.
vValue.
virtual void Assign ( RPromSol sol,
const RString crit,
const double  v 
)
virtual

Assign a value to a criterion.

Parameters
solPointer to the solution.
critName of the criterion.
vValue.
virtual void Assign ( const RString sol,
const RString crit,
const double  v 
)
virtual

Assign a value to a criterion.

Parameters
solName of the solution.
critName of the criterion.
vValue.
static int sort_function_solutions ( const void *  a,
const void *  b 
)
staticprivate

Function used to sort the solutions by fit.

Parameters
aPointer to the first solution.
bPointer to the second solution.
void OrderSolutions ( void  )
private

Order the solutions by descending order of their fitness.

const RPromSol* GetBestSol ( void  )
Returns
the best solution.
RCursor<RPromSol> GetSols ( void  )
Returns
a cursor over the solutions ordered descending by their fitness.
void CopySols ( RContainer< RPromSol, false, false > &  sols)

Copy the solutions ordered descending by their fitness into a container.

Parameters
solsContainer holding the results.
double GetMinFi ( void  )
Returns
the Fi of the worst solution.
double GetMaxFi ( void  )
Returns
the Fi of the best solution.
size_t GetBestSolId ( void  )

Return the best solution identifier.

void Clear ( void  )

Clear the kernel.

void ClearSols ( void  )

Clear the solutions of the kernel.

void Print ( bool  normalized)

Print the solutions ordered on screen.

Parameters
normalizedShow the values normalized or not.

Member Data Documentation

RString Name
private

The name of the kernel.

RContainer<RPromSol,true,true> Solutions
private

Solutions.

RContainer<RPromSol,false,false> OrderedSolutions
private

Solutions ordered by fitness.

RContainer<RPromCriterion,true,true> Criteria
private

Criteria.

bool MustReOrder
private

Look if the solution must be reordered (for example after a computing).