tom.library.sl
Class Pselect
java.lang.Object
tom.library.sl.AbstractStrategy
tom.library.sl.Pselect
- All Implemented Interfaces:
- Strategy, Visitable
public class Pselect
- extends AbstractStrategy
Pselect(p,q,v1,v2) = v1
with probability p/q
Pselect(p,q,v1,v2) = v2
with probability 1-(p/q)
Visitor combinator with a probability and two visitor arguments,
that select a visitor according to the probability p/q
The strategy fails if the selected strategy fails
Note that any side-effects of v1 are not undone when it fails.
Field Summary |
static int |
FIRST
|
static int |
THEN
|
Method Summary |
int |
getP()
|
int |
getQ()
|
int |
visit()
Visits the current subject (found in the environment)
and place its result in the environment. |
Visitable |
visitLight(Visitable visitable)
Visits the subject any in a light way (without environment) |
Methods inherited from class tom.library.sl.AbstractStrategy |
accept, getChildAt, getChildCount, getChildren, getEnvironment, getRoot, getSubject, init, init, initSubterm, initSubterm, initSubterm, initSubterm, initSubterm, setChildAt, setChildren, setEnvironment, setRoot, setSubject, visit, visit |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FIRST
public static final int FIRST
- See Also:
- Constant Field Values
THEN
public static final int THEN
- See Also:
- Constant Field Values
Pselect
public Pselect(int p,
int q,
Strategy first,
Strategy then)
getP
public int getP()
getQ
public int getQ()
visitLight
public Visitable visitLight(Visitable visitable)
throws VisitFailure
- Description copied from interface:
Strategy
- Visits the subject any in a light way (without environment)
- Parameters:
visitable
- the subject to visit.
- Throws:
VisitFailure
- in case of failure.
visit
public int visit()
- Description copied from interface:
Strategy
- Visits the current subject (found in the environment)
and place its result in the environment.
Sets the environment flag to Environment.FAILURE in case of failure