Class NetworkOptimizer
java.lang.Object
neqsim.process.equipment.network.NetworkOptimizer
Formal NLP and multi-objective optimizer for pipeline network production allocation.
Replaces the gradient-finite-difference approach in LoopedPipeNetwork with mathematically
rigorous optimization using Apache Commons Math:
- BOBYQA: Bound Optimization BY Quadratic Approximation — derivative-free trust-region method. Best for smooth objectives with 2–20 decision variables.
- CMA-ES: Covariance Matrix Adaptation Evolution Strategy — global optimizer for non-convex, noisy, or multi-modal landscapes. Robust for 5–50 variables.
- Multi-objective: Weighted-sum scalarization with Pareto front exploration via systematic weight sweep.
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOptimizer algorithm selection.static enumObjective type for single-objective optimization.static classResult container for network optimization. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NetworkOptimizer.AlgorithmAlgorithm selection.Choke elements to optimize (names).private doublePenalty factor for constraint violations.Last optimization result.private static final org.apache.logging.log4j.Loggerprivate double[]Lower bounds for choke openings (%).private intMaximum function evaluations.private final LoopedPipeNetworkThe network being optimized.private NetworkOptimizer.ObjectiveTypeObjective type.private intNumber of Pareto front points for multi-objective.private double[]Upper bounds for choke openings (%). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidapplyChokeOpenings(double[] openings) Apply choke opening values to the network elements.private doubleCompute constraint violation penalty.private voidDiscover choke elements and set up bounds.private doubleEvaluate the objective function based on the selected objective type.Get the optimization algorithm.doubleGet the constraint penalty factor.Get the result from the last optimization run.intGet the maximum number of function evaluations.Get the objective type.intGet the number of Pareto front points.private doubleGet total compressor power across all compressor elements in the network.optimize()Run single-objective optimization of choke openings.Run multi-objective optimization: production vs compressor power.private org.apache.commons.math3.optim.PointValuePairrunBOBYQA(double[] x0) Run BOBYQA (Bound Optimization BY Quadratic Approximation).private org.apache.commons.math3.optim.PointValuePairrunCMAES(double[] x0) Run CMA-ES (Covariance Matrix Adaptation Evolution Strategy).voidsetAlgorithm(NetworkOptimizer.Algorithm algorithm) Set the optimization algorithm.voidsetChokeBounds(String chokeName, double minOpening, double maxOpening) Set custom bounds for a specific choke element.voidsetConstraintPenalty(double penalty) Set the constraint penalty factor.voidsetMaxEvaluations(int maxEval) Set the maximum number of function evaluations.voidSet the objective type.voidsetParetoPoints(int points) Set the number of Pareto front points for multi-objective optimization.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger -
network
The network being optimized. -
algorithm
Algorithm selection. -
maxEvaluations
private int maxEvaluationsMaximum function evaluations. -
objectiveType
Objective type. -
constraintPenalty
private double constraintPenaltyPenalty factor for constraint violations. -
chokeNames
-
lowerBounds
private double[] lowerBoundsLower bounds for choke openings (%). -
upperBounds
private double[] upperBoundsUpper bounds for choke openings (%). -
paretoPoints
private int paretoPointsNumber of Pareto front points for multi-objective. -
lastResult
Last optimization result.
-
-
Constructor Details
-
NetworkOptimizer
Create a new network optimizer.- Parameters:
network- the pipeline network to optimize
-
-
Method Details
-
setAlgorithm
Set the optimization algorithm.- Parameters:
algorithm- BOBYQA or CMAES
-
getAlgorithm
-
setMaxEvaluations
public void setMaxEvaluations(int maxEval) Set the maximum number of function evaluations.- Parameters:
maxEval- maximum evaluations
-
getMaxEvaluations
public int getMaxEvaluations()Get the maximum number of function evaluations.- Returns:
- maximum evaluations
-
setObjectiveType
Set the objective type.- Parameters:
type- objective type
-
getObjectiveType
Get the objective type.- Returns:
- objective type
-
setConstraintPenalty
public void setConstraintPenalty(double penalty) Set the constraint penalty factor.- Parameters:
penalty- penalty multiplier for each constraint violation
-
getConstraintPenalty
public double getConstraintPenalty()Get the constraint penalty factor.- Returns:
- penalty
-
setParetoPoints
public void setParetoPoints(int points) Set the number of Pareto front points for multi-objective optimization.- Parameters:
points- number of weight combinations to evaluate (minimum 3)
-
getParetoPoints
public int getParetoPoints()Get the number of Pareto front points.- Returns:
- number of points
-
getLastResult
Get the result from the last optimization run.- Returns:
- optimization result, or null if not yet run
-
optimize
Run single-objective optimization of choke openings.Discovers all choke elements, constructs bounds, and runs the selected algorithm (BOBYQA or CMA-ES) to optimize the specified objective.
- Returns:
- optimization result with optimal choke openings, objective value, and diagnostics
-
optimizeMultiObjective
Run multi-objective optimization: production vs compressor power.Explores the Pareto front by sweeping a weight parameter w from 0 to 1:
f(x) = w * production(x) - (1 - w) * power(x)
Returns a list of Pareto-optimal solutions, each with its production, power, and choke settings.
- Returns:
- list of Pareto-optimal results ordered by increasing production weight
-
runBOBYQA
private org.apache.commons.math3.optim.PointValuePair runBOBYQA(double[] x0) Run BOBYQA (Bound Optimization BY Quadratic Approximation).- Parameters:
x0- initial point (choke openings in %)- Returns:
- optimal point-value pair
-
runCMAES
private org.apache.commons.math3.optim.PointValuePair runCMAES(double[] x0) Run CMA-ES (Covariance Matrix Adaptation Evolution Strategy).- Parameters:
x0- initial point (choke openings in %)- Returns:
- optimal point-value pair
-
evaluateObjective
private double evaluateObjective()Evaluate the objective function based on the selected objective type.- Returns:
- objective value (higher is better)
-
computePenalty
private double computePenalty()Compute constraint violation penalty.- Returns:
- penalty value (non-negative)
-
getTotalCompressorPower
private double getTotalCompressorPower()Get total compressor power across all compressor elements in the network.- Returns:
- total power in kW
-
discoverChokeElements
private void discoverChokeElements()Discover choke elements and set up bounds. -
applyChokeOpenings
private void applyChokeOpenings(double[] openings) Apply choke opening values to the network elements.- Parameters:
openings- array of choke openings in % (same order as chokeNames)
-
setChokeBounds
Set custom bounds for a specific choke element.- Parameters:
chokeName- name of the choke elementminOpening- minimum opening in % (default 1)maxOpening- maximum opening in % (default 100)
-