/*======================================================================== Copyright (C) 2006 by Geir-Tore Lindsve, Torbjørn Meistad and Yngve Raudberget, hereby refered to as "the authors". Based on the CLab source code developed by Rune Møller Jensen. All rights reserved Permission is hereby granted, without written agreement and without license or royalty fees, to use, reproduce, prepare derivative works, distribute, and display this software and its documentation for NONCOMMERCIAL RESEARCH AND EDUCATIONAL PURPOSES, provided that (1) the above copyright notice and the following two paragraphs appear in all copies of the source code and (2) redistributions, including without limitation binaries, reproduce these notices in the supporting documentation. IN NO EVENT SHALL THE AUTHORS, OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ========================================================================*/ using System; using System.Collections; using System.Collections.Generic; using System.Text; using CLab.Data; namespace CLab.BDD { /// /// Abstract class representing variable types. /// Used by . /// public abstract class BDDType : CLab.Data.Type { private int bddVarNum = 0; private int domainSize = 0; /// /// Initializes a new instance of the class. /// /// Name of the layout type. /// The number of BDD variables. /// Size of the domain. public BDDType(String layoutTypeName, int bddVarNum, int domainSize) : base(layoutTypeName) { this.bddVarNum = bddVarNum; this.domainSize = domainSize; } /// /// Gets or sets the size of the domain. /// /// The size of the domain. public int DomainSize { get { return domainSize; } set { domainSize = value; } } /// /// Gets or sets the BDD variable number. /// /// The BDD variable number. public int BDDvarNum { get { return bddVarNum; } set { bddVarNum = value; } } /// /// Calculates the number of BDD variables needed, using the domain size. /// /// Size of the domain. /// The number of BDD variables needed. public static int BooleanVarNumber(int domainSize) { return (int)Math.Ceiling(Math.Log((double)domainSize) / Math.Log(2.0)); } /// /// Returns a constant from the enumeration, /// representing the current type. /// /// A constant from the enumeration. public abstract CPTypes TypeFormat(); /// /// Method that gets the Domain value at "index". /// Index can be "0" to "domain size - 1". /// /// The index of the domain value. /// The string representation of the domain value. public abstract String GetDomainValue(int index); /// /// Returns a that represents the current . /// /// /// A that represents the current . /// public override string ToString() { return string.Format("Layout type name: {0}, domain size: {1}, Number of BDD variables needed: {2}", base.TypeName, this.DomainSize, this.BDDvarNum); } } }