Class ProductionOptimizer.OptimizationConfig

java.lang.Object
neqsim.process.util.optimizer.ProductionOptimizer.OptimizationConfig
Enclosing class:
ProductionOptimizer

public static final class ProductionOptimizer.OptimizationConfig extends Object
Builder-style configuration for the production optimizer.

This class uses a fluent API pattern for configuring optimization parameters. All setter methods return this to enable method chaining.

Configuration Categories

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 Details

    • lowerBound

      private double lowerBound
    • upperBound

      private double upperBound
    • tolerance

      private double tolerance
    • maxIterations

      private int maxIterations
    • rateUnit

      private String rateUnit
    • defaultUtilizationLimit

      private double defaultUtilizationLimit
    • utilizationMarginFraction

      private double utilizationMarginFraction
    • capacityUncertaintyFraction

      private double capacityUncertaintyFraction
    • capacityPercentile

      private double capacityPercentile
    • capacityRangeSpreadFraction

      private double capacityRangeSpreadFraction
    • searchMode

      private ProductionOptimizer.SearchMode 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
    • socialWeight

      private double socialWeight
    • 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

      private final Map<String,Double> utilizationLimitsByName
    • utilizationLimitsByType

      private final Map<Class<?>,Double> utilizationLimitsByType
    • capacityRulesByName

      private final Map<String, ProductionOptimizer.CapacityRule> capacityRulesByName
    • capacityRulesByType

      private final Map<Class<?>, ProductionOptimizer.CapacityRule> capacityRulesByType
    • capacityRangesByName

      private final Map<String, ProductionOptimizer.CapacityRange> capacityRangesByName
    • capacityRangesByType

      private final Map<Class<?>, ProductionOptimizer.CapacityRange> capacityRangesByType
    • equipmentConstraintRules

      private final List<ProductionOptimizer.EquipmentConstraintRule> 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

      public ProductionOptimizer.OptimizationConfig tolerance(double 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

      public ProductionOptimizer.OptimizationConfig maxIterations(int maxIterations)
      Sets the maximum number of iterations.
      Parameters:
      maxIterations - maximum iterations before termination (default: 30)
      Returns:
      this config for method chaining
    • rejectInvalidSimulations

      public ProductionOptimizer.OptimizationConfig rejectInvalidSimulations(boolean reject)
      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

      public ProductionOptimizer.OptimizationConfig rateUnit(String rateUnit)
    • searchMode

    • swarmSize

      public ProductionOptimizer.OptimizationConfig swarmSize(int swarmSize)
    • inertiaWeight

      public ProductionOptimizer.OptimizationConfig inertiaWeight(double inertiaWeight)
    • cognitiveWeight

      public ProductionOptimizer.OptimizationConfig cognitiveWeight(double cognitiveWeight)
    • socialWeight

      public ProductionOptimizer.OptimizationConfig socialWeight(double socialWeight)
    • randomSeed

      public ProductionOptimizer.OptimizationConfig randomSeed(long seed)
      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

      public ProductionOptimizer.OptimizationConfig useFixedSeed(boolean fixed)
      Controls whether a fixed or time-based random seed is used.

      When false, uses System.nanoTime() as the seed, providing different exploration paths on each run. When true (default), uses the seed set by randomSeed(long) for reproducibility.

      Parameters:
      fixed - true for fixed seed (reproducible), false for time-based seed (diverse)
      Returns:
      this config for method chaining
    • createRandom

      public Random 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

      public ProductionOptimizer.OptimizationConfig columnFsFactorLimit(double 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

      public ProductionOptimizer.OptimizationConfig capacityPercentile(double capacityPercentile)
    • capacityRangeSpreadFraction

      public ProductionOptimizer.OptimizationConfig capacityRangeSpreadFraction(double capacityRangeSpreadFraction)
    • utilizationLimitForName

      public ProductionOptimizer.OptimizationConfig utilizationLimitForName(String equipmentName, double limit)
    • utilizationLimitForType

      public ProductionOptimizer.OptimizationConfig utilizationLimitForType(Class<?> type, double limit)
    • capacityRuleForName

      public ProductionOptimizer.OptimizationConfig capacityRuleForName(String equipmentName, ProductionOptimizer.CapacityRule rule)
    • capacityRuleForType

    • capacityRangeForName

      public ProductionOptimizer.OptimizationConfig capacityRangeForName(String equipmentName, ProductionOptimizer.CapacityRange range)
    • capacityRangeForType

    • equipmentConstraintRule

    • enableCaching

      public ProductionOptimizer.OptimizationConfig enableCaching(boolean enableCaching)
    • parallelEvaluations

      public ProductionOptimizer.OptimizationConfig parallelEvaluations(boolean parallel)
      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

      public ProductionOptimizer.OptimizationConfig parallelThreads(int threads)
      Sets the number of threads for parallel evaluations.
      Parameters:
      threads - number of threads (default: available processors)
      Returns:
      this config for method chaining
    • paretoGridSize

      public ProductionOptimizer.OptimizationConfig paretoGridSize(int gridSize)
      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

      public String getRateUnit()
      Gets the rate unit for the optimization.
      Returns:
      the rate unit string
    • 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

      public ProductionOptimizer.SearchMode 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

      public ProductionOptimizer.OptimizationConfig stagnationIterations(int iterations)
      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

      public ProductionOptimizer.OptimizationConfig maxCacheSize(int size)
      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

      public ProductionOptimizer.OptimizationConfig initialGuess(double[] guess)
      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