Generic Placement Heuristic class. More...

#include <rplacementheuristic.h>

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

Public Member Functions

 RPlacementHeuristic (size_t maxobjs, bool calc, bool use, RRandom &r, RParamStruct *dist, RParamStruct *area, bool firstrandom, bool ori)
 
virtual void Init (RProblem2D *prob, RLayout *layout, RGrid *grid)
 
RGeoInfoNextObject (void)
 
void Run (RProblem2D *prob, RLayout *layout, RGrid *grid)
 
void AddValidPosition (RPoint &pos)
 
virtual void PostRun (void)
 
RRect GetResult (void)
 
double GetDistances (void)
 
bool IsEnd (void)
 
size_t GetNbObjsOk (void)
 
RFreePolygonsGetFreePolygons (void)
 
RLayoutGetLayout (void) const
 
virtual ~RPlacementHeuristic (void)
 

Protected Member Functions

virtual RGeoInfoSelectNextObject (void)
 
virtual void SearchValidPositions (RGeoInfo *info)=0
 
virtual void PostPlace (RGeoInfo *info, const RPoint &pos)=0
 

Protected Attributes

RRandomRandom
 
RGridGrid
 
RLayoutLayout
 
RSize Limits
 
bool WeightedDistances
 
size_t NbObjs
 
size_t NbObjsOk
 
RRect Result
 
double Distances
 
RGeoInfo ** Order
 
RGeoInfoCurInfo
 
RFreePolygons Free
 
bool CalcFree
 
bool UseFree
 
bool AllOri
 
RContainer< ObjectPos, true,
false > 
ValidPos
 
RPromKernel Prom
 
RPromCriterionDist
 
const RParamDistParams
 
RPromCriterionArea
 
const RParamAreaParams
 
bool FirstRandom
 

Detailed Description

Generic Placement Heuristic class.

The RPlacementHeuristic class provides an abstract class for placement heuristics.

Constructor & Destructor Documentation

RPlacementHeuristic ( size_t  maxobjs,
bool  calc,
bool  use,
RRandom r,
RParamStruct dist,
RParamStruct area,
bool  firstrandom,
bool  ori 
)

Construct the placement heuristic.

Parameters
maxobjsThe maximum objects to placed fore this object.
calcMust free polygons be calculated.
useMust free polygons be used.
rThe random generator to use.
distDistance criteria parameters.
areaArea criteria parameters.
firstrandomMust the first object be placed randomly?
oriMust all orientation be tested.
virtual ~RPlacementHeuristic ( void  )
virtual

Destruct the placement heuristic.

Member Function Documentation

virtual void Init ( RProblem2D prob,
RLayout layout,
RGrid grid 
)
virtual

Initialise the heuristic. The method chooses all the objects to place. In particular, if an object is associated to an aggregator, it is not placed and the method supposes that the aggregator itself is to placed.

Parameters
probThe problem.
layoutLayout.
gridPointer to the grid.

Reimplemented in RPlacementEdge, RPlacementCenter, and RPlacementBottomLeft.

virtual RGeoInfo* SelectNextObject ( void  )
protectedvirtual

Select the next object to place. By default, the method chooses the first object randomly. Then, the next objects are chosen according to their connections (the most connection) with those already placed.

Returns
the geometric information of the object to place.
virtual void SearchValidPositions ( RGeoInfo info)
protectedpure virtual

Calculate all the possible positions to place a given object. The method must register these valid positions with the 'AddValidPosition' method.

Parameters
infoGeometric information representing the object placed.

Implemented in RPlacementEdge, RPlacementCenter, and RPlacementBottomLeft.

virtual void PostPlace ( RGeoInfo info,
const RPoint pos 
)
protectedpure virtual

This method is called each time a given object is placed at a given position. It can be used to make some specific computational updates. By default, the method does nothing.

This method must update Result, the rectangle bounding all placed objects.

Parameters
infoGeometric information representing the object placed.
posThe position where it is placed.

Implemented in RPlacementEdge, RPlacementCenter, and RPlacementBottomLeft.

RGeoInfo* NextObject ( void  )

Select and place an unassigned object. The steps followed by this method are:

  1. Select an object with the 'SelectNextObject' method.
  2. Look if a free polygon can hold the object (if managed).
  3. If not, for every possible orientation of the object, the method 'SearchValidPositions' is called to find all valid positions.
  4. If multiple positions are possible, PROMETHEE is used to select the best one : the position minimizing the total area occupied and the total distance of the connections.
  5. The object is placed and 'PostPlace' is called.
  6. If free polygons are managed, update them.
    Returns
    the geometric information of the object placed.
void Run ( RProblem2D prob,
RLayout layout,
RGrid grid 
)

Run the heuristic.

Parameters
probThe problem.
layoutLayout.
gridGrid.
void AddValidPosition ( RPoint pos)

Add a valid position fot the current geometric information to place.

Parameters
posPosition to be a valid.
virtual void PostRun ( void  )
virtual

Do some operations after the run.

Reimplemented in RPlacementCenter.

RRect GetResult ( void  )

Return the bound rectangle containing all the objects.

double GetDistances ( void  )

Return the sum of the distances of all the connections.

bool IsEnd ( void  )

Return true if all the objects are placed.

size_t GetNbObjsOk ( void  )

Return the number of objects placed.

RFreePolygons* GetFreePolygons ( void  )

Return a pointer to all the free polygons.

RLayout* GetLayout ( void  ) const

Get a pointer to the current (or the last treated) layout.

Member Data Documentation

RRandom& Random
protected

The random number generator to use

RGrid* Grid
protected

The grid used for the placement.

RLayout* Layout
protected

The layout.

RSize Limits
protected

The limits for the placement.

bool WeightedDistances
protected

Should the distances computed be weighted?.

size_t NbObjs
protected

Total number of objects to place.

size_t NbObjsOk
protected

Number of objects already placed.

RRect Result
protected

The bounding rectangle of the resulting placement. It must be updated by the inheriting classes.

double Distances
protected

The sum of the connections distances.

RGeoInfo** Order
protected

Order in which the objects are to be treated.

RGeoInfo* CurInfo
protected

Geometric information of the current object to place.

RFreePolygons Free
protected

Free Polygons resulting of the placement.

bool CalcFree
protected

Calculations of free polygons.

bool UseFree
protected

Use of free polygons.

bool AllOri
protected

All possible orientation must be tested.

RContainer<ObjectPos,true,false> ValidPos
protected

Valid positions.

RPromKernel Prom
protected

PROMERHEE kernel.

RPromCriterion* Dist
protected

PROMETHEE distance criterion.

const RParam* DistParams
protected

PROMETHEE Parameters for the distance.

RPromCriterion* Area
protected

PROMETHEE area criterion.

const RParam* AreaParams
protected

PROMETHEE Parameters for the area.

bool FirstRandom
protected

Is the first object randomly chosen?