public Zen <bool> Build_Network(Zen <IList <int> > costs) { Zen <bool> network_expr = True(); foreach (KeyValuePair <int, HashSet <int> > kvp in node2neighbors) { // costs.At(1).Value() == Min(costs.At(0).Value() + 1, costs.At(2).Value() + 1), Zen <ushort> i = (Zen <ushort>)kvp.Key; // this is just i, but it doesn't allow me to cast -_- if (kvp.Key == dst_node) { continue; } Console.Write(kvp.Key + ": ["); Zen <bool> lower_limit_expr = True(); foreach (Zen <ushort> j in kvp.Value) { Console.Write(j + ", "); lower_limit_expr = And(lower_limit_expr, costs.At(i).Value() <= costs.At(j).Value() + 1); } Zen <bool> upper_limit_expr = False(); foreach (Zen <ushort> j in kvp.Value) { upper_limit_expr = Or(upper_limit_expr, costs.At(i).Value() >= costs.At(j).Value() + 1); } Console.WriteLine("]"); network_expr = And(network_expr, And(lower_limit_expr, upper_limit_expr)); } Console.WriteLine("physical edges" + physicalEdges.Count); Console.WriteLine("Network Expression " + network_expr); return(network_expr); }
/// <summary> /// Or operation of two Zen List of bool. /// </summary> /// <param name="ma">list a.</param> /// <param name="mb">list b.</param> /// <returns>list of a or b.</returns> public static Zen <IList <bool> > Or(this Zen <IList <bool> > ma, Zen <IList <bool> > mb) { var index = mb.Length(); var ret = ma.Select(_ => Language.Or(ma.At(index -= 1).Value(), mb.At(index).Value())); return(ret); }
public void NSLabelTest() { Zen <IDictionary <string, string> > l1 = EmptyDict <string, string>().Add("k1", "v1"); Zen <IDictionary <string, string> > l2 = EmptyDict <string, string>().Add("k2", "v1"); Zen <IDictionary <string, string> > l3 = EmptyDict <string, string>().Add("k3", "v1"); Zen <IList <string> > k1 = EmptyList <string>().AddBack("k1"); Zen <IList <string> > k2 = EmptyList <string>().AddBack("k2"); Zen <IList <string> > k3 = EmptyList <string>().AddBack("k3"); var ns1 = Namespace.Create("defaul", l1, k1); var ns2 = Namespace.Create("defaul", l2, k2); var ns3 = Namespace.Create("defaul", l3, k3); Zen <Namespace>[] namespaces = new Zen <Namespace>[] { ns1, ns2, ns3 }; var output = Algorithms.CreateNSLabelMatrix(namespaces); var r1 = EmptyList <bool>().AddBack(true).AddBack(false).AddBack(false); var r2 = EmptyList <bool>().AddBack(false).AddBack(true).AddBack(false); var r3 = EmptyList <bool>().AddBack(false).AddBack(false).AddBack(true); Assert.IsTrue(output.Get(k1.At(0).Value().GetHashCode()).Value().ToString().Equals(r1.ToString())); Assert.IsTrue(output.Get(k2.At(0).Value().GetHashCode()).Value().ToString().Equals(r2.ToString())); Assert.IsTrue(output.Get(k3.At(0).Value().GetHashCode()).Value().ToString().Equals(r3.ToString())); }
// 0 - 1 - 2 (0 - 2) // The function encodes the property we want to verify public Zen <bool> Simple_CPV(Zen <IList <int> > costs, int src_node) { return(And(And(costs.At((Zen <ushort>) this.dst_node).Value() == 0, costs.At((Zen <ushort>)src_node).Value() <= GlobalVar.MAX_HOPS), costs.Length() == 7)); }