from CADETProcess.simulation import Cadet, ProcessEvaluator from CADETProcess.optimization import OptimizationProblem from CADETProcess.common import RankedPerformance from case_2a_simulation import batch_long_ternary process_simulator = Cadet() process_simulator.evaluate_stationarity = True ranking = [1, 1, 1] purity_required = [0.95, 0.95, 0.95] evaluator = ProcessEvaluator(process_simulator, purity_required, ranking) optimization_problem = OptimizationProblem(batch_long_ternary, evaluator, name='case_2a', save_log=True) def objective_function(performance): ranked = RankedPerformance(performance, ranking) return -ranked.productivity * ranked.recovery * ranked.eluent_consumption optimization_problem.objective_fun = objective_function optimization_problem.add_variable('cycle_time', lb=10, ub=1200) optimization_problem.add_variable('feed_duration.time', lb=10, ub=100) optimization_problem.add_linear_constraint( opt_vars=['feed_duration.time', 'cycle_time'], factors=[1, -1], b=0)
purity_required = [0.95, 0.95] ranking = [1, 1] def fractionation_objective(performance): performance = RankedPerformance(performance, ranking) return -performance.mass fractionation_optimizer = FractionationOptimizer(purity_required, fractionation_objective) evaluator = ProcessEvaluator(process_simulator, fractionation_optimizer) optimization_problem = OptimizationProblem(batch_binary, evaluator, save_log=True) def objective_function(performance): performance = RankedPerformance(performance, ranking) return -performance.mass * performance.recovery * performance.eluent_consumption optimization_problem.add_objective(objective_function) optimization_problem.add_variable('cycle_time', lb=10, ub=600) optimization_problem.add_variable('feed_duration.time', lb=10, ub=300) optimization_problem.add_linear_constraint( ['feed_duration.time', 'cycle_time'], [1, -1])
from CADETProcess.simulation import Cadet, ProcessEvaluator from CADETProcess.optimization import OptimizationProblem from CADETProcess.common import RankedPerformance from case_4_simulation import serial_ternary process_simulator = Cadet() process_simulator.evaluate_stationarity = True ranking = [1, 1, 0] purity_required = [0.95, 0.95, 0] evaluator = ProcessEvaluator(process_simulator, purity_required, ranking) optimization_problem = OptimizationProblem(serial_ternary, evaluator, name='case_4', save_log=True) def objective_function(performance): ranked = RankedPerformance(performance, ranking) return -ranked.productivity * ranked.recovery * ranked.eluent_consumption optimization_problem.objective_fun = objective_function optimization_problem.add_variable('cycle_time', lb=10, ub=600) optimization_problem.add_variable('feed_duration.time', lb=10, ub=100) optimization_problem.add_variable('serial_on.time', lb=0, ub=600) optimization_problem.add_variable('serial_off.time', lb=0, ub=600) optimization_problem.add_variable('flow_sheet.column_1.length', lb=0.1, ub=1.2)
from CADETProcess.simulation import Cadet, ProcessEvaluator from CADETProcess.optimization import OptimizationProblem from CADETProcess.common import RankedPerformance from case_3b_simulation import ssr_binary process_simulator = Cadet() process_simulator.evaluate_stationarity = True ranking = [1, 1] purity_required = [0.95, 0.95] evaluator = ProcessEvaluator(process_simulator, purity_required, ranking) optimization_problem = OptimizationProblem(ssr_binary, evaluator, name='case_3b', save_log=True) productivity_batch = 0.02193975356603516 recovery_batch = 0.7388888917708063 eluent_consumption_batch = 2.356279655342963 def objective_function(performance): ranked = RankedPerformance(performance, ranking) return -(ranked.productivity / productivity_batch + ranked.recovery / recovery_batch + ranked.eluent_consumption / eluent_consumption_batch) optimization_problem.objective_fun = objective_function
def setup_optimization_problem(self, frac): opt = OptimizationProblem(frac) opt.logger.setLevel(logging.WARNING) opt.add_objective(self.obj_fun) opt.add_nonlinear_constraint( nonlin_bounds_decorator(self.purity_required)(purity)) for evt in frac.events: opt.add_variable(evt.name + '.time', evt.name) for chrom_index, chrom in enumerate(frac.chromatograms): chrom_events = frac.chromatogram_events[chrom] evt_names = [evt.name for evt in chrom_events] for evt_index, evt in enumerate(chrom_events): if evt_index < len(chrom_events) - 1: opt.add_linear_constraint( [evt_names[evt_index], evt_names[evt_index + 1]], [1, -1]) else: opt.add_linear_constraint([evt_names[0], evt_names[-1]], [-1, 1], frac.cycle_time) opt.x0 = [evt.time for evt in frac.events] if not opt.check_nonlinear_constraints(opt.x0): raise CADETProcessError("No areas found with sufficient purity.") return opt