Class ConditionalParameter<T>
- Type Parameters:
T- the type of the parent parameter's value that will be evaluated by the condition
This class is designed to model conditional parameter relationships commonly found in metaheuristic algorithm configurations, where certain parameters are only relevant when a parent parameter takes specific values. For example, archive-related parameters might only be applicable when the algorithm variant is set to use an external archive.
The conditional relationship is defined through a Predicate that evaluates the parent
parameter's value. When the predicate returns true, the associated parameter becomes
active and should be considered during parameter space exploration or algorithm configuration.
Example usage in YAML configuration:
algorithmResult:
type: categorical
values:
population: {}
externalArchive:
conditionalParameters:
populationSizeWithArchive:
type: integer
range: [10, 200]
In this example, populationSizeWithArchive is a conditional parameter that only
becomes active when algorithmResult equals "externalArchive".
This class is immutable and thread-safe once constructed.
- Since:
- 1.0
- Version:
- 1.0
- Author:
- [Author Name]
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalParameter(Predicate<T> condition, Parameter<?> parameter, String description) Constructs a new ConditionalParameter with the specified condition, parameter, and description. -
Method Summary
Modifier and TypeMethodDescriptionReturns the predicate condition associated with this conditional parameter.Returns the human-readable description of this conditional parameter's condition.Parameter<?> Returns the parameter that becomes active when the condition is satisfied.toString()Returns a string representation of this conditional parameter.
-
Constructor Details
-
ConditionalParameter
Constructs a new ConditionalParameter with the specified condition, parameter, and description.All parameters are required and must not be null. The condition will be used to determine when the associated parameter should be active during parameter space processing or algorithm configuration.
- Parameters:
condition- the predicate that determines when the parameter is active; must not be nullparameter- the parameter to be activated when the condition is met; must not be nulldescription- a textual description of the condition for documentation and debugging purposes; must not be null- Throws:
IllegalArgumentException- if any parameter is null
-
-
Method Details
-
condition
-
parameter
Returns the parameter that becomes active when the condition is satisfied.This parameter should only be considered during parameter space exploration or algorithm configuration when the associated condition evaluates to true.
- Returns:
- the conditional parameter; never null
-
description
Returns the human-readable description of this conditional parameter's condition.The description provides context about when this parameter becomes active and is useful for documentation, debugging, and user interfaces.
- Returns:
- the condition description; never null
-
toString
Returns a string representation of this conditional parameter.The string includes both the condition description and the parameter name for easy identification during debugging and logging.
-