Skip to content

Implemented 11.1 Job-Shop-Problem #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
complete HLA and Problem implementations
  • Loading branch information
KaiRawal committed Mar 26, 2017
commit b17f84be14f6a61149bd4c09b4113c8e3aa52d08
27 changes: 26 additions & 1 deletion planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@ def __init__(self, action, precond=[None,None], effect=[None,None], duration=0,
#self.priority = -1 # must be assigned in relation to other HLAs
#self.job_group = -1 # must be assigned in relation to other HLAs

def do_action(self, job_order, available_resources, kb, args):
#print(self.name)
if (not self.has_usable_resource(available_resources) or
not self.has_consumable_resource(available_resources) ):
raise Exception('Not enough resources to execute {}'.format(self.name))
if not self.inorder(job_order):
raise Exception("Can't execute {} - execute prerequisite actions first".format(self.name))
super().act(kb, args)
self.completed = True

def has_consumable_resource(self, available_resources):
for resource in self.consumes:
if available_resources.get(resource) is None:
Expand All @@ -617,7 +627,7 @@ def inorder(self, job_order):
if job.completed == False:
return False
return True

#def __call__(self, kb, args, resources):
# if self.check_resources(resources):
# return self.act(kb, args)
Expand Down Expand Up @@ -650,4 +660,19 @@ def __init__(self, initial_state, actions, goal_test, jobs=None, resources={}):
super().__init__(initial_state, actions, goal_test)
self.jobs = jobs
self.resources = resources

def act(self, action):
"""
Performs the HLA given as argument.

Note that this is different from the superclass action - where the parameter was an
Expression. For real world problems, an Expr object isn't enough to capture all the
detail required for executing the action - resources, preconditions, etc need to be
checked for too.
"""
args = action.args
list_action = first(a for a in self.actions if a.name == action.name)
if list_action is None:
raise Exception("Action '{}' not found".format(action.name))
list_action.do_action(self.jobs, self.resources, self.kb, args)

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy