You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/usage.md
+48-18
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# Usage
2
2
3
-
The `factryengine` package contains three main components: `Resource`, `Task`, and `Scheduler`. Below is the documentation for using each of these components.
3
+
The `factryengine` package contains three main components: `Resource`, `ResourceGroup`, `Assignment`, `Task`, and `Scheduler`. Below is the documentation for using each of these components.
4
4
5
-
## Resource
5
+
## Resource and ResourceGroup
6
6
7
7
The `Resource` class is used to represent a resource in the scheduling problem. Below is an example of how to create a `Resource` object.
8
8
@@ -21,6 +21,41 @@ resource = Resource(
21
21
-`id` (`int`): Unique identifier for the resource.
22
22
-`available_windows` (`list[tuple[int, int]]`): List of available windows for the resource represented as tuples of start and end times.
23
23
24
+
---
25
+
26
+
We can put multiple resources into a group which can be used for dynamic assignments.
27
+
28
+
```python
29
+
from factryengine import ResourceGroup
30
+
31
+
# create resource objects
32
+
operator1 = Resource(
33
+
id=2,
34
+
available_windows=[(0, 5), (10, 15)],
35
+
)
36
+
operator2 = Resource(
37
+
id=3,
38
+
available_windows=[(0, 5), (10, 15)],
39
+
)
40
+
41
+
# add them to resource group
42
+
43
+
operators = ResourceGroup([operator1, operator2])
44
+
```
45
+
46
+
## Assignment
47
+
48
+
Assignments are used for allocating resources to tasks dynamically. You dont need to hardcode the resources you can instead select a pool of resource that could do the task. The algorithm will select the subset which finishes the task the fastest.
-`resource_groups` (`list[ResouceGroup]`): The resource groups which can be picked from. If multiple resource groups are added then the fastest completing resourcegroup will be selected.
56
+
-`resource_count` (`int`): The maximum number of resources which may be selected.
57
+
-`use_all_resources` (`bool`): if you want to allow to use all resources in a group then simple set use_all_resources to True.
58
+
24
59
## Task
25
60
26
61
The `Task` class is used to represent a task in the scheduling problem. Below is an example of how to create a `Task` object, reusing the `resource` object created above.
@@ -33,9 +68,9 @@ task = Task(
33
68
id=1,
34
69
duration=5,
35
70
priority=1,
36
-
resources=[[resource]],
37
-
resource_count=1,
38
-
predecessors=[],
71
+
constraints=[resource],
72
+
assigments=[assignment]
73
+
predecessor_ids=[1],
39
74
predecessor_delay=0,
40
75
)
41
76
```
@@ -45,26 +80,21 @@ task = Task(
45
80
-`id` (`int | str`): Unique identifier for the task.
46
81
-`duration` (`int`): Duration of the task with a constraint of being greater than 0.
47
82
-`priority` (`int`): Priority of the task with a constraint of being greater than 0.
48
-
-`resources` (`list[set[Resource]]`): List of sets of resources required by the task.
49
-
-`resource_count` (`int | str`): Number of resources required by the task.
50
-
-`predecessors` (`list["Task"]`): List of predecessor tasks.
83
+
-`constraints` (`set[Resource]`): Are resource which are required througout the task.
84
+
-`assignments` (list[Assignment]): Are used to dynamically assign resources to tasks. If 2 resources are allocated, the task will finish twice as fast.
85
+
86
+
-`predecessor_ids` (`list[int]`): List of predecessor task ids.
51
87
-`predecessor_delay` (`int`): Buffer time after the completion of predecessor tasks before the current task can commence, must be greater than 0.
52
-
53
-
!!! tip
54
-
Resource count allows you to specifiy to use all resources specified:
55
-
```python
56
-
resource_count = "all"
57
-
```
58
88
59
89
## Scheduler
60
90
61
-
The `Scheduler` class is used to schedule tasks based on their priorities, durations, and resources. Below is an example of how to use the `Scheduler` class, reusing the `task`object created above.
91
+
The `Scheduler` class is used to schedule tasks based on their priorities, durations, and resources. Below is an example of how to use the `Scheduler` class, reusing the `task`and `resource` objects created above.
0 commit comments