Class ProductionOptimizer.OptimizationConfig
- Enclosing class:
ProductionOptimizer
This class uses a fluent API pattern for configuring optimization parameters. All setter
methods return this to enable method chaining.
Configuration Categories
- Search bounds -
lowerBound,upperBounddefine the search range - Convergence -
tolerance,maxIterationscontrol termination - Algorithm -
searchModeselects the optimization algorithm - Utilization - equipment capacity limits and margins
- Parallelization -
parallelEvaluations,parallelThreads - Pareto -
paretoGridSizefor multi-objective optimization - PSO parameters - swarm size, inertia, cognitive/social weights
Java Example
OptimizationConfig config = new OptimizationConfig(50000.0, 200000.0).tolerance(100.0)
.maxIterations(50).searchMode(SearchMode.GOLDEN_SECTION_SCORE).rateUnit("kg/hr")
.utilizationLimitForName("compressor1", 0.90).parallelEvaluations(true).parallelThreads(4);
Python Example (via JPype)
config = OptimizationConfig(50000.0, 200000.0) \
.tolerance(100.0) \
.maxIterations(50) \
.searchMode(SearchMode.GOLDEN_SECTION_SCORE)
- Version:
- 1.0
- Author:
- NeqSim Development Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleprivate final Map<String, ProductionOptimizer.CapacityRange> private final Map<Class<?>, ProductionOptimizer.CapacityRange> private doubleprivate final Map<String, ProductionOptimizer.CapacityRule> private final Map<Class<?>, ProductionOptimizer.CapacityRule> private doubleprivate doubleprivate doubleprivate doubleprivate booleanprivate final List<ProductionOptimizer.EquipmentConstraintRule> private doubleprivate double[]private doubleprivate intprivate intprivate booleanprivate intprivate intprivate longprivate Stringprivate booleanprivate ProductionOptimizer.SearchModeprivate doubleprivate intprivate intprivate doubleprivate doubleprivate booleanprivate double -
Constructor Summary
ConstructorsConstructorDescriptionOptimizationConfig(double lowerBound, double upperBound) Constructs a configuration with specified search bounds. -
Method Summary
Modifier and TypeMethodDescriptioncapacityPercentile(double capacityPercentile) capacityRangeForName(String equipmentName, ProductionOptimizer.CapacityRange range) capacityRangeForType(Class<?> type, ProductionOptimizer.CapacityRange range) capacityRangeSpreadFraction(double capacityRangeSpreadFraction) capacityRuleForName(String equipmentName, ProductionOptimizer.CapacityRule rule) capacityRuleForType(Class<?> type, ProductionOptimizer.CapacityRule rule) capacityUncertaintyFraction(double capacityUncertaintyFraction) cognitiveWeight(double cognitiveWeight) columnFsFactorLimit(double columnFsFactorLimit) Creates a Random instance based on the seed configuration.defaultUtilizationLimit(double defaultUtilizationLimit) Sets the default equipment utilization limit.enableCaching(boolean enableCaching) doubledoubledoubledoubledoubledoubleGets the default equipment utilization limit.doubledouble[]Gets the initial guess for warm starting.doubleGets the lower bound for the search range.intGets the maximum cache size.intintReturns the number of threads for parallel evaluations.intReturns the grid size for Pareto front generation.longGets the random seed.Gets the rate unit for the optimization.Gets the search mode (algorithm) for the optimization.doubleintGets the stagnation iteration limit.intdoubleGets the convergence tolerance.doubleGets the upper bound for the search range.doubleinertiaWeight(double inertiaWeight) initialGuess(double[] guess) Sets an initial guess for warm starting the optimization.booleanReturns whether parallel evaluations are enabled.booleanGets whether invalid simulations are rejected.booleanReturns whether a fixed seed is used.maxCacheSize(int size) Sets the maximum cache size for evaluation caching.maxIterations(int maxIterations) Sets the maximum number of iterations.parallelEvaluations(boolean parallel) Enables parallel evaluation of candidates in PSO and scenario optimization.parallelThreads(int threads) Sets the number of threads for parallel evaluations.paretoGridSize(int gridSize) Sets the grid size for Pareto front generation.randomSeed(long seed) Sets the random seed for stochastic algorithms (PSO, Nelder-Mead initialization).rejectInvalidSimulations(boolean reject) Sets whether to reject simulation results that are physically invalid.socialWeight(double socialWeight) stagnationIterations(int iterations) Sets the number of iterations without improvement before early termination.swarmSize(int swarmSize) tolerance(double tolerance) Sets the convergence tolerance.useFixedSeed(boolean fixed) Controls whether a fixed or time-based random seed is used.utilizationLimitForName(String equipmentName, double limit) utilizationLimitForType(Class<?> type, double limit) utilizationMarginFraction(double utilizationMarginFraction) voidvalidate()Validates this configuration and throws if invalid.
-
Field Details
-
lowerBound
private double lowerBound -
upperBound
private double upperBound -
tolerance
private double tolerance -
maxIterations
private int maxIterations -
rateUnit
-
defaultUtilizationLimit
private double defaultUtilizationLimit -
utilizationMarginFraction
private double utilizationMarginFraction -
capacityUncertaintyFraction
private double capacityUncertaintyFraction -
capacityPercentile
private double capacityPercentile -
capacityRangeSpreadFraction
private double capacityRangeSpreadFraction -
searchMode
-
enableCaching
private boolean enableCaching -
rejectInvalidSimulations
private boolean rejectInvalidSimulations -
parallelEvaluations
private boolean parallelEvaluations -
parallelThreads
private int parallelThreads -
paretoGridSize
private int paretoGridSize -
swarmSize
private int swarmSize -
inertiaWeight
private double inertiaWeight -
cognitiveWeight
private double cognitiveWeight -
columnFsFactorLimit
private double columnFsFactorLimit -
stagnationIterations
private int stagnationIterations -
maxCacheSize
private int maxCacheSize -
randomSeed
private long randomSeed -
useFixedSeed
private boolean useFixedSeed -
initialGuess
private double[] initialGuess -
utilizationLimitsByName
-
utilizationLimitsByType
-
capacityRulesByName
-
capacityRulesByType
-
capacityRangesByName
-
capacityRangesByType
-
equipmentConstraintRules
-
-
Constructor Details
-
OptimizationConfig
public OptimizationConfig(double lowerBound, double upperBound) Constructs a configuration with specified search bounds.- Parameters:
lowerBound- minimum value for the decision variable (e.g., min flow rate)upperBound- maximum value for the decision variable (e.g., max flow rate)
-
-
Method Details
-
tolerance
Sets the convergence tolerance.The optimizer terminates when the change in the decision variable between iterations is less than this tolerance.
- Parameters:
tolerance- convergence tolerance in the same units as the decision variable- Returns:
- this config for method chaining
-
maxIterations
Sets the maximum number of iterations.- Parameters:
maxIterations- maximum iterations before termination (default: 30)- Returns:
- this config for method chaining
-
rejectInvalidSimulations
Sets whether to reject simulation results that are physically invalid.When enabled (default), the optimizer will mark operating points as infeasible if any equipment reports invalid simulation results (e.g., negative power in compressors, NaN values, etc.).
- Parameters:
reject- true to reject invalid simulations- Returns:
- this config for method chaining
-
isRejectInvalidSimulations
public boolean isRejectInvalidSimulations()Gets whether invalid simulations are rejected.- Returns:
- true if invalid simulations are rejected
-
getMaxIterations
public int getMaxIterations() -
getUtilizationMarginFraction
public double getUtilizationMarginFraction() -
getCapacityUncertaintyFraction
public double getCapacityUncertaintyFraction() -
getCapacityPercentile
public double getCapacityPercentile() -
getCapacityRangeSpreadFraction
public double getCapacityRangeSpreadFraction() -
rateUnit
-
searchMode
-
swarmSize
-
inertiaWeight
-
cognitiveWeight
-
socialWeight
-
randomSeed
Sets the random seed for stochastic algorithms (PSO, Nelder-Mead initialization).A fixed seed (default: 0) ensures reproducible results across runs. Set
useFixedSeed(false)to use a time-based seed for diversified parallel runs.- Parameters:
seed- the random seed value- Returns:
- this config for method chaining
-
useFixedSeed
Controls whether a fixed or time-based random seed is used.When
false, usesSystem.nanoTime()as the seed, providing different exploration paths on each run. Whentrue(default), uses the seed set byrandomSeed(long)for reproducibility.- Parameters:
fixed- true for fixed seed (reproducible), false for time-based seed (diverse)- Returns:
- this config for method chaining
-
createRandom
Creates a Random instance based on the seed configuration.- Returns:
- a new Random instance
-
getRandomSeed
public long getRandomSeed()Gets the random seed.- Returns:
- the random seed value
-
isUseFixedSeed
public boolean isUseFixedSeed()Returns whether a fixed seed is used.- Returns:
- true if using fixed seed
-
columnFsFactorLimit
-
defaultUtilizationLimit
public ProductionOptimizer.OptimizationConfig defaultUtilizationLimit(double defaultUtilizationLimit) Sets the default equipment utilization limit.- Parameters:
defaultUtilizationLimit- the utilization limit (0.0 to 1.0)- Returns:
- this config for method chaining
-
getDefaultUtilizationLimit
public double getDefaultUtilizationLimit()Gets the default equipment utilization limit.- Returns:
- the utilization limit (0.0 to 1.0)
-
utilizationMarginFraction
public ProductionOptimizer.OptimizationConfig utilizationMarginFraction(double utilizationMarginFraction) -
capacityUncertaintyFraction
public ProductionOptimizer.OptimizationConfig capacityUncertaintyFraction(double capacityUncertaintyFraction) -
capacityPercentile
-
capacityRangeSpreadFraction
public ProductionOptimizer.OptimizationConfig capacityRangeSpreadFraction(double capacityRangeSpreadFraction) -
utilizationLimitForName
public ProductionOptimizer.OptimizationConfig utilizationLimitForName(String equipmentName, double limit) -
utilizationLimitForType
-
capacityRuleForName
public ProductionOptimizer.OptimizationConfig capacityRuleForName(String equipmentName, ProductionOptimizer.CapacityRule rule) -
capacityRuleForType
public ProductionOptimizer.OptimizationConfig capacityRuleForType(Class<?> type, ProductionOptimizer.CapacityRule rule) -
capacityRangeForName
public ProductionOptimizer.OptimizationConfig capacityRangeForName(String equipmentName, ProductionOptimizer.CapacityRange range) -
capacityRangeForType
public ProductionOptimizer.OptimizationConfig capacityRangeForType(Class<?> type, ProductionOptimizer.CapacityRange range) -
equipmentConstraintRule
public ProductionOptimizer.OptimizationConfig equipmentConstraintRule(ProductionOptimizer.EquipmentConstraintRule rule) -
enableCaching
-
parallelEvaluations
Enables parallel evaluation of candidates in PSO and scenario optimization.When enabled, particle swarm optimization evaluates particles in parallel using a thread pool, and scenario optimization runs scenarios concurrently.
- Parameters:
parallel- true to enable parallel evaluations- Returns:
- this config for method chaining
-
parallelThreads
Sets the number of threads for parallel evaluations.- Parameters:
threads- number of threads (default: available processors)- Returns:
- this config for method chaining
-
paretoGridSize
Sets the grid size for Pareto front generation.For weighted-sum Pareto optimization, this determines how many weight combinations are evaluated. A grid size of 11 generates weights: 0.0, 0.1, 0.2, ..., 1.0.
- Parameters:
gridSize- number of weight points per objective (default: 11)- Returns:
- this config for method chaining
-
isParallelEvaluations
public boolean isParallelEvaluations()Returns whether parallel evaluations are enabled.- Returns:
- true if parallel evaluations are enabled
-
getParallelThreads
public int getParallelThreads()Returns the number of threads for parallel evaluations.- Returns:
- number of threads
-
getParetoGridSize
public int getParetoGridSize()Returns the grid size for Pareto front generation.- Returns:
- Pareto grid size
-
getSwarmSize
public int getSwarmSize() -
getInertiaWeight
public double getInertiaWeight() -
getCognitiveWeight
public double getCognitiveWeight() -
getSocialWeight
public double getSocialWeight() -
getColumnFsFactorLimit
public double getColumnFsFactorLimit() -
getRateUnit
-
getLowerBound
public double getLowerBound()Gets the lower bound for the search range.- Returns:
- the lower bound
-
getUpperBound
public double getUpperBound()Gets the upper bound for the search range.- Returns:
- the upper bound
-
getSearchMode
Gets the search mode (algorithm) for the optimization.- Returns:
- the search mode
-
getTolerance
public double getTolerance()Gets the convergence tolerance.- Returns:
- the tolerance value
-
stagnationIterations
Sets the number of iterations without improvement before early termination.Stagnation detection prevents wasted iterations when the optimizer is stuck. If the best score doesn't improve for this many consecutive iterations, the search terminates early.
- Parameters:
iterations- number of stagnation iterations (default: 5, 0 to disable)- Returns:
- this config for method chaining
-
getStagnationIterations
public int getStagnationIterations()Gets the stagnation iteration limit.- Returns:
- number of iterations without improvement before termination
-
maxCacheSize
Sets the maximum cache size for evaluation caching.Limits memory usage by evicting oldest entries when cache exceeds this size.
- Parameters:
size- maximum number of cached evaluations (default: 1000)- Returns:
- this config for method chaining
-
getMaxCacheSize
public int getMaxCacheSize()Gets the maximum cache size.- Returns:
- maximum number of cached evaluations
-
initialGuess
Sets an initial guess for warm starting the optimization.For single-variable optimization, provide a single-element array. For multi-variable optimization, provide values matching the variable order.
- Parameters:
guess- initial values for decision variables (null to disable)- Returns:
- this config for method chaining
-
getInitialGuess
public double[] getInitialGuess()Gets the initial guess for warm starting.- Returns:
- initial guess array or null if not set
-
validate
public void validate()Validates this configuration and throws if invalid.- Throws:
IllegalArgumentException- if configuration is invalid
-
socialWeight