Class FixedElapsedTime
- java.lang.Object
-
- org.apache.commons.math4.legacy.genetics.FixedElapsedTime
-
- All Implemented Interfaces:
StoppingCondition
public class FixedElapsedTime extends Object implements StoppingCondition
Stops after a fixed amount of time has elapsed.The first time
isSatisfied(Population)
is invoked, the end time of the evolution is determined based on the providedmaxTime
value. Once the elapsed time reaches the configuredmaxTime
value,isSatisfied(Population)
returns true.- Since:
- 3.1
-
-
Constructor Summary
Constructors Constructor Description FixedElapsedTime(long maxTime)
Create a newFixedElapsedTime
instance.FixedElapsedTime(long maxTime, TimeUnit unit)
Create a newFixedElapsedTime
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isSatisfied(Population population)
Determine whether or not the maximum allowed time has passed.
-
-
-
Constructor Detail
-
FixedElapsedTime
public FixedElapsedTime(long maxTime) throws NumberIsTooSmallException
Create a newFixedElapsedTime
instance.- Parameters:
maxTime
- maximum number of seconds generations are allowed to evolve- Throws:
NumberIsTooSmallException
- if the provided time is < 0
-
FixedElapsedTime
public FixedElapsedTime(long maxTime, TimeUnit unit) throws NumberIsTooSmallException
Create a newFixedElapsedTime
instance.- Parameters:
maxTime
- maximum time generations are allowed to evolveunit
-TimeUnit
of the maxTime argument- Throws:
NumberIsTooSmallException
- if the provided time is < 0
-
-
Method Detail
-
isSatisfied
public boolean isSatisfied(Population population)
Determine whether or not the maximum allowed time has passed. The termination time is determined after the first generation.- Specified by:
isSatisfied
in interfaceStoppingCondition
- Parameters:
population
- ignored (no impact on result)- Returns:
true
IFF the maximum allowed time period has elapsed
-
-