Skip to content
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

Bugfix/matrix utilization #7

Merged
merged 27 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
54d7845
Fixed indexing bug on intervals
mjducut-oe Oct 3, 2024
ecc5ccf
Task Allocator stable
mjducut-oe Oct 4, 2024
0597b99
Updated task allocator + added test cases
mjducut-oe Oct 4, 2024
582677a
Removed initial prints
mjducut-oe Oct 4, 2024
7821a0e
Core and test changes
mjducut-oe Oct 8, 2024
1e39830
Fixed get_resource_interval_function
mjducut-oe Oct 9, 2024
7f4de82
Bugfix non-owned interval
mjducut-oe Oct 14, 2024
e6585b7
Ignored inpults folder
mjducut-oe Oct 14, 2024
0373f94
Constraints + assignments stable
mjducut-oe Oct 15, 2024
309c4b6
Updated cumsum_reset and pytest
mjducut-oe Oct 16, 2024
0a31390
Reverted cumsum reset index function
mjducut-oe Oct 16, 2024
9ab20d1
Current Updates
mjducut-oe Oct 16, 2024
4589698
Updates
mjducut-oe Oct 16, 2024
70191f8
Task allocator update
mjducut-oe Oct 17, 2024
59fcedf
Committing for branch change
mjducut-oe Oct 17, 2024
81119fb
Used matrices for getting resource intervals
mjducut-oe Oct 17, 2024
e8eee22
Stable scheduler
mjducut-oe Oct 17, 2024
d30f06a
Updated get_resource_intervals test
mjducut-oe Oct 21, 2024
3b2df6f
Updated find indexes test
mjducut-oe Oct 21, 2024
5964f6c
Updated test _cumsum_reset_at_minus_one
mjducut-oe Oct 21, 2024
1f785cc
Reverted cumsum at minus -1 test
mjducut-oe Oct 21, 2024
22dc0a7
Updates to test and task allocator
mjducut-oe Oct 22, 2024
2ac6f16
Updated task allocator comments
mjducut-oe Oct 22, 2024
4a31734
Ignored files with .ipynb extensions
mjducut-oe Oct 22, 2024
610d132
Move files to notebooks folder
mjducut-oe Oct 22, 2024
464aa79
Deleted stresstest
mjducut-oe Oct 22, 2024
cb018dc
Added find_first_index function and a window counter
mjducut-oe Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Prototyping Notebooks
notebooks/
*.ipynb

# Test data
inputs/

# vscode settings
.vscode/
Expand Down
16 changes: 13 additions & 3 deletions src/factryengine/models/task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field, model_validator, validator
from pydantic import BaseModel, Field, model_validator, validator, PrivateAttr

from .resource import Resource, ResourceGroup

Expand Down Expand Up @@ -44,15 +44,16 @@ def get_unique_resources(self) -> set[Resource]:


class Task(BaseModel):
id: int
id: int | str
name: str = ""
duration: int = Field(gt=0)
priority: int = Field(gt=0)
assignments: list[Assignment] = []
constraints: set[Resource] = set()
predecessor_ids: set[int] = set()
predecessor_ids: set[int] | set[str] = set()
predecessor_delay: int = Field(0, gt=0)
quantity: int = Field(None, gt=0)
_batch_id: int = PrivateAttr(None)

def __hash__(self):
return hash(self.id)
Expand Down Expand Up @@ -85,3 +86,12 @@ def set_name(cls, v, values) -> str:
def get_id(self) -> int:
"""returns the task id"""
return self.id

@property
def batch_id(self):
"""returns the batch id of the task"""
return self._batch_id

def set_batch_id(self, batch_id):
"""sets the batch id of the task"""
self._batch_id = batch_id
9 changes: 5 additions & 4 deletions src/factryengine/scheduler/heuristic_solver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,25 @@ def solve(self) -> list[dict]:
except AllocationError as e:
self.mark_task_as_unscheduled(task_id=task_id, error_message=str(e))
continue

# update resource windows
self.window_manager.update_resource_windows(allocated_resource_windows_dict)

# Append task values

task_values = {
"task_id": task_id,
"assigned_resource_ids": list(allocated_resource_windows_dict.keys()),
"task_start": min(
start for start, _ in allocated_resource_windows_dict.values()
start for intervals in allocated_resource_windows_dict.values() for start, _ in intervals
),
"task_end": max(
end for _, end in allocated_resource_windows_dict.values()
end for intervals in allocated_resource_windows_dict.values() for _, end in intervals
),
"resource_intervals": allocated_resource_windows_dict.values(),
}
self.task_vars[task_id] = task_values


return list(
self.task_vars.values()
) # Return values of the dictionary as a list
Expand Down
7 changes: 5 additions & 2 deletions src/factryengine/scheduler/heuristic_solver/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ def trim_end(cls, original_matrix: "Matrix", trim_matrix: "Matrix") -> "Matrix":
Trims a Matrix based on another
"""
new_intervals = original_matrix.intervals[: len(trim_matrix.intervals)]
# Check if intervals are the same

if not np.array_equal(new_intervals, trim_matrix.intervals):
# if not np.array_equal(new_intervals, trim_matrix.intervals):
# raise ValueError("All matrices must have the same intervals")

# Used np.allclose to allow for small differences in the intervals
if not np.allclose(new_intervals, trim_matrix.intervals, atol=1e-8):
raise ValueError("All matrices must have the same intervals")

return cls(
Expand Down
Loading
Loading