22This module contains the core "evaluation" function for Method Of Morris. It needs to be isolated
33(outside of class) to enable parallelization.
44"""
5+
56from __future__ import annotations
67
78import logging
1920 from temoa .core .config import TemoaConfig
2021
2122
22-
2323def configure_worker_logger (log_queue : Any , log_level : int ) -> logging .Logger :
2424 """configure the logger"""
2525 worker_logger = logging .getLogger ('MM evaluate' )
@@ -35,8 +35,15 @@ def configure_worker_logger(log_queue: Any, log_level: int) -> logging.Logger:
3535 return worker_logger
3636
3737
38- def evaluate (param_info : dict [int , list [Any ]], mm_sample : Any , data : dict [str , Any ],
39- i : int , config : TemoaConfig , log_queue : Any , log_level : int ) -> list [float ]:
38+ def evaluate (
39+ param_info : dict [int , list [Any ]],
40+ mm_sample : Any ,
41+ data : dict [str , Any ],
42+ i : int ,
43+ config : TemoaConfig ,
44+ log_queue : Any ,
45+ log_level : int ,
46+ ) -> list [float ]:
4047 """
4148 Run model for params provided and return objective value and emission value
4249 Note: This function needs to be a static instance to enable the parallel
@@ -81,6 +88,7 @@ def evaluate(param_info: dict[int, list[Any]], mm_sample: Any, data: dict[str, A
8188 with TableWriter (config ) as table_writer :
8289 table_writer .write_mm_results (model = mdl , iteration = i )
8390 import contextlib
91+
8492 with contextlib .closing (sqlite3 .connect (config .input_database )) as con :
8593 cur = con .cursor ()
8694 scenario_name = config .scenario + f'-{ i } '
0 commit comments