Пример #1
0
 /// <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");
 }
Пример #2
0
 /// <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);
     }
 }
Пример #3
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);
        }
Пример #4
0
        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);
        }
Пример #5
0
 /// <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));
 }
Пример #6
0
 /// <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)));
 }
Пример #7
0
 /// <summary>
 /// Return max of ADD
 /// [ REFS: 'none', DEREFS: 'none' ]
 /// </summary>
 public static double FindMax(CUDDNode dd)
 {
     return(PlatformInvoke.DD_FindMax(manager, dd.Ptr));
 }
Пример #8
0
 /// <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));
 }
Пример #9
0
 /// <summary>
 /// Allocate an array of n DdNodes and return the pointer
 /// </summary>
 public static IntPtr AllocateNodes(int n)
 {
     return(PlatformInvoke.DDV_AllocateNodes(n));
 }
Пример #10
0
 /// <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));
 }
Пример #11
0
 /// <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)));
 }
Пример #12
0
 /// <summary>
 /// Return the reference count
 /// </summary>
 public static int GetReference(CUDDNode dd)
 {
     return(PlatformInvoke.DDN_GetReference(dd.Ptr));
 }
Пример #13
0
 /// <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);
 }
Пример #14
0
 /// <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);
 }
Пример #15
0
 /// <summary>
 /// Sets the epsilon parameter of the manager
 /// [ REFS: 'none', DEREFS: 'none' ]
 /// </summary>
 public static void SetCUDDEpsilon(double epsilon)
 {
     PlatformInvoke.DD_SetCUDDEpsilon(manager, epsilon);
 }
Пример #16
0
 /// <summary>
 /// Return the value of the given constant node
 /// </summary>
 public static double GetValue(CUDDNode dd)
 {
     return(PlatformInvoke.DDN_GetValue(dd.Ptr));
 }
Пример #17
0
 /// <summary>
 /// Free the array of DdNodes
 /// </summary>
 public static void FreeArray(IntPtr array)
 {
     PlatformInvoke.DDV_FreeArray(array);
 }
Пример #18
0
 /// <summary>
 /// Assign the ith DdNode of array
 /// </summary>
 public static void SetElement(IntPtr vars, IntPtr var, int i)
 {
     PlatformInvoke.DDV_SetElement(vars, var, i);
 }
Пример #19
0
 /// <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())));
 }
Пример #20
0
 /// <summary>
 /// Decreases the reference count of node
 /// [ REFS: 'none', DEREFS: dd ]
 /// </summary>
 public static void Deref(CUDDNode dd)
 {
     PlatformInvoke.Cudd_RecursiveDeref(manager, dd.Ptr);
 }
Пример #21
0
 /// <summary>
 /// Return number of terminals
 /// [ REFS: 'none', DEREFS: 'none' ]
 /// </summary>
 public static int GetNumTerminals(CUDDNode dd)
 {
     return(PlatformInvoke.DD_GetNumTerminals(manager, dd.Ptr));
 }
Пример #22
0
 /// <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));
 }
Пример #23
0
 /// <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));
 }
Пример #24
0
 /// <summary>
 /// Return the index of the given node
 /// </summary>
 public static int GetIndex(CUDDNode dd)
 {
     return(PlatformInvoke.DDN_GetIndex(dd.Ptr));
 }
Пример #25
0
 /// <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()));
 }
Пример #26
0
 /// <summary>
 /// Return the minus infinity constant
 /// [ REFS: 'result', DEREFS: 'none' ]
 /// </summary>
 /// <returns></returns>
 public static CUDDNode MinusInfinity()
 {
     return(new CUDDNode(PlatformInvoke.DD_MinusInfinity(manager)));
 }
Пример #27
0
 /// <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)));
 }
Пример #28
0
 /// <summary>
 /// Return the Else node of the given node
 /// </summary>
 public static CUDDNode GetElse(CUDDNode dd)
 {
     return(new CUDDNode(PlatformInvoke.DDN_GetElse(dd.Ptr)));
 }
Пример #29
0
 public static void ManuallyReorder(int minSize)
 {
     PlatformInvoke.Cudd_ManuallyReorder(manager, minSize);
 }
Пример #30
0
 /// <summary>
 /// Return a constant
 /// [ REFS: 'result', DEREFS: 'none' ]
 /// </summary>
 public static CUDDNode Constant(double value)
 {
     return(new CUDDNode(PlatformInvoke.DD_Constant(manager, value)));
 }