Commit c66a9146 authored by Francois DELOBEL's avatar Francois DELOBEL
Browse files

Fix: simpler DiffExpr priority

parent 8153c169
......@@ -86,13 +86,6 @@ class Minizinc < Backend
"#{e.str};\n"
when Interval
"#{e.min}..#{e.max}"
# when Array2D_Value
# joined = e.arrays.map { |v| v.join(",") }.join("|")
# "[|#{joined}|]"
# when Array1D_Value
# "[#{e.array.join(",")}]"
when DiffExpr
"(#{visit(e.a)} != #{visit(e.b)})"
when Operator
e.operator.to_s
when Type
......@@ -112,10 +105,6 @@ class Minizinc < Backend
"(#{visit(e.parameter)})"
when Function
"#{visit(e.name)}(#{e.parameters.map { |p| visit(p) }.join(", ")})"
# when Indice_Table1D
# "#{visit(e.table_name)}[#{visit(e.indice)} + 1]"
# when Indice_Table2D
# "#{visit(e.table_name)}[#{visit(e.indice1)} + 1,#{visit(e.indice2)} + 1]"
when String
e
when LitteralValue
......
......@@ -130,12 +130,9 @@ class DiffOp < Operation
end
end
class DiffExpr < Operation
attr_accessor :a, :b
class DiffExpr < Priority
def initialize(a,b)
@a = a
@b = b
super(Priority.new(DiffOp.new(a,b)))
super(DiffOp.new(a,b))
end
end
......@@ -150,4 +147,4 @@ class TableSum < Operation
@table = table
@indices = indices
end
end
\ No newline at end of file
end
......@@ -17,7 +17,7 @@ def forbid_assign(vars, assign)
return res
end
## Minizinc writer. Produces a mzn file with
## Minizinc writer. Produces a mzn file with
def get_minizinc_dk_step1opt(dag, mc_improvements=true)
res = ""
res += "%%%%% AUTOMATICALLY GENERATED USING CryptoDag (https://gitlab.limos.fr/iia_lulibral/cryptodag)\n"
......@@ -106,7 +106,7 @@ def get_minizinc_dk_step1opt(dag, mc_improvements=true)
res += "constraint forall(j in 0..3) (\n";
res += "\tsum(i in 0..3)(#{a}[i,j]+#{b}[i,j]) in {0,4,5,6,7,8}\n"
res += ");\n"
vars = ["#{a}[0,j]","#{a}[1,j]","#{a}[2,j]","#{a}[3,j]","#{b}[0,j]","#{b}[1,j]","#{b}[2,j]","#{b}[3,j]"]
# # sum != 1
# 8.times do |i|
......@@ -171,4 +171,4 @@ def get_minizinc_dk_step1opt(dag, mc_improvements=true)
end
res += "constraint objective=sum(i in 0..3, j in 0..3)(#{sboxes.map{|i| "#{i.name}[i,j]"}.join(" + ")});\n"
res += "solve minimize objective;\n"
end
\ No newline at end of file
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment