emat/model/core_files/core_files.py
def run_model(self, scenario, policy):
		"""
		Runs an experiment through core model.

		This method overloads the `run_model` method given in
		the EMA Workbench, and provides the correct execution
		of the GBNRTC model within that framework.

		For each experiment, the core model is called to:

			1. set experiment variables
			2. run the experiment
			3. run post-processors associated with specified
			   performance measures
			4. (optionally) archive model outputs
			5. record performance measures to database

		Note that this method does *not* return any outcomes.
		Outcomes are instead written into self.outcomes_output,
		and can be retrieved from there.

		Args:
			scenario (Scenario): A dict-like object that
				has key-value pairs for each uncertainty.
			policy (Policy): A dict-like object that
				has key-value pairs for each lever.

		Raises:
			UserWarning: If there are no experiments associated with
				this type.

		"""

		_logger.debug("run_core_model read_experiment_parameters")

		experiment_id = self.db.read_experiment_id(self.scope.name, None, scenario, policy)

		if experiment_id is not None and self.allow_short_circuit:
			# opportunity to short-circuit run by loading pre-computed values.
			precomputed = self.db.read_experiment_measures(
				self.scope.name,
				design=None,
				experiment_id=experiment_id,
			)
			if not precomputed.empty:
				self.outcomes_output = dict(precomputed.iloc[0])
				return

		if experiment_id is None:
			experiment_id = self.db.write_experiment_parameters_1(
				self.scope.name, 'ad hoc', scenario, policy
			)

		xl = {}
		xl.update(scenario)
		xl.update(policy)

		m_names = self.scope.get_measure_names()

		m_out = pd.DataFrame()

		_logger.debug(f"run_core_model setup {experiment_id}")
		self.setup(xl)

		_logger.debug(f"run_core_model run {experiment_id}")
		self.run()

		_logger.debug(f"run_core_model post_process {experiment_id}")
		self.post_process(xl, m_names)

		_logger.debug(f"run_core_model wrap up {experiment_id}")
		measures_dictionary = self.load_measures(m_names)
		m_df = pd.DataFrame(measures_dictionary, index=[experiment_id])

		# Assign to outcomes_output, for ema_workbench compatibility
		self.outcomes_output = measures_dictionary

		_logger.debug(f"run_core_model write db {experiment_id}")
		self.db.write_experiment_measures(self.scope.name, self.metamodel_id, m_df)

		try:
			archive_path = self.get_experiment_archive_path(experiment_id)
		except MissingArchivePathError:
			pass
		else:
			_logger.debug(f"run_core_model archive {experiment_id}")
			self.archive(xl, archive_path, experiment_id)

		Runs an experiment through core model.

		This method overloads the `run_model` method given in
		the EMA Workbench, and provides the correct execution
		of the GBNRTC model within that framework.

		For each experiment, the core model is called to:

			1. set experiment variables
			2. run the experiment
			3. run post-processors associated with specified
			   performance measures
			4. (optionally) archive model outputs
			5. record performance measures to database

		Note that this method does *not* return any outcomes.
		Outcomes are instead written into self.outcomes_output,
		and can be retrieved from there.

		Args:
			scenario (Scenario): A dict-like object that
				has key-value pairs for each uncertainty.
			policy (Policy): A dict-like object that
				has key-value pairs for each lever.

		Raises:
			UserWarning: If there are no experiments associated with
				this type.

		
Runs an experiment through core model.
This method overloads the `run_model` method given in
the EMA Workbench, and provides the correct execution
of the GBNRTC model within that framework.

For each experiment, the core model is called to.

1. set experiment variables
2. run the experiment
3. run post-processors associated with specified
performance measures
4. (optionally) archive model outputs
5. record performance measures to database

Note that this method does *not* return any outcomes.
Outcomes are instead written into self.outcomes_output,
and can be retrieved from there.
Runs an experiment through core model . This method overloads the ` run_model ` method given in the EMA Workbench and provides the correct execution of the GBNRTC model within that framework . For each experiment the core model is called to . 1 . set experiment variables 2 . run the experiment 3 . run post - processors associated with specified performance measures 4 . ( optionally ) archive model outputs 5 . record performance measures to database Note that this method does * not * return any outcomes . Outcomes are instead written into self . outcomes_output and can be retrieved from there .
def run_model(self, scenario, policy):
		_logger.debug("run_core_model read_experiment_parameters")
		experiment_id = self.db.read_experiment_id(self.scope.name, None, scenario, policy)
		if experiment_id is not None and self.allow_short_circuit:
			precomputed = self.db.read_experiment_measures(
				self.scope.name,
				design=None,
				experiment_id=experiment_id,
			)
			if not precomputed.empty:
				self.outcomes_output = dict(precomputed.iloc[0])
				return
		if experiment_id is None:
			experiment_id = self.db.write_experiment_parameters_1(
				self.scope.name, 'ad hoc', scenario, policy
			)
		xl = {}
		xl.update(scenario)
		xl.update(policy)
		m_names = self.scope.get_measure_names()
		m_out = pd.DataFrame()
		_logger.debug(f"run_core_model setup {experiment_id}")
		self.setup(xl)
		_logger.debug(f"run_core_model run {experiment_id}")
		self.run()
		_logger.debug(f"run_core_model post_process {experiment_id}")
		self.post_process(xl, m_names)
		_logger.debug(f"run_core_model wrap up {experiment_id}")
		measures_dictionary = self.load_measures(m_names)
		m_df = pd.DataFrame(measures_dictionary, index=[experiment_id])
		self.outcomes_output = measures_dictionary
		_logger.debug(f"run_core_model write db {experiment_id}")
		self.db.write_experiment_measures(self.scope.name, self.metamodel_id, m_df)
		try:
			archive_path = self.get_experiment_archive_path(experiment_id)
		except MissingArchivePathError:
			pass
		else:
			_logger.debug(f"run_core_model archive {experiment_id}")
			self.archive(xl, archive_path, experiment_id)
def run_model ( self , scenario , policy ) : _logger . debug ( "run_core_model read_experiment_parameters" ) experiment_id = self . db . read_experiment_id ( self . scope . name , None , scenario , policy ) if experiment_id is not None and self . allow_short_circuit : precomputed = self . db . read_experiment_measures ( self . scope . name , design = None , experiment_id = experiment_id , ) if not precomputed . empty : self . outcomes_output = dict ( precomputed . iloc [ 0 ] ) return if experiment_id is None : experiment_id = self . db . write_experiment_parameters_1 ( self . scope . name , 'ad hoc' , scenario , policy ) xl = { } xl . update ( scenario ) xl . update ( policy ) m_names = self . scope . get_measure_names ( ) m_out = pd . DataFrame ( ) _logger . debug ( f"run_core_model setup {experiment_id}" ) self . setup ( xl ) _logger . debug ( f"run_core_model run {experiment_id}" ) self . run ( ) _logger . debug ( f"run_core_model post_process {experiment_id}" ) self . post_process ( xl , m_names ) _logger . debug ( f"run_core_model wrap up {experiment_id}" ) measures_dictionary = self . load_measures ( m_names ) m_df = pd . DataFrame ( measures_dictionary , index = [ experiment_id ] ) self . outcomes_output = measures_dictionary _logger . debug ( f"run_core_model write db {experiment_id}" ) self . db . write_experiment_measures ( self . scope . name , self . metamodel_id , m_df ) try : archive_path = self . get_experiment_archive_path ( experiment_id ) except MissingArchivePathError : pass else : _logger . debug ( f"run_core_model archive {experiment_id}" ) self . archive ( xl , archive_path , experiment_id )
Runs an experiment through core model.
Runs an experiment through core model .
"""
		Runs an experiment through core model.

		This method overloads the `run_model` method given in
		the EMA Workbench, and provides the correct execution
		of the GBNRTC model within that framework.

		For each experiment, the core model is called to:

			1. set experiment variables
			2. run the experiment
			3. run post-processors associated with specified
			   performance measures
			4. (optionally) archive model outputs
			5. record performance measures to database

		Note that this method does *not* return any outcomes.
		Outcomes are instead written into self.outcomes_output,
		and can be retrieved from there.

		Args:
			scenario (Scenario): A dict-like object that
				has key-value pairs for each uncertainty.
			policy (Policy): A dict-like object that
				has key-value pairs for each lever.

		Raises:
			UserWarning: If there are no experiments associated with
				this type.

		""" # opportunity to short-circuit run by loading pre-computed values. # Assign to outcomes_output, for ema_workbench compatibility
If there are no experiments associated with
this type.
If there are no experiments associated with this type .
UserWarning
self
scenario
A dict-like object that
has key-value pairs for each uncertainty.
A dict - like object that has key - value pairs for each uncertainty .
policy
A dict-like object that
has key-value pairs for each lever.
A dict - like object that has key - value pairs for each lever .