Jelajahi Sumber

Possibly fixed the DEVS model (runs in ~50 minutes)

Yentl Van Tendeloo 8 tahun lalu
induk
melakukan
25be0ad91b
3 mengubah file dengan 13 tambahan dan 11 penghapusan
  1. 4 4
      bootstrap/transform.alc
  2. 8 6
      model/model.py
  3. 1 1
      model/operations

+ 4 - 4
bootstrap/transform.alc

@@ -299,7 +299,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 	set_add_node(mappings, initial_mapping)
 	set_add_node(mappings, initial_mapping)
 	while (list_len(schedule) > 0):
 	while (list_len(schedule) > 0):
 		current_element = list_pop(schedule, list_len(schedule) - 1)
 		current_element = list_pop(schedule, list_len(schedule) - 1)
-		//log("Binding element with label " + cast_value(read_attribute(schedule_model, current_element, "label")))
+		log("Binding element with label " + cast_value(read_attribute(schedule_model, current_element, "label")))
 		new_mappings = dict_create()
 		new_mappings = dict_create()
 
 
 		while (set_len(mappings) > 0):
 		while (set_len(mappings) > 0):
@@ -313,7 +313,7 @@ Element function match(host_model : Element, schedule_model : Element, LHS : Str
 				set_add_node(new_mappings, new_map)
 				set_add_node(new_mappings, new_map)
 
 
 		mappings = new_mappings
 		mappings = new_mappings
-		//log("Remaining options: " + cast_value(set_len(mappings)))
+		log("Remaining options: " + cast_value(set_len(mappings)))
 
 
 		if (set_len(mappings) == 0):
 		if (set_len(mappings) == 0):
 			// Stop because we have no more options remaining!
 			// Stop because we have no more options remaining!
@@ -554,7 +554,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	Element mapping
 	Element mapping
 	Boolean result
 	Boolean result
 
 
-	//log("Executing rule: " + current)
+	log("Executing rule: " + current)
 
 
 	mappings = full_match(host_model, schedule_model, current, False)
 	mappings = full_match(host_model, schedule_model, current, False)
 
 
@@ -563,7 +563,7 @@ Boolean function transform_forall(host_model : Element, schedule_model : Element
 	else:
 	else:
 		result = False
 		result = False
 
 
-	//log("Matches in forall: " + cast_string(set_len(mappings)))
+	log("Matches in forall: " + cast_string(set_len(mappings)))
 	while (set_len(mappings) > 0):
 	while (set_len(mappings) > 0):
 		mapping = set_pop(mappings)
 		mapping = set_pop(mappings)
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))
 		RHS = set_pop(allAssociationDestinations(schedule_model, current, "RHSLink"))

+ 8 - 6
model/model.py

@@ -432,7 +432,6 @@ class ModelverseInterface(AtomicDEVS):
                     print("Adding 3 empty lists")
                     print("Adding 3 empty lists")
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
-                    self.state.operations.insert(0, None)
                 elif prev_output.startswith("Finished task: "):
                 elif prev_output.startswith("Finished task: "):
                     self.state.blocked = True
                     self.state.blocked = True
                 elif " : " in prev_output:
                 elif " : " in prev_output:
@@ -444,7 +443,10 @@ class ModelverseInterface(AtomicDEVS):
                     # NOTE We now know that there is something to do on an other task, so we just wait for that event to come in
                     # NOTE We now know that there is something to do on an other task, so we just wait for that event to come in
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
                     self.state.operations.insert(0, None)
-                    self.state.operations.insert(0, None)
+                elif prev_output == "Success":
+                    print("Remaining operations: " + str(self.state.operations))
+                    self.state.operations.pop(0)
+                    self.state.blocked = False
                 else:
                 else:
                     print("UNKNOWN: " + str(prev_output))
                     print("UNKNOWN: " + str(prev_output))
 
 
@@ -526,7 +528,7 @@ class Network(AtomicDEVS):
     def intTransition(self):
     def intTransition(self):
         self.state.processing.pop(0)
         self.state.processing.pop(0)
         if self.state.processing:
         if self.state.processing:
-            self.state.timer = (len(self.state.processing[0]) * 8 / float(self.bandwidth) + self.latency)
+            self.state.timer = (len(json.dumps(self.state.processing[0])) * 8 / float(self.bandwidth) + self.latency)
         else:
         else:
             self.state.timer = float("inf")
             self.state.timer = float("inf")
         return self.state
         return self.state
@@ -536,14 +538,14 @@ class Network(AtomicDEVS):
         if self.state.timer == float("inf"):
         if self.state.timer == float("inf"):
             self.state.timer = 0
             self.state.timer = 0
         for v in inputs[self.input_port]:
         for v in inputs[self.input_port]:
-            self.state.processing.append(json.dumps(v))
+            self.state.processing.append(v)
             # NOTE data is in bytes, while bandwidth is in bits, so multiply by 8
             # NOTE data is in bytes, while bandwidth is in bits, so multiply by 8
         if len(self.state.processing) > 0:
         if len(self.state.processing) > 0:
-            self.state.timer = (len(self.state.processing[0]) * 8 / float(self.bandwidth) + self.latency)
+            self.state.timer = (len(json.dumps(self.state.processing[0])) * 8 / float(self.bandwidth) + self.latency)
         return self.state
         return self.state
 
 
     def outputFnc(self):
     def outputFnc(self):
-        return {self.output_port: [json.loads(self.state.processing[0])]}
+        return {self.output_port: [self.state.processing[0]]}
 
 
     def timeAdvance(self):
     def timeAdvance(self):
         #print("Timer: " + str(self.state.timer))
         #print("Timer: " + str(self.state.timer))

File diff ditekan karena terlalu besar
+ 1 - 1
model/operations