Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetan1988 authored Aug 21, 2023
2 parents 939b8ae + ad63841 commit 24de6d2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/rule_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def prepare_data(file_path="./data/k1.json"):
re_name = re["machineName"]
re_id = int(re_name.replace("M", ""))
resource = Resource(resource_id=re_id, resource_name=re_name)
resource.available_hours = list(range(1, 151))
resource_collector.add_resource_dict({re_id: resource})
# print([i.resource_id for i in resource_collector.get_all_resources()])
# print(resource_collector.get_all_resources()[0].available_hours)
Expand Down Expand Up @@ -88,6 +87,7 @@ def prepare_data(file_path="./data/k1.json"):
def run_scheduling(job_collector, resource_collector, route_collector):
# scheduler = ForwardScheduler(job_collector, resource_collector, route_collector)
scheduler = BackwardScheduler(job_collector, resource_collector, route_collector)

scheduler.run()
return

Expand Down
1 change: 1 addition & 0 deletions lekin/lekin_struct/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_latest_available_time(self, duration=None, end=None):
self.update_continuous_empty_hours()
return max([i + 1 for (i, v) in enumerate(self.continuous_empty_hours[:end]) if v >= duration])


def update_continuous_empty_hours(self):
if len(self.available_hours) != len(self._available_timeslots):
pass
Expand Down
2 changes: 2 additions & 0 deletions lekin/solver/construction_heuristics/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def scheduling_job(self, job, resource_collector, route_collector):

op_earliest_start = 0 # forward constraint
op_latest_end = 150 # backward constraint

for operation in job.operations[::-1]: # inverse for backward
logging.info(f"\tAssign Operation {operation.operation_id} of Job {job.job_id}")
chosen_resource, chosen_timeslot_hour = self.find_best_resource_and_timeslot_for_operation(
Expand Down Expand Up @@ -86,6 +87,7 @@ def find_best_resource_and_timeslot_for_operation(
chosen_resource = available_resource[latest_index]
latest_time = int(min(op_latest_end, resource_latest_time))
chosen_hours = list(range(latest_time - math.ceil(operation.processing_time), latest_time + 1))

return chosen_resource, chosen_hours

def assign_operation(self, operation, start_time, end_time, resources):
Expand Down

0 comments on commit 24de6d2

Please sign in to comment.