Skip to content

Commit

Permalink
OA-Systems: Online Adaptive Systems #612
Browse files Browse the repository at this point in the history
  • Loading branch information
laxmikantbaheti committed May 29, 2023
1 parent ae5895e commit 165e1b5
Showing 1 changed file with 74 additions and 13 deletions.
87 changes: 74 additions & 13 deletions src/mlpro/oa/systems/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _run( self,
# self._processing_wf.add_task(PseudoTask(p_wrap_method = self._wrap_method))
# return False
#
#

# ## -------------------------------------------------------------------------------------------------
# def add_task(self, p_task : StreamTask, p_pred_tasks: list = None):
# """
Expand Down Expand Up @@ -275,7 +275,7 @@ def simulate_reaction(self, p_state: State, p_action: Action, p_t_step : timedel


# 6. Run the workflow
self._wf.run(p_inst_new=[self._instance])
self._wf.run(p_inst_new=[p_state])


# 7. Return the results
Expand Down Expand Up @@ -367,12 +367,31 @@ def _run(self, p_inst_new, p_inst_del):
-------
"""

self.get_so().add_result(self.get_id(), FctSTrans.simulate_reaction(self,
try:
self.get_so().add_result(self.get_id(), AFctSTrans._simulate_reaction(self,
p_state=self._state,
p_action=self._action))
except:
self.get_so().add_result(self.get_id(), FctSTrans.simulate_reaction(self,
p_state=self._state,
p_action=self._action))


## -------------------------------------------------------------------------------------------------
def _setup_fct_workflow(self):
"""
Returns
-------
"""

self._wf.add_task(PseudoTask(p_wrap_method = self._run))
return False







Expand Down Expand Up @@ -494,7 +513,7 @@ def compute_success(self, p_state: State) -> bool:


# 6. Run the workflow
self._wf_success.run(p_inst_new=[self._instance])
self._wf_success.run(p_inst_new=[p_state])


# 7. Return the results
Expand Down Expand Up @@ -548,7 +567,7 @@ def _add_task(self, p_task:StreamTask, p_pred_tasks:list = None):


## -------------------------------------------------------------------------------------------------
def _run(self, p_inst_new, p_inst_del):
def _run_wf_success(self, p_inst_new, p_inst_del):
"""
Parameters
Expand All @@ -560,7 +579,11 @@ def _run(self, p_inst_new, p_inst_del):
-------
"""
self.get_so().add_result(self.get_id(), FctSuccess.compute_success(self,
try:
self.get_so().add_result(self.get_id(), AFctSuccess._compute_success(self,
p_state=self._state))
except:
self.get_so().add_result(self.get_id(), FctSuccess.compute_success(self,
p_state=self._state))


Expand Down Expand Up @@ -588,6 +611,20 @@ def _adapt(self, **p_kwargs) -> bool:
return adapted


## -------------------------------------------------------------------------------------------------
def _setup_fct_workflow(self):
"""
Returns
-------
"""

self._wf_success.add_task(PseudoTask(p_wrap_method = self._run_wf_success))
return False






Expand Down Expand Up @@ -712,7 +749,7 @@ def compute_broken(self, p_state: State) -> bool:


# 6. Run the workflow
self._wf_broken.run(p_inst_new=[self._instance])
self._wf_broken.run(p_inst_new=[p_state])


# 7. Return the results
Expand Down Expand Up @@ -750,7 +787,7 @@ def add_task(self, p_task: StreamTask, p_pred_tasks:list = None):


## -------------------------------------------------------------------------------------------------
def _run(self, p_inst_new, p_inst_del):
def _run_wf_broken(self, p_inst_new, p_inst_del):
"""
Parameters
Expand All @@ -762,7 +799,11 @@ def _run(self, p_inst_new, p_inst_del):
-------
"""
self.get_so().add_result(self.get_id(), FctBroken.compute_broken(self,
try:
self.get_so().add_result(self.get_id(), AFctBroken._compute_broken(self,
p_state=self._state))
except:
self.get_so().add_result(self.get_id(), FctBroken._compute_broken(self,
p_state=self._state))


Expand Down Expand Up @@ -806,13 +847,27 @@ def _adapt_on_event(self, p_event_id:str, p_event_object:Event) -> bool:
pass


## -------------------------------------------------------------------------------------------------
def _setup_fct_workflow(self):
"""
Returns
-------
"""

self._wf_broken.add_task(PseudoTask(p_wrap_method = self._run_wf_broken))
return False







## -------------------------------------------------------------------------------------------------
## -------------------------------------------------------------------------------------------------
class OASystem(ASystem):
class OASystem(ASystem, OAFctSTrans, OAFctSuccess, OAFCtBroken):
"""
Parameters
Expand All @@ -835,7 +890,9 @@ def __init__(self,
p_fct_strans : FctSTrans = None,
p_fct_success : FctSuccess = None,
p_fct_broken : FctBroken = None,
p_processing_wf : StreamWorkflow = None,
p_wf : OAWorkflow = None,
p_wf_success : OAWorkflow = None,
p_wf_broken : OAWorkflow = None,
p_visualize : bool = False,
p_logging = Log.C_LOG_ALL):

Expand All @@ -848,7 +905,11 @@ def __init__(self,
p_visualize = p_visualize,
p_logging = p_logging)

self._processing_wf = p_processing_wf
OAFctSTrans.__init__(self, p_wf=p_wf)

OAFctSuccess.__init__(self, p_wf=p_wf_success)

OAFCtBroken.__init__(self, p_wf_broken=p_wf_broken)



Expand Down

0 comments on commit 165e1b5

Please sign in to comment.