@@ -45,13 +45,8 @@ def build_item(i: Instance, graph: GraphInstance, p: int, e: int, head: bool, es
45
45
pr_ids : list = []
46
46
pm_ids : list = []
47
47
for o in range (start , end ):
48
- if o > start :
49
- op_start = op_start + operation_mean_time
50
- else :
51
- op_start = estimated_start
52
48
succs = end - (o + 1 )
53
49
operation_load = i .operation_time (p ,o , total_load = True )
54
- operation_mean_time = i .operation_time (p ,o , total_load = False )
55
50
required_res = 0
56
51
required_mat = 0
57
52
for rt in i .required_rt (p , o ):
@@ -99,15 +94,15 @@ def build_item(i: Instance, graph: GraphInstance, p: int, e: int, head: bool, es
99
94
estimated_childrend_end = _base_design_end
100
95
estimated_children_cost = 0
101
96
for children in graph .direct_children [p ][e ]:
102
- graph , child_id , estimated_end_child , child_cost = build_item (i , graph , p , e = children , head = False , estimated_start = estimated_start_child , must_be_outsourced = must_be_outsourced )
97
+ child_id , estimated_end_child , child_cost = build_item (i , graph , p , e = children , head = False , estimated_start = estimated_start_child , must_be_outsourced = must_be_outsourced )
103
98
graph .add_item_assembly (item_id , child_id )
104
99
estimated_childrend_end = max (estimated_childrend_end , estimated_end_child )
105
100
estimated_children_cost += child_cost
106
101
external_end = estimated_start + i .outsourcing_time [p ][e ]
107
102
internal_end = estimated_childrend_end + physical_mean_time
108
103
estimated_end = external_end if must_be_outsourced else min (external_end , internal_end ) if i .external [p ][e ] else internal_end
109
104
mandatory_cost = estimated_children_cost + (i .external_cost [p ][e ] if must_be_outsourced else 0 )
110
- return graph , item_id , estimated_end , mandatory_cost
105
+ return item_id , estimated_end , mandatory_cost
111
106
112
107
def build_precedence (i : Instance , graph : GraphInstance ):
113
108
for p in i .loop_projects ():
@@ -133,7 +128,6 @@ def build_precedence(i: Instance, graph: GraphInstance):
133
128
for pfp in parent_first_physical :
134
129
succ_id = graph .operations_i2g [p ][pfp ]
135
130
graph .add_precedence (o_id , succ_id )
136
- return graph
137
131
138
132
def build_direct_access_objects (i : Instance , graph : GraphInstance ):
139
133
for p in i .loop_projects ():
@@ -164,11 +158,20 @@ def build_direct_access_objects(i: Instance, graph: GraphInstance):
164
158
graph .operation_resource_time [p ][o ].append (i .operation_resource_time (p , o , rt , max_load = True ))
165
159
for r in i .loop_resources ():
166
160
graph .resource_family .append (i .get_resource_familly (r ))
167
- return graph
161
+
162
+ def rec_lower_bound (i : Instance , graph : GraphInstance , p : int , o : int , start : int , next_operations : list [list [list [int ]]]):
163
+ graph .update_operation (graph .operations_i2g [p ][o ], [('lb' , start )], maxx = True )
164
+ for next in next_operations [p ][o ]:
165
+ rec_lower_bound (i , graph , p , next , start + i .operation_time (p , o , total_load = False ), next_operations )
166
+
167
+ def build_lower_bounds (i : Instance , graph : GraphInstance , next_operations : list [list [list [int ]]]):
168
+ for p in i .loop_projects ():
169
+ for o in i .first_operations (p , i .project_head (p )):
170
+ rec_lower_bound (i , graph , p , o , 0 , next_operations )
168
171
169
172
def translate (i : Instance , device : str ):
170
173
graph = GraphInstance (device = device )
171
- graph = build_direct_access_objects (i , graph )
174
+ build_direct_access_objects (i , graph )
172
175
for rt in range (i .nb_resource_types ):
173
176
resources = i .resources_by_type (rt )
174
177
operations = i .operations_by_resource_type (rt )
@@ -195,14 +198,15 @@ def translate(i: Instance, device: str):
195
198
Cmax_lower_bound = 0
196
199
cost_lower_bound = 0
197
200
for p in i .loop_projects ():
198
- graph , _ , project_end , project_cost = build_item (i , graph , p , e = i .project_head (p ), head = True , estimated_start = 0 , must_be_outsourced = False )
201
+ _ , project_end , project_cost = build_item (i , graph , p , e = i .project_head (p ), head = True , estimated_start = 0 , must_be_outsourced = False )
199
202
Cmax_lower_bound = max (Cmax_lower_bound , project_end )
200
203
cost_lower_bound += project_cost
201
204
graph .operations_i2g = graph .build_i2g_2D (graph .operations_g2i )
202
205
graph .items_i2g = graph .build_i2g_2D (graph .items_g2i )
203
206
graph .add_dummy_item (device = device )
204
- graph = build_precedence (i , graph )
207
+ build_precedence (i , graph )
205
208
previous_operations , next_operations = i .build_next_and_previous_operations ()
209
+ build_lower_bounds (i , graph , next_operations )
206
210
related_items : Tensor = graph .flatten_related_items (device )
207
211
parent_items : Tensor = graph .flatten_parents (device )
208
212
return graph , Cmax_lower_bound , cost_lower_bound , previous_operations , next_operations , related_items , parent_items
0 commit comments