/// <summary> /// Create CUDD with maxMemory in MB /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static void InitialiseCUDD(int maxMemory, int uniqueSlots, int cacheSlots, double epsilon) { manager = PlatformInvoke.DD_InitialiseCUDD(maxMemory, uniqueSlots, cacheSlots, epsilon); ZERO = Constant(0); ONE = Constant(1); PLUS_INFINITY = PlusInfinity(); MINUS_INFINITY = MinusInfinity(); //PlatformInvoke.Cudd_SetStdoutToFile(manager, Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\out.txt"); }
/// <summary> /// [Compares two ADDs for equality within tolerance.] /// Description [Compares two ADDs for equality within tolerance. Two /// ADDs are reported to be equal if the maximum difference between them /// (the sup norm of their difference) is less than or equal to the /// tolerance parameter. /// </summary> /// <param name="add1"></param> /// <param name="add2"></param> /// <returns></returns> public static bool IsEqual(CUDDNode add1, CUDDNode add2) { if (CUDD.TERMINATION_CRITERIA > 0) { return(PlatformInvoke.Cudd_EqualSupNormRel(manager, add1.Ptr, add2.Ptr, TERMINATION_EPSILON, 0) > 0); } else { return(PlatformInvoke.Cudd_EqualSupNorm(manager, add1.Ptr, add2.Ptr, TERMINATION_EPSILON, 0) > 0); } }
/// <summary> /// Close down the CUDD package /// Deletes resources associated with a DD manager /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static void CloseDownCUDD() { //Deref(ZERO, ONE, PLUS_INFINITY, MINUS_INFINITY); //Use in debug mode, to check whether any wrong in calculating reference number //CUDD.Debug.Debugs(); //Use this to print the summary information //CUDD.Print.PrintInfo(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\info.txt"); PlatformInvoke.Cudd_Quit(manager); }
public static int ShuffleHeap(List <int> newPermutation) { IntPtr newPermutationPtr = PlatformInvoke.DDV_AllocateIntArray(newPermutation.Count); for (int i = 0; i < newPermutation.Count; i++) { PlatformInvoke.DDV_SetElementIntArray(newPermutationPtr, i, newPermutation[i]); } int result = PlatformInvoke.Cudd_ShuffleHeap(manager, newPermutationPtr); PlatformInvoke.DDV_FreeIntArray(newPermutationPtr); return(result); }
/// <summary> /// Return max of ADD but must not be greater than a threshold /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static double FindMaxThreshold(CUDDNode dd, int threshold) { return(PlatformInvoke.DD_FindMaxThreshold(manager, dd.Ptr, threshold)); }
/// <summary> /// Get the ith variable, if not exist then create it /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> public static CUDDNode Var(int i) { return(new CUDDNode(PlatformInvoke.DD_Var(manager, i))); }
/// <summary> /// Return max of ADD /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static double FindMax(CUDDNode dd) { return(PlatformInvoke.DD_FindMax(manager, dd.Ptr)); }
/// <summary> /// Returns the memory in use by the manager measured in bytes. /// </summary> /// <returns></returns> public static int ReadMemoryInUse() { return((int)PlatformInvoke.Cudd_ReadMemoryInUse(manager)); }
/// <summary> /// Allocate an array of n DdNodes and return the pointer /// </summary> public static IntPtr AllocateNodes(int n) { return(PlatformInvoke.DDV_AllocateNodes(n)); }
/// <summary> /// Return number of minterm which made the ADD != 0 /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static double GetNumMinterms(CUDDNode dd, int numVars) { return(PlatformInvoke.DD_GetNumMinterms(manager, dd.Ptr, numVars)); }
/// <summary> /// Finds the variables on which a DD depends. /// Returns a ADD consisting of the product of the variables. /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> public static CUDDNode GetSupport(CUDDNode dd) { return(new CUDDNode(PlatformInvoke.DD_GetSupport(manager, dd.Ptr))); }
/// <summary> /// Return the reference count /// </summary> public static int GetReference(CUDDNode dd) { return(PlatformInvoke.DDN_GetReference(dd.Ptr)); }
/// <summary> /// Increases the reference count of a node, if it is not saturated /// [ REFS: dd, DEREFS: 'none' ] /// </summary> public static void Ref(CUDDNode dd) { PlatformInvoke.Cudd_Ref(dd.Ptr); }
/// <summary> /// Set the maximum memory of CUDD in MB /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> /// <param name="maxMemory"></param> public static void SetCUDDMaxMem(int maxMemory) { PlatformInvoke.DD_SetCUDDMaxMem(manager, maxMemory); }
/// <summary> /// Sets the epsilon parameter of the manager /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static void SetCUDDEpsilon(double epsilon) { PlatformInvoke.DD_SetCUDDEpsilon(manager, epsilon); }
/// <summary> /// Return the value of the given constant node /// </summary> public static double GetValue(CUDDNode dd) { return(PlatformInvoke.DDN_GetValue(dd.Ptr)); }
/// <summary> /// Free the array of DdNodes /// </summary> public static void FreeArray(IntPtr array) { PlatformInvoke.DDV_FreeArray(array); }
/// <summary> /// Assign the ith DdNode of array /// </summary> public static void SetElement(IntPtr vars, IntPtr var, int i) { PlatformInvoke.DDV_SetElement(vars, var, i); }
/// <summary> /// Return the first cube making the ADD not 0 /// [ REFS: 'result', DEREFS: 'dd' ] /// </summary> public static CUDDNode RestrictToFirst(CUDDNode dd, CUDDVars vars) { return(new CUDDNode(PlatformInvoke.DD_RestrictToFirst(manager, dd.Ptr, vars.GetArrayPointer(), vars.GetNumVars()))); }
/// <summary> /// Decreases the reference count of node /// [ REFS: 'none', DEREFS: dd ] /// </summary> public static void Deref(CUDDNode dd) { PlatformInvoke.Cudd_RecursiveDeref(manager, dd.Ptr); }
/// <summary> /// Return number of terminals /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static int GetNumTerminals(CUDDNode dd) { return(PlatformInvoke.DD_GetNumTerminals(manager, dd.Ptr)); }
/// <summary> /// return the variable index of the variable currently at position pos /// </summary> /// <param name="i">The position of the varaible index to get</param> /// <returns></returns> public static int ReadInvPerm(int i) { return(PlatformInvoke.Cudd_ReadPerm(manager, i)); }
/// <summary> /// returns number of paths in dd /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static double GetNumPaths(CUDDNode dd) { return(PlatformInvoke.DD_GetNumPaths(manager, dd.Ptr)); }
/// <summary> /// Return the index of the given node /// </summary> public static int GetIndex(CUDDNode dd) { return(PlatformInvoke.DDN_GetIndex(dd.Ptr)); }
/// <summary> /// Return the int value corresponding the binary representation of the current minterm /// [ REFS: 'none', DEREFS: 'none' ] /// </summary> public static int MinTermToInt(CUDDNode dd, CUDDVars vars) { return(PlatformInvoke.Cudd_MinTermToInt(manager, dd.Ptr, vars.GetArrayPointer(), vars.GetNumVars())); }
/// <summary> /// Return the minus infinity constant /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> /// <returns></returns> public static CUDDNode MinusInfinity() { return(new CUDDNode(PlatformInvoke.DD_MinusInfinity(manager))); }
/// <summary> /// Create a new dd, initial value is Zero /// Careful to use with the default value 0 /// Working with vector, should not use, should set vector default value is -infinity /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> /// <returns></returns> public static CUDDNode Create() { return(new CUDDNode(PlatformInvoke.DD_Create(manager))); }
/// <summary> /// Return the Else node of the given node /// </summary> public static CUDDNode GetElse(CUDDNode dd) { return(new CUDDNode(PlatformInvoke.DDN_GetElse(dd.Ptr))); }
public static void ManuallyReorder(int minSize) { PlatformInvoke.Cudd_ManuallyReorder(manager, minSize); }
/// <summary> /// Return a constant /// [ REFS: 'result', DEREFS: 'none' ] /// </summary> public static CUDDNode Constant(double value) { return(new CUDDNode(PlatformInvoke.DD_Constant(manager, value))); }