### Install ENOPPY from source Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/quick_start.md Clone the repository and install the package locally. ```bash $ git clone https://github.com/thieu1995/enoppy.git $ cd enoppy $ python setup.py install ``` -------------------------------- ### Install ENOPPY via pip Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/quick_start.md Install the current stable release from PyPI. ```bash $ pip install enoppy==0.1.1 ``` -------------------------------- ### Import and verify ENOPPY Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/quick_start.md Verify the installation by checking the library version. ```python $ python >>> import enoppy >>> enoppy.__version__ ``` -------------------------------- ### Install ENOPPY Source: https://github.com/thieu1995/enoppy/blob/main/README.md Install the current PyPI release of the enoppy library using pip. This command is used in the terminal or command prompt. ```sh $ pip install enoppy ``` -------------------------------- ### Gear Train Problem Example (Discrete Optimization) Source: https://context7.com/thieu1995/enoppy/llms.txt Example usage for the Gear Train Problem from the PDO 2022 suite, demonstrating discrete optimization by creating a solution and amending it to integer values. ```python prob = pdo_2022.GearTrainProblem() x0 = prob.create_solution() x0 = prob.amend_position(x0) # Convert to integers print("Gear teeth:", x0) # Output: [34 45 22 51] (integer values between 12-60) print("Objective:", prob.get_objs(x0)) # Output: Gear ratio error squared ``` -------------------------------- ### Import and Get ENOPPY Version Source: https://github.com/thieu1995/enoppy/blob/main/README.md Import the enoppy library in a Python script and print its installed version. This is a basic check after installation. ```python import enoppy print(enoppy.__version__) ``` -------------------------------- ### Car Side Impact Problem Usage Source: https://context7.com/thieu1995/enoppy/llms.txt Example usage for the Car Side Impact Problem, demonstrating how to create a solution, and get dimensions, objectives, and objective values. ```python x0 = csp.create_solution() print("Car Side Impact - Dimensions:", csp.n_dims) # Output: 7 print("Car Side Impact - Objectives:", csp.n_objs) # Output: 3 print("Objective values:", csp.get_objs(x0)) # Output: [23.5, 4.2, 13.1] (approximate, depends on solution) ``` -------------------------------- ### Custom Penalty Function for Tension/Compression Spring Source: https://context7.com/thieu1995/enoppy/llms.txt Example of using a custom penalty function with the Tension/Compression Spring Problem from the IHAOAVOA 2022 suite. The custom function modifies constraint values and calculates a penalized objective. ```python import numpy as np def penalty_func(list_objs, list_cons): list_cons[list_cons < 0] = 0 return np.sum(list_objs) + 1e5 * np.sum(list_cons ** 2) prob = ihaoavoa_2022.TensionCompressionSpringProblem(penalty_func) x0 = np.array([0.05, 0.5, 10.0]) # [wire diameter, mean coil diameter, number of coils] print("Objective:", prob.get_objs(x0)) # Output: [0.125] (spring weight) print("Constraints:", prob.get_cons(x0)) # Output: [0.99, -0.79, 0.88, -0.63] (constraint values) ``` -------------------------------- ### Initialize and evaluate a problem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/quick_start.md Demonstrates how to instantiate a problem class and evaluate solutions. ```python from enoppy.paper_based.moeosma_2023 import SpeedReducerProblem # SRP = SpeedReducerProblem # SP = SpringProblem # HTBP = HydrostaticThrustBearingProblem # VPP = VibratingPlatformProblem # CSP = CarSideImpactProblem # WRMP = WaterResourceManagementProblem # BCP = BulkCarriersProblem # MPBPP = MultiProductBatchPlantProblem srp_prob = SpeedReducerProblem() print("Lower bound for this problem: ", srp_prob.lb) print("Upper bound for this problem: ", srp_prob.ub) x0 = srp_prob.create_solution() print("Get the objective values of x0: ", srp_prob.get_objs(x0)) print("Get the constraint values of x0: ", srp_prob.get_cons(x0)) print("Evaluate with default penalty function: ", srp_prob.evaluate(x0)) ``` -------------------------------- ### View ENOPPY directory structure Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/quick_start.md Overview of the project file organization. ```text docs examples enoppy paper_based pdo_2022.py rwco_2020.py problem_based chemical.py mechanism.py utils validator.py visualize.py __init__.py engineer.py README.md setup.py ``` -------------------------------- ### Instantiate and Inspect Speed Reducer Problem Source: https://context7.com/thieu1995/enoppy/llms.txt Instantiate the SpeedReducerProblem and access its properties like name, dimensions, objectives, constraints, and bounds. ```python from enoppy.paper_based.moeosma_2023 import SpeedReducerProblem # Instantiate a problem problem = SpeedReducerProblem() # Access problem properties print("Problem name:", problem.name) # Output: Speed Reducer Design Problem print("Number of dimensions:", problem.n_dims) # Output: 7 print("Number of objectives:", problem.n_objs) # Output: 2 print("Number of constraints:", problem.n_cons) # Output: 11 print("Lower bounds:", problem.lb) # Output: [2.6 0.7 17. 7.3 7.3 2.9 5. ] print("Upper bounds:", problem.ub) # Output: [3.6 0.8 28. 8.3 8.3 3.9 5.5] print("Bounds as list of tuples:", problem.bounds) # Output: [(2.6, 3.6), (0.7, 0.8), (17, 28), (7.3, 8.3), (7.3, 8.3), (2.9, 3.9), (5.0, 5.5)] # Get all problem parameters params = problem.get_paras() print("Parameters:", params) # Output: {'bounds': [...], 'n_dims': 7} ``` -------------------------------- ### Integrate ENOPPY with SciPy for Optimization Source: https://context7.com/thieu1995/enoppy/llms.txt Demonstrates how to use ENOPPY problems with scipy.optimize for gradient-based optimization. Includes a custom penalty function for handling constraints. ```python import numpy as np from scipy import optimize from enoppy.paper_based import ihaoavoa_2022 # Custom penalty function for scipy def penalty_func(list_objs, list_cons): list_cons[list_cons < 0] = 0 return np.sum(list_objs) + 1e5 * np.sum(list_cons ** 2) # Create problem with penalty function prob = ihaoavoa_2022.TensionCompressionSpringProblem(penalty_func) # Generate initial guess x0 = np.random.uniform(prob.lb, prob.ub) # Solve using scipy.optimize.minimize result = optimize.minimize( prob.evaluate, x0=x0, bounds=prob.bounds, method='L-BFGS-B' ) # Print results print("Optimal solution:") print("x =", result.x) # Output: x = [0.051 0.357 11.2] (approximate) print("Objective value:", prob.get_objs(result.x)) # Output: [0.0127] (spring weight) print("Constraint values:", prob.get_cons(result.x)) # Output: [-0.001, -0.23, -0.001, -0.73] (all satisfied if negative) print("Optimization success:", result.success) print("Iterations:", result.nit) ``` -------------------------------- ### Benchmark Problem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Standard methods available for benchmark problem classes such as MultipleDiskClutchBrakeDesignProblem, OptimalDesignIndustrialRefrigerationSystemProblem, and OptimalOperationAlkylationUnitProblem. ```APIDOC ## evaluate(x) ### Description Evaluation of the benchmark function for a given candidate vector. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ### Response - **val** (float) - The evaluated benchmark function value. ## get_cons(x) ### Description Compute the values of the constraint functions for a given set of input values. ## get_ineq_cons(x) ### Description Compute the values of the inequality constraint functions for a given set of input values. ## get_objs(x) ### Description Compute the values of the objective functions for a given set of input values. ``` -------------------------------- ### Initialize Heat Exchanger Network Design Case 1 Source: https://context7.com/thieu1995/enoppy/llms.txt Initializes a Heat Exchanger Network Design Case 1 problem. This problem has 9 variables and 8 equality constraints. ```python prob = rwco_2020.HeatExchangerNetworkDesignCase1Problem() print("Dimensions:", prob.n_dims) # 9 print("Equality constraints:", prob.n_eq_cons) # 8 x0 = prob.create_solution() print("Objective:", prob.get_objs(x0)) ``` -------------------------------- ### Instantiate MOEOSMA 2023 Problems Source: https://context7.com/thieu1995/enoppy/llms.txt Instantiate various optimization problems from the MOEOSMA 2023 suite. These problems cover different domains like vibrating platforms and bulk carriers. ```python vpp = moeosma_2023.VibratingPlatformProblem() # Alias: moeosma_2023.VPP csp = moeosma_2023.CarSideImpactProblem() # Alias: moeosma_2023.CSP wrmp = moeosma_2023.WaterResourceManagementProblem() # Alias: moeosma_2023.WRMP bcp = moeosma_2023.BulkCarriersProblem() # Alias: moeosma_2023.BCP mpbpp = moeosma_2023.MultiProductBatchPlantProblem() # Alias: moeosma_2023.MPBPP ``` -------------------------------- ### MultiProductBatchPlantProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Methods for evaluating the Multi-product Batch Plant design problem. ```APIDOC ## MultiProductBatchPlantProblem ### Description Evaluates the Multi-product Batch Plant design problem (x = [N1, N2, N3, V1, V2, V3, TL1, TL2, B1, B2]). ### Methods - **amend_position(x, lb, ub)**: Amends position to fit the problem format. - **evaluate(x)**: Evaluates the benchmark function. - **get_cons(x)**: Computes constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray) - Required - The current position (solution). ``` -------------------------------- ### Create and Evaluate a Solution Source: https://context7.com/thieu1995/enoppy/llms.txt Generate a random feasible solution, amend it if necessary for discrete variables, and evaluate its objectives, constraints, and fitness with the default penalty function. ```python from enoppy.paper_based.moeosma_2023 import SpeedReducerProblem # Create problem instance problem = SpeedReducerProblem() # Create a random solution within bounds x0 = problem.create_solution() print("Random solution:", x0) # Output: [3.12 0.75 22.5 7.8 7.9 3.4 5.2] (random values) # Amend position for discrete variables if needed x0 = problem.amend_position(x0) # Get objective function values objectives = problem.get_objs(x0) print("Objective values:", objectives) # Output: [2996.35, 1.8e+03] (depends on solution) # Get constraint function values (negative = satisfied, positive = violated) constraints = problem.get_cons(x0) print("Constraint values:", constraints) # Output: [-0.82, -0.95, ...] (11 constraint values) # Evaluate with default penalty function fitness = problem.evaluate(x0) print("Fitness (with penalty):", fitness) # Output: Penalized objective values array ``` -------------------------------- ### Import MOEOSMA 2023 Problems Source: https://context7.com/thieu1995/enoppy/llms.txt Import and instantiate various multi-objective optimization problems from the MOEOSMA 2023 paper, including Speed Reducer, Spring Design, and Hydrostatic Thrust Bearing problems. ```python from enoppy.paper_based import moeosma_2023 # Speed Reducer Problem (7 vars, 2 objs, 11 cons) srp = moeosma_2023.SpeedReducerProblem() # Alias: moeosma_2023.SRP # Spring Design Problem (3 vars, 2 objs, 8 cons) sp = moeosma_2023.SpringProblem() # Alias: moeosma_2023.SP # Hydrostatic Thrust Bearing Problem (4 vars, 2 objs, 7 cons) htbp = moeosma_2023.HydrostaticThrustBearingProblem() # Alias: moeosma_2023.HTBP ``` -------------------------------- ### Instantiate IHAOAVOA 2022 Problems Source: https://context7.com/thieu1995/enoppy/llms.txt Instantiate single-objective constrained problems from the IHAOAVOA 2022 paper. This suite includes problems like tension/compression spring and welded beam. ```python from enoppy.paper_based import ihaoavoa_2022 # Tension/Compression Spring Problem (3 vars, 1 obj, 4 cons) tcsp = ihaoavoa_2022.TensionCompressionSpringProblem() # Alias: ihaoavoa_2022.TCSP # Welded Beam Problem (4 vars, 1 obj, 7 cons) wbp = ihaoavoa_2022.WeldedBeamProblem() # Alias: ihaoavoa_2022.WBP # Cantilever Beam Problem (5 vars, 1 obj, 1 cons) cbp = ihaoavoa_2022.CantileverBeamProblem() # Alias: ihaoavoa_2022.CBP # Speed Reducer Problem (7 vars, 1 obj, 11 cons) srp = ihaoavoa_2022.SpeedReducerProblem() # Alias: ihaoavoa_2022.SRP # Rolling Element Bearing Problem (10 vars, 1 obj, 9 cons) rebp = ihaoavoa_2022.RollingElementBearingProblem() # Alias: ihaoavoa_2022.REBP ``` -------------------------------- ### Tension/Compression Spring Design (Mechanical design problems) Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Tension/Compression Spring Design benchmark function. ```APIDOC ## evaluate(x) ### Description Evaluation of the benchmark function. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have `len(x) == self.n_dims`. ### Returns - **val** (float) - The evaluated benchmark function value. ``` ```APIDOC ## get_cons(x) ### Description Compute the values of the constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing constraint functions. Must have `len(x) == self.n_dims`. ``` ```APIDOC ## get_ineq_cons(x) ### Description Compute the values of the inequality constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing inequality constraint functions. Must have `len(x) == self.n_dims`. ``` ```APIDOC ## get_objs(x) ### Description Compute the values of the objective functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing objective functions. Must have `len(x) == self.n_dims`. ``` -------------------------------- ### Process Synthesis 01 Problem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Handles the Process Synthesis 01 benchmark problem for process design and synthesis. ```APIDOC ## ProcessSynthesis01Problem ### Description Represents the Process Synthesis 01 problem for process design and synthesis. ### Methods - **amend_position(x, lb=None, ub=None)**: Amend position to fit the format of the problem. - **evaluate(x)**: Evaluation of the benchmark function. - **get_cons(x)**: Compute the values of the constraint functions. - **get_ineq_cons(x)**: Compute the values of the inequality constraint functions. - **get_objs(x)**: Compute the values of the objective functions. ``` -------------------------------- ### Instantiate PDO 2022 Problems Source: https://context7.com/thieu1995/enoppy/llms.txt Instantiate single-objective problems from the PDO 2022 paper. This suite includes a variety of engineering design problems like welded beam and pressure vessel. ```python from enoppy.paper_based import pdo_2022 # Welded Beam Problem (4 vars, 1 obj, 7 cons) wbp = pdo_2022.WeldedBeamProblem() # Alias: pdo_2022.WBP # Pressure Vessel Problem (4 vars, 1 obj, 4 cons) pvp = pdo_2022.PressureVesselProblem() # Alias: pdo_2022.PVP # Compression Spring Problem (3 vars, 1 obj, 4 cons) csp = pdo_2022.CompressionSpringProblem() # Alias: pdo_2022.CSP # Speed Reducer Problem (7 vars, 1 obj, 11 cons) srd = pdo_2022.SpeedReducerProblem() # Alias: pdo_2022.SRD # Three Bar Truss Problem (2 vars, 1 obj, 3 cons) tbtd = pdo_2022.ThreeBarTrussProblem() # Alias: pdo_2022.TBTD # Gear Train Problem - Unconstrained (4 vars, 1 obj, 0 cons) gtd = pdo_2022.GearTrainProblem() # Alias: pdo_2022.GTD # Cantilever Beam Problem (5 vars, 1 obj, 1 cons) cbd = pdo_2022.CantileverBeamProblem() # Alias: pdo_2022.CBD # I-Beam Problem (4 vars, 1 obj, 2 cons) ibd = pdo_2022.IBeamProblem() # Alias: pdo_2022.IBD # Tubular Column Problem (2 vars, 1 obj, 6 cons) tcd = pdo_2022.TubularColumnProblem() # Alias: pdo_2022.TCD # Piston Lever Problem (4 vars, 1 obj, 4 cons) pld = pdo_2022.PistonLeverProblem() # Alias: pdo_2022.PLD # Corrugated Bulkhead Problem (4 vars, 1 obj, 6 cons) cbhd = pdo_2022.CorrugatedBulkheadProblem() # Alias: pdo_2022.CBHD # Reinforced Concrete Beam Problem (3 vars, 1 obj, 2 cons) rcb = pdo_2022.ReinforcedConcreateBeamProblem() # Alias: pdo_2022.RCB ``` -------------------------------- ### Integrate ENOPPY with MEALPY for Meta-heuristic Optimization Source: https://context7.com/thieu1995/enoppy/llms.txt Shows how to use ENOPPY problems with the MEALPY library for meta-heuristic optimization algorithms like the Slime Mould Algorithm (SMA). ```python from mealpy import SMA, FloatVar from enoppy.paper_based import moeosma_2023 # Create problem instance prob = moeosma_2023.SpeedReducerProblem() # Configure problem for MEALPY problem_dict = { "bounds": FloatVar(lb=prob.lb, ub=prob.ub), "obj_func": prob.evaluate, "minmax": "min", "obj_weights": [0.5, 0.5] # Weights for multi-objective } # Run Slime Mould Algorithm model = SMA.OriginalSMA(epoch=100, pop_size=50, pr=0.03) g_best = model.solve(problem_dict) # Print results print(f"Best solution: {g_best.solution}") # Output: Best solution: [2.9 0.75 23 7.8 7.9 3.2 5.1] print(f"Best fitness: {g_best.target.fitness}") # Output: Best fitness: 2856.24 # Verify constraint satisfaction constraints = prob.get_cons(g_best.solution) print(f"Constraints satisfied: {all(c <= 0 for c in constraints)}") ``` -------------------------------- ### MultiProductBatchPlantProblem API Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md API documentation for the MultiProductBatchPlantProblem, detailing its methods for amending position, evaluation, constraint retrieval, objective function retrieval, and accessing its name. ```APIDOC ## MultiProductBatchPlantProblem Methods ### Description Provides methods to amend the problem's position, evaluate the problem, retrieve constraints, retrieve objective functions, and get the problem name. ### Methods - `amend_position()`: Amends the position of the problem. - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints of the problem. - `get_objs()`: Retrieves the objective functions of the problem. - `name`: Property to get the name of the problem. ``` -------------------------------- ### PlanetaryGearTrainDesignOptimizationProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Planetary Gear Train Design Optimization Problem. ```APIDOC ## PlanetaryGearTrainDesignOptimizationProblem ### Description Represents the planetary gear train design optimization problem with 9 dimensions. ### Methods - **amend_position(x, lb=None, ub=None)**: Adjusts the position vector to fit problem constraints. - **evaluate(x)**: Evaluates the benchmark function for a given candidate vector. - **get_cons(x)**: Computes all constraint values. - **get_eq_cons(x)**: Computes equality constraint values. - **get_ineq_cons(x)**: Computes inequality constraint values. - **get_objs(x)**: Computes objective function values. ``` -------------------------------- ### OptimalDesignIndustrialRefrigerationSystemProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods for the OptimalDesignIndustrialRefrigerationSystemProblem class. ```APIDOC ## OptimalDesignIndustrialRefrigerationSystemProblem ### Description Provides methods for the OptimalDesignIndustrialRefrigerationSystemProblem. ### Methods - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints. - `get_ineq_cons()`: Retrieves the inequality constraints. - `get_objs()`: Retrieves the objective functions. - `name`: The name of the problem. ``` -------------------------------- ### MultipleDiskClutchBrakeDesignProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods for the MultipleDiskClutchBrakeDesignProblem class. ```APIDOC ## MultipleDiskClutchBrakeDesignProblem ### Description Provides methods related to the MultipleDiskClutchBrakeDesignProblem. ### Methods - `get_objs()`: Retrieves the objective functions. - `name`: The name of the problem. ``` -------------------------------- ### Enoppy Property: name Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Retrieves the name of the benchmark problem. ```APIDOC ## GET /properties/name ### Description Retrieves the name of the benchmark problem. ### Method GET ### Endpoint /properties/name ### Parameters None ### Request Example None ### Response #### Success Response (200) - **name** (string) - The name of the benchmark problem. ``` -------------------------------- ### Process Synthesis 02 Problem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Handles the Process Synthesis 02 benchmark problem for process design and synthesis. ```APIDOC ## ProcessSynthesis02Problem ### Description Represents the Process Synthesis 02 problem for process design and synthesis. ### Methods - **amend_position(x, lb=None, ub=None)**: Amend position to fit the format of the problem. - **evaluate(x)**: Evaluation of the benchmark function. - **get_cons(x)**: Compute the values of the constraint functions. - **get_ineq_cons(x)**: Compute the values of the inequality constraint functions. - **get_objs(x)**: Compute the values of the objective functions. ``` -------------------------------- ### Enoppy Property: ub Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Retrieves the upper bounds for the problem. ```APIDOC ## GET /properties/ub ### Description Retrieves the upper bounds for the problem. ### Method GET ### Endpoint /properties/ub ### Parameters None ### Request Example None ### Response #### Success Response (200) - **ub** (1D-vector) - The upper bounds for the problem. ``` -------------------------------- ### OptimalOperationAlkylationUnitProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods for the OptimalOperationAlkylationUnitProblem class. ```APIDOC ## OptimalOperationAlkylationUnitProblem ### Description Provides methods for the OptimalOperationAlkylationUnitProblem. ### Methods - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints. - `get_ineq_cons()`: Retrieves the inequality constraints. - `get_objs()`: Retrieves the objective functions. - `name`: The name of the problem. ``` -------------------------------- ### Process Synthesis and Design Problem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Handles the Process Synthesis and Design benchmark problem. ```APIDOC ## ProcessSynthesisAndDesignProblem ### Description Represents the Process Synthesis and Design problem. ### Methods - **amend_position(x, lb=None, ub=None)**: Amend position to fit the format of the problem. - **evaluate(x)**: Evaluation of the benchmark function. - **get_cons(x)**: Compute the values of the constraint functions. - **get_eq_cons(x)**: Compute the values of the equality constraint functions. - **get_ineq_cons(x)**: Compute the values of the inequality constraint functions. - **get_objs(x)**: Compute the values of the objective functions. ``` -------------------------------- ### PressureVesselDesignProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Pressure Vessel Design Problem. ```APIDOC ## PressureVesselDesignProblem ### Description Represents the pressure vessel design optimization problem with 4 dimensions. ### Methods - **amend_position(x, lb=None, ub=None)**: Adjusts the position vector to fit problem constraints. - **evaluate(x)**: Evaluates the benchmark function for a given candidate vector. - **get_cons(x)**: Computes all constraint values. - **get_ineq_cons(x)**: Computes inequality constraint values. - **get_objs(x)**: Computes objective function values. ``` -------------------------------- ### HydrostaticThrustBearingProblem API Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md API documentation for the HydrostaticThrustBearingProblem, detailing its methods for evaluation, constraint retrieval, objective function retrieval, and accessing its name. ```APIDOC ## HydrostaticThrustBearingProblem Methods ### Description Provides methods to evaluate the problem, retrieve constraints, retrieve objective functions, and get the problem name. ### Methods - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints of the problem. - `get_objs()`: Retrieves the objective functions of the problem. - `name`: Property to get the name of the problem. ``` -------------------------------- ### HeatExchangerNetworkDesignProblems Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Interface for Heat Exchanger Network Design cases 1 and 2. ```APIDOC ## HeatExchangerNetworkDesignProblems ### Description Evaluates Heat Exchanger Network Design problems (Case 1 and Case 2). ### Methods - **evaluate(x)**: Evaluates the benchmark function for a candidate vector x. - **get_cons(x)**: Computes constraint function values. - **get_eq_cons(x)**: Computes equality constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ``` -------------------------------- ### ProcessSynthesisAndDesignProblem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods available for the ProcessSynthesisAndDesignProblem class. ```APIDOC ## ProcessSynthesisAndDesignProblem Methods ### Description Methods for defining and evaluating combined process synthesis and design problems. ### Methods - `amend_position()`: Modifies the problem's configuration. - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves all constraints. ### Properties - `name`: The name of the problem. ``` -------------------------------- ### VibratingPlatformProblem API Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md API documentation for the VibratingPlatformProblem, detailing its methods for evaluation, constraint retrieval, objective function retrieval, and accessing its name. ```APIDOC ## VibratingPlatformProblem Methods ### Description Provides methods to evaluate the problem, retrieve constraints, retrieve objective functions, and get the problem name. ### Methods - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints of the problem. - `get_objs()`: Retrieves the objective functions of the problem. - `name`: Property to get the name of the problem. ``` -------------------------------- ### ProcessFlowSheetingProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Process Flow Sheeting Problem. ```APIDOC ## ProcessFlowSheetingProblem ### Description Represents the process flow sheeting problem with 3 dimensions. ### Methods - **amend_position(x, lb=None, ub=None)**: Adjusts the position vector to fit problem constraints. - **evaluate(x)**: Evaluates the benchmark function for a given candidate vector. - **get_cons(x)**: Computes all constraint values. - **get_ineq_cons(x)**: Computes inequality constraint values. - **get_objs(x)**: Computes objective function values. ``` -------------------------------- ### Optimization Problem Aliases Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md A collection of aliases for various engineering and process design optimization problems. ```APIDOC ## Optimization Problem Aliases ### Description This module provides aliases for specific optimization problem classes used in the enoppy library. ### Problem Mappings - **p2**: HeatExchangerNetworkDesignCase2Problem - **p20**: ThreeBarTrussDesignProblem - **p21**: MultipleDiskClutchBrakeDesignProblem - **p22**: PlanetaryGearTrainDesignOptimizationProblem - **p23**: StepConePulleyProblem - **p3**: HaverlyPoolingProblem - **p4**: BlendingPoolingSeparationProblem - **p5**: PropaneIsobutaneNButaneNonsharpSeparationProblem - **p6**: OptimalOperationAlkylationUnitProblem - **p7**: ReactorNetworkDesignProblem - **p8**: ProcessSynthesis01Problem - **p9**: ProcessSynthesisAndDesignProblem ``` -------------------------------- ### Cite ENOPPY and MEALPY in BibTeX Source: https://github.com/thieu1995/enoppy/blob/main/README.md Use these BibTeX entries to cite the ENOPPY library and the related MEALPY framework in academic publications. ```bibtex @software{nguyen_van_thieu_2023_7953207, author = {Nguyen Van Thieu}, title = {ENOPPY: A Python Library for Engineering Optimization Problems}, year = 2023, publisher = {Zenodo}, doi = {10.5281/zenodo.7953206}, url = {https://github.com/thieu1995/enoppy} } @article{van2023mealpy, title={MEALPY: An open-source library for latest meta-heuristic algorithms in Python}, author={Van Thieu, Nguyen and Mirjalili, Seyedali}, journal={Journal of Systems Architecture}, year={2023}, publisher={Elsevier}, doi={10.1016/j.sysarc.2023.102871} } ``` -------------------------------- ### Benchmark Problem Interface Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Standard methods available for all engineering benchmark problems in the enoppy library. ```APIDOC ## Benchmark Problem Methods ### evaluate(x) Evaluation of the benchmark function. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ### Response - **val** (float) - The evaluated benchmark function value. ### get_cons(x) Compute the values of the constraint functions for a given set of input values. ### get_objs(x) Compute the values of the objective functions for a given set of input values. ### amend_position(x, lb=None, ub=None) Amend position to fit the format of the problem. ### Parameters - **x** (np.ndarray) - Required - The current position (solution). ``` -------------------------------- ### ProcessDesignProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Process Design Problem. ```APIDOC ## ProcessDesignProblem ### Description Represents the process design problem with 5 dimensions. ### Methods - **amend_position(x, lb=None, ub=None)**: Adjusts the position vector to fit problem constraints. - **evaluate(x)**: Evaluates the benchmark function for a given candidate vector. - **get_cons(x)**: Computes all constraint values. - **get_ineq_cons(x)**: Computes inequality constraint values. - **get_objs(x)**: Computes objective function values. ``` -------------------------------- ### TensionCompressionSpringProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Represents the Tension/Compression Spring design problem. It is an alias for enoppy.paper_based.ihaoavoa_2022.TensionCompressionSpringProblem. ```APIDOC ## Class: TensionCompressionSpringProblem ### Description Represents the Tension/Compression Spring design problem. ### Method __init__(self, f_penalty=None) ### Parameters - **f_penalty** (any) - Optional - Penalty function. ### Methods #### evaluate(self, x) ##### Description Evaluation of the benchmark function. ##### Parameters - **x** (np.ndarray, list, tuple) - The candidate vector for evaluating the benchmark problem. Must have `len(x) == self.n_dims`. ##### Returns - **val** (float) - The evaluated benchmark function. #### get_cons(self, x) ##### Description Compute the values of the constraint functions for a given set of input values. #### get_objs(self, x) ##### Description Compute the values of the objective functions for a given set of input values. #### name - **name** (str) - 'Tension/compression spring design problem' ``` -------------------------------- ### Enoppy Property: lb Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Retrieves the lower bounds for the problem. ```APIDOC ## GET /properties/lb ### Description Retrieves the lower bounds for the problem. ### Method GET ### Endpoint /properties/lb ### Parameters None ### Request Example None ### Response #### Success Response (200) - **lb** (1D-vector) - The lower bounds for the problem. ``` -------------------------------- ### PressureVesselDesignProblem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods available for the PressureVesselDesignProblem class. ```APIDOC ## PressureVesselDesignProblem Methods ### Description Provides methods to access constraints and objectives for pressure vessel design problems. ### Methods - `get_cons()`: Retrieves all constraints. - `get_ineq_cons()`: Retrieves inequality constraints. - `get_objs()`: Retrieves objective functions. ### Properties - `name`: The name of the problem. ``` -------------------------------- ### Use LabelEncoder for Categorical Data Source: https://context7.com/thieu1995/enoppy/llms.txt Demonstrates the use of the LabelEncoder utility for encoding discrete or categorical values into integer indices, useful for optimization problems. ```python from enoppy.utils.encoder import LabelEncoder import numpy as np # Create encoder with discrete values encoder = LabelEncoder() discrete_values = [0.009, 0.0095, 0.0104, 0.0118, 0.0128, 0.0132, 0.014, 0.015, 0.0162, 0.0173, 0.018, 0.020, 0.023, 0.025, 0.028, 0.032, 0.035, 0.041, 0.047, 0.054, 0.063] # Fit encoder to discrete values encoder.fit(discrete_values) # Transform values to indices indices = encoder.transform([0.009, 0.020, 0.063]) print("Indices:", indices) # Output: [0, 11, 20] ``` -------------------------------- ### PlanetaryGearTrainDesignOptimizationProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods for the PlanetaryGearTrainDesignOptimizationProblem class. ```APIDOC ## PlanetaryGearTrainDesignOptimizationProblem ### Description Provides methods for the PlanetaryGearTrainDesignOptimizationProblem. ### Methods - `amend_position()`: Amends the position. - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves the constraints. - `get_eq_cons()`: Retrieves the equality constraints. - `get_ineq_cons()`: Retrieves the inequality constraints. - `get_objs()`: Retrieves the objective functions. - `name`: The name of the problem. ``` -------------------------------- ### WaterResourceManagementProblem API Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md API documentation for the WaterResourceManagementProblem, detailing its method for evaluation. ```APIDOC ## WaterResourceManagementProblem Methods ### Description Provides a method to evaluate the problem. ### Methods - `evaluate()`: Evaluates the problem. ``` -------------------------------- ### WeightMinimizationSpeedReducerProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Models the weight minimization problem for a speed reducer, a mechanical design problem. It includes methods for evaluation and retrieving constraint and objective values. ```APIDOC ## Class: WeightMinimizationSpeedReducerProblem ### Description Mechanical design problems. This class models the weight minimization of a speed reducer. ### Inheritance Bases: `Engineer` ### Methods #### `evaluate(x)` Evaluation of the benchmark function. * **Parameters:** **x** (*np.ndarray*, *list*, *tuple*) – The candidate vector for evaluating the benchmark problem. Must have `len(x) == self.n_dims`. * **Returns:** **val** – the evaluated benchmark function * **Return type:** float #### `get_cons(x)` Compute the values of the constraint functions for a given set of input values. #### `get_ineq_cons(x)` Compute the values of the inequality constraint functions for a given set of input values. #### `get_objs(x)` Compute the values of the objective functions for a given set of input values. ### Name 'Weight minimization of a speed reducer (Mechanical design problems)' ``` -------------------------------- ### Propane Isobutane n-Butane Nonsharp Separation Problem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Handles the industrial chemical process benchmark for nonsharp separation. ```APIDOC ## PropaneIsobutaneNButaneNonsharpSeparationProblem ### Description Represents the Propane, Isobutane, n-Butane Nonsharp Separation industrial chemical process problem. ### Methods - **evaluate(x)**: Evaluation of the benchmark function. - **get_cons(x)**: Compute the values of the constraint functions. - **get_eq_cons(x)**: Compute the values of the equality constraint functions. - **get_objs(x)**: Compute the values of the objective functions. ``` -------------------------------- ### BlendingPoolingSeparationProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Interface for the Blending-Pooling-Separation problem (Industrial Chemical Processes). ```APIDOC ## BlendingPoolingSeparationProblem ### Description Evaluates the Blending-Pooling-Separation problem for industrial chemical processes. ### Methods - **evaluate(x)**: Evaluates the benchmark function for a candidate vector x. - **get_cons(x)**: Computes constraint function values. - **get_eq_cons(x)**: Computes equality constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ``` -------------------------------- ### WeightMinimizationSpeedReducerProblem API Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md API endpoints for the WeightMinimizationSpeedReducerProblem, providing access to evaluation, constraints, and objectives. ```APIDOC ## WeightMinimizationSpeedReducerProblem ### Description Defines the Weight Minimization Speed Reducer Problem, with methods to evaluate the problem, retrieve constraints, and access objectives. ### Methods - `evaluate()`: Evaluates the design problem. - `get_cons()`: Retrieves the constraints for the problem. - `get_ineq_cons()`: Retrieves the inequality constraints for the problem. - `get_objs()`: Retrieves the objective functions for the problem. - `name`: Property representing the name of the design problem. ``` -------------------------------- ### ProcessSynthesis01Problem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods available for the ProcessSynthesis01Problem class. ```APIDOC ## ProcessSynthesis01Problem Methods ### Description Methods for defining and evaluating the ProcessSynthesis01Problem. ### Methods - `amend_position()`: Modifies the problem's configuration. - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves all constraints. - `get_ineq_cons()`: Retrieves inequality constraints. - `get_objs()`: Retrieves objective functions. ### Properties - `name`: The name of the problem. ``` -------------------------------- ### Engineering Problem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Common methods available for engineering optimization problem classes such as GearTrainProblem, IBeamProblem, PistonLeverProblem, PressureVesselProblem, and ReinforcedConcreateBeamProblem. ```APIDOC ## evaluate(x) ### Description Evaluates the benchmark function for a given candidate vector. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ### Response #### Success Response (200) - **val** (float) - The evaluated benchmark function value. ## get_cons(x) ### Description Computes the values of the constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray) - Required - The input values for constraint calculation. ## get_objs(x) ### Description Computes the values of the objective functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray) - Required - The input values for objective calculation. ## amend_position(x, lb=None, ub=None) ### Description Amends the position to fit the specific format of the problem. ### Parameters #### Path Parameters - **x** (np.ndarray) - Required - The current position (solution). - **lb** (optional) - Lower bound. - **ub** (optional) - Upper bound. ``` -------------------------------- ### BulkCarriersProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Methods for evaluating the Bulk Carriers design problem. ```APIDOC ## BulkCarriersProblem ### Description Evaluates the Bulk Carriers design problem (x = [L, B, D, T, Vk, CB]). ### Methods - **evaluate(x)**: Evaluates the benchmark function. - **get_cons(x)**: Computes constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. ``` -------------------------------- ### PressureVesselDesignProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods for the PressureVesselDesignProblem class. ```APIDOC ## PressureVesselDesignProblem ### Description Provides methods for the PressureVesselDesignProblem. ### Methods - `amend_position()`: Amends the position. - `evaluate()`: Evaluates the problem. ``` -------------------------------- ### ProcessSynthesis02Problem Methods Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.md Methods available for the ProcessSynthesis02Problem class. ```APIDOC ## ProcessSynthesis02Problem Methods ### Description Methods for defining and evaluating the ProcessSynthesis02Problem. ### Methods - `amend_position()`: Modifies the problem's configuration. - `evaluate()`: Evaluates the problem. - `get_cons()`: Retrieves all constraints. - `get_ineq_cons()`: Retrieves inequality constraints. - `get_objs()`: Retrieves objective functions. ### Properties - `name`: The name of the problem. ``` -------------------------------- ### Reactor Network Design (Industrial Chemical Processes) Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md API for the Reactor Network Design benchmark function. ```APIDOC ## evaluate(x) ### Description Evaluation of the benchmark function. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have `len(x) == self.n_dims`. ### Returns - **val** (float) - The evaluated benchmark function value. ``` ```APIDOC ## get_cons(x) ### Description Compute the values of the constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing constraint functions. Must have `len(x) == self.n_dims`. ``` ```APIDOC ## get_eq_cons(x) ### Description Compute the values of the equality constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing equality constraint functions. Must have `len(x) == self.n_dims`. ``` ```APIDOC ## get_ineq_cons(x) ### Description Compute the values of the inequality constraint functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing inequality constraint functions. Must have `len(x) == self.n_dims`. ``` ```APIDOC ## get_objs(x) ### Description Compute the values of the objective functions for a given set of input values. ### Parameters #### Path Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for computing objective functions. Must have `len(x) == self.n_dims`. ``` -------------------------------- ### SpeedReducerProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Methods for evaluating the Speed Reducer design problem. ```APIDOC ## SpeedReducerProblem ### Description Evaluates the Speed Reducer design problem (x = [b, m, z, l1, l2, d1, d2]). ### Methods - **amend_position(x, lb, ub)**: Amends position to fit the problem format. - **evaluate(x)**: Evaluates the benchmark function. - **get_cons(x)**: Computes constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray) - Required - The current position (solution). ``` -------------------------------- ### HaverlyPoolingProblem Source: https://github.com/thieu1995/enoppy/blob/main/docs/source/pages/enoppy.paper_based.md Interface for Haverly's Pooling Problem. ```APIDOC ## HaverlyPoolingProblem ### Description Evaluates Haverly's Pooling Problem for industrial chemical processes. ### Methods - **evaluate(x)**: Evaluates the benchmark function for a candidate vector x. - **get_cons(x)**: Computes constraint function values. - **get_eq_cons(x)**: Computes equality constraint function values. - **get_ineq_cons(x)**: Computes inequality constraint function values. - **get_objs(x)**: Computes objective function values. ### Parameters - **x** (np.ndarray, list, tuple) - Required - The candidate vector for evaluating the benchmark problem. Must have len(x) == self.n_dims. ```