FRAMES NO FRAMES

Class IloRandomSelector<,>

Definition file: ilsolver/iimmulti.h
Include file: <ilsolver/iim.h>
A selector which chooses objects randomly.

This class is a selector which randomly selects an object from a given container. The selection is unbiased, with each object having an equal probability of selection.

When you create a random selector, you must pass a visitor object. This visitor will traverse the container from which you are selecting objects. However, in the case where a default visitor exists for the container, you can omit the visitor as the default will be used. In addition to the default visitors available in Solver, IIM provides default visitors for IloSolutionPool and IloPoolProcArray.

The following code shows how to create a random selector and use it to build a pool processor:

    // Selects parents randomly
    IloPoolProc selector = IloSelectSolutions(
      env, IloRandomSelector<IloSolution, IloSolutionPool>(env)
    );
Note
An instance of IloRandomSelector which has been transformed into a pool processor using IloSelectSolutions will always draw its random numbers from the random number generator of the solver on which it is executing.

See Also:

Constructor Summary
public IloRandomSelector(IloEnv env, IloVisitor< IloObject, IloContainer > visitor=0)

Builds a random selector.

Method Summary
public IloVisitor< IloObject, IloContainer >getVisitor() const

Delivers the visitor used by the selector.

Inherited Methods from IloSelector
select
Constructor Detail

IloRandomSelector

public IloRandomSelector(IloEnv env, IloVisitor< IloObject, IloContainer > visitor=0)
Builds a random selector.

This constructor builds a random selector from an environment env and an optional visitor visitor. If no visitor is specified, a default visitor will be used if it exists. If no default visitor exists, an exception of type IloException is raised.


Method Detail

getVisitor

public IloVisitor< IloObject, IloContainer > getVisitor() const
Delivers the visitor used by the selector.

This member function returns the visitor passed at construction time or, if no visitor was passed, the default visitor for the container from which objects are being selected.