|
@@ -3,9 +3,8 @@ include "modelling.alh"
|
|
|
include "object_operations.alh"
|
|
|
|
|
|
Composite schedule {
|
|
|
- {Contains} Failure failure {}
|
|
|
{Contains} Success success {}
|
|
|
- {Contains} ForAll expand {
|
|
|
+ {Contains} Atomic expand {
|
|
|
LHS {
|
|
|
Pre_Design/Block expand_lhs_0 {
|
|
|
label = "0"
|
|
@@ -42,10 +41,16 @@ Composite schedule {
|
|
|
Post_Design/Block expand_rhs_3 {
|
|
|
label = "3"
|
|
|
}
|
|
|
+ Post_Design/InitialCondition (expand_rhs_3, expand_rhs_1) {
|
|
|
+ label = "4"
|
|
|
+ }
|
|
|
+ Post_Design/Link (expand_rhs_0, expand_rhs_1) {
|
|
|
+ label = "5"
|
|
|
+ }
|
|
|
Post_Design/ConstantBlock expand_rhs_7 {
|
|
|
label = "7"
|
|
|
- value = $
|
|
|
- Integer function value(model : Element, name : String, mapping : Element):
|
|
|
+ value_value = $
|
|
|
+ Float function value(model : Element, name : String, mapping : Element):
|
|
|
return 0.01!
|
|
|
$
|
|
|
}
|
|
@@ -63,8 +68,8 @@ Composite schedule {
|
|
|
}
|
|
|
Post_Design/ConstantBlock expand_rhs_12 {
|
|
|
label = "12"
|
|
|
- value = $
|
|
|
- Integer function value(model : Element, name : String, mapping : Element):
|
|
|
+ value_value = $
|
|
|
+ Float function value(model : Element, name : String, mapping : Element):
|
|
|
return 0!
|
|
|
$
|
|
|
}
|
|
@@ -109,10 +114,10 @@ Composite schedule {
|
|
|
Pre_Design/Block opt_inv_lhs_2 {
|
|
|
label = "2"
|
|
|
}
|
|
|
- Pre_Design/Link opt_inv_lhs_3 {
|
|
|
+ Pre_Design/Link (opt_inv_lhs_0, opt_inv_lhs_1) {
|
|
|
label = "3"
|
|
|
}
|
|
|
- Pre_Design/Link opt_inv_lhs_4 {
|
|
|
+ Pre_Design/Link (opt_inv_lhs_1, opt_inv_lhs_2) {
|
|
|
label = "4"
|
|
|
}
|
|
|
}
|
|
@@ -131,7 +136,7 @@ Composite schedule {
|
|
|
}
|
|
|
Post_Design/ConstantBlock opt_inv_rhs_5 {
|
|
|
label = "5"
|
|
|
- value = $
|
|
|
+ value_value = $
|
|
|
Float function value(model : Element, name : String, mapping : Element):
|
|
|
return float_division(1, read_attribute(model, mapping["0"], "value"))!
|
|
|
$
|
|
@@ -153,10 +158,10 @@ Composite schedule {
|
|
|
Pre_Design/Block opt_neg_lhs_2 {
|
|
|
label = "2"
|
|
|
}
|
|
|
- Pre_Design/Link opt_neg_lhs_3 {
|
|
|
+ Pre_Design/Link (opt_neg_lhs_0, opt_neg_lhs_1) {
|
|
|
label = "3"
|
|
|
}
|
|
|
- Pre_Design/Link opt_neg_lhs_4 {
|
|
|
+ Pre_Design/Link (opt_neg_lhs_1, opt_neg_lhs_2) {
|
|
|
label = "4"
|
|
|
}
|
|
|
}
|
|
@@ -175,7 +180,7 @@ Composite schedule {
|
|
|
}
|
|
|
Post_Design/ConstantBlock opt_neg_rhs_5 {
|
|
|
label = "5"
|
|
|
- value = $
|
|
|
+ value_value = $
|
|
|
Float function value(model : Element, name : String, mapping : Element):
|
|
|
return float_subtraction(0, read_attribute(model, mapping["0"], "value"))!
|
|
|
$
|
|
@@ -187,20 +192,18 @@ Composite schedule {
|
|
|
}
|
|
|
|
|
|
{Contains} ForAll remove_blocks {
|
|
|
- NAC {
|
|
|
- Pre_Design/Block rem_nac_0 {
|
|
|
- label = "0"
|
|
|
- }
|
|
|
- Pre_Design/Block rem_nac_1 {
|
|
|
- label = "1"
|
|
|
- }
|
|
|
- Pre_Design/Link rem_nac_2 {
|
|
|
- label = "2"
|
|
|
- }
|
|
|
- }
|
|
|
LHS {
|
|
|
Pre_Design/Block rem_lhs_0 {
|
|
|
label = "0"
|
|
|
+ constraint = $
|
|
|
+ Boolean function constraint(model : Element, name : String):
|
|
|
+ if (set_len(allOutgoingAssociationInstances(model, name, "Design/Link")) > 0):
|
|
|
+ return False!
|
|
|
+ elif (set_len(allOutgoingAssociationInstances(model, name, "Design/InitialCondition")) > 0):
|
|
|
+ return False!
|
|
|
+ else:
|
|
|
+ return read_type(model, name) != "Design/ProbeBlock"!
|
|
|
+ $
|
|
|
}
|
|
|
}
|
|
|
RHS {}
|
|
@@ -251,7 +254,7 @@ Composite schedule {
|
|
|
}
|
|
|
Post_Design/ConstantBlock opt_add_rhs_7 {
|
|
|
label = "7"
|
|
|
- value = $
|
|
|
+ value_value = $
|
|
|
Float function value(model : Element, name : String, mapping : Element):
|
|
|
return float_addition(read_attribute(model, mapping["0"], "value"), read_attribute(model, mapping["1"], "value"))!
|
|
|
$
|
|
@@ -307,7 +310,7 @@ Composite schedule {
|
|
|
}
|
|
|
Post_Design/ConstantBlock opt_mult_rhs_7 {
|
|
|
label = "7"
|
|
|
- value = $
|
|
|
+ value_value = $
|
|
|
Float function value(model : Element, name : String, mapping : Element):
|
|
|
return float_multiplication(read_attribute(model, mapping["0"], "value"), read_attribute(model, mapping["1"], "value"))!
|
|
|
$
|
|
@@ -378,23 +381,28 @@ Composite schedule {
|
|
|
Element all_links
|
|
|
|
|
|
all_blocks = allInstances(model, "Design/Block")
|
|
|
+ log("Translating models: " + cast_value(set_len(all_blocks)))
|
|
|
while (set_len(all_blocks) > 0):
|
|
|
element_name = set_pop(all_blocks)
|
|
|
+ log("Check " + element_name)
|
|
|
mm_type_name = "PartialRuntime/" + cast_string(list_read(string_split(read_type(model, element_name), "/"), 1))
|
|
|
|
|
|
if (set_len(allOutgoingAssociationInstances(model, element_name, "D2P_block")) == 0):
|
|
|
// New design element, so create in partial runtime model as well
|
|
|
new_element_name = instantiate_node(model, mm_type_name, "")
|
|
|
instantiate_link(model, "D2P_block", "", element_name, new_element_name)
|
|
|
+ log("New element: " + mm_type_name)
|
|
|
|
|
|
// Always update the value of attributes of PartialRuntime
|
|
|
new_element_name = map_D2P(model, element_name)
|
|
|
if (mm_type_name == "PartialRuntime/ConstantBlock"):
|
|
|
instantiate_attribute(model, new_element_name, "value", read_attribute(model, element_name, "value"))
|
|
|
+ log("Copied value: " + cast_value(read_attribute(model, element_name, "value")))
|
|
|
elif (mm_type_name == "PartialRuntime/ProbeBlock"):
|
|
|
instantiate_attribute(model, new_element_name, "name", read_attribute(model, element_name, "name"))
|
|
|
|
|
|
all_blocks = allInstances(model, "PartialRuntime/Block")
|
|
|
+ log("All created blocks: " + cast_value(set_len(all_blocks)))
|
|
|
while (set_len(all_blocks) > 0):
|
|
|
element_name = set_pop(all_blocks)
|
|
|
if (set_len(allIncomingAssociationInstances(model, element_name, "D2P_block")) == 0):
|
|
@@ -414,13 +422,18 @@ Composite schedule {
|
|
|
all_links = allInstances(model, "Design/Link")
|
|
|
while (set_len(all_links) > 0):
|
|
|
element_name = set_pop(all_links)
|
|
|
+ log("Recreate link " + element_name)
|
|
|
+ log("Source type: " + read_type(model, readAssociationSource(model, element_name)))
|
|
|
instantiate_link(model, "PartialRuntime/Link", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
|
|
|
|
|
|
all_links = allInstances(model, "Design/InitialCondition")
|
|
|
while (set_len(all_links) > 0):
|
|
|
element_name = set_pop(all_links)
|
|
|
+ log("Recreate initial condition " + element_name)
|
|
|
instantiate_link(model, "PartialRuntime/InitialCondition", "", map_D2P(model, readAssociationSource(model, element_name)), map_D2P(model, readAssociationDestination(model, element_name)))
|
|
|
|
|
|
+ log("Finished translation")
|
|
|
+
|
|
|
return!
|
|
|
|
|
|
String function map_D2P(model : Element, name : String):
|
|
@@ -441,19 +454,7 @@ Composite schedule {
|
|
|
|
|
|
Initial (schedule, expand) {}
|
|
|
|
|
|
-OnSuccess (expand, optimize_inverse) {}
|
|
|
-OnSuccess (optimize_inverse, optimize_inverse) {}
|
|
|
-OnSuccess (optimize_negator, optimize_inverse) {}
|
|
|
-OnSuccess (optimize_adder, optimize_inverse) {}
|
|
|
-OnSuccess (optimize_multiplier, optimize_inverse) {}
|
|
|
-OnSuccess (optimize_constant, optimize_inverse) {}
|
|
|
-
|
|
|
-OnFailure (expand, optimize_inverse) {}
|
|
|
-OnFailure (optimize_inverse, optimize_negator) {}
|
|
|
-OnFailure (optimize_negator, optimize_adder) {}
|
|
|
-OnFailure (optimize_adder, optimize_multiplier) {}
|
|
|
-OnFailure (optimize_multiplier, optimize_constant) {}
|
|
|
-OnFailure (optimize_constant, remove_blocks) {}
|
|
|
-
|
|
|
-OnSuccess (remove_blocks, success) {}
|
|
|
-OnFailure (remove_blocks, success) {}
|
|
|
+OnSuccess (expand, expand) {}
|
|
|
+OnFailure (expand, remove_blocks) {}
|
|
|
+OnSuccess (remove_blocks, map_to_partial) {}
|
|
|
+OnSuccess (map_to_partial, success) {}
|