optframework.examples.all_test module
Comprehensive Test Script for OptFramework
This script provides a comprehensive test suite for all major functionalities of the OptFramework library, including particle size distribution (PSD) generation, synthetic data creation, optimization, and solver validation.
The test script performs the following operations sequentially:
PSD Data Generation: Creates initial particle size distribution data that serves as the computational initial condition for subsequent simulations.
Synthetic Data Generation: Generates synthetic data for optimizer testing. This process internally invokes the DPBESolver to perform numerical solving and creates artificial datasets that mimic experimental data.
Optimization Testing: The optimizer reads the synthetic data and performs optimization to test the functionality of the optimization algorithms.
Delta Calculation: Executes run_calc_delta which performs a single cost function calculation within the optimization process. This is a common debugging approach for optimizers to verify the objective function computation.
Solver Validation: Calls three different solvers from the library: - DPBESolver (Discrete Population Balance Equation Solver) - PBMSolver (Population Balance Model Solver) - MCPBESolver (Monte Carlo Population Balance Equation Solver)
All three solvers simulate the same input parameters and their results are compared for consistency validation.
- Expected Output:
If the program runs successfully, it will generate comparison plots showing the 0th, 1st, and 2nd order moments. The results from all three solvers should be essentially identical.
- Usage:
Run this script directly to execute the full test suite:
`python python all_test.py `
Individual test components can be controlled by modifying the boolean flags: - generate_synth_data: Controls synthetic data generation - run_opt: Controls optimization testing - run_calc_delta: Controls delta calculation testing - run_validation: Controls solver validation testing
- Dependencies:
numpy: Numerical computations
ray: Parallel processing for optimization
pathlib: Path handling
optframework: Main optimization framework modules
- Note:
This script serves as both a functionality test and a demonstration of the OptFramework library capabilities. It can be used for regression testing, performance validation, and as a reference implementation.
Created on Thu Jan 4 14:53:00 2024
@author: Haoran Ji