Home

CLab# and CaSPer: User Manual

image

Contents

1. Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public ClabSymbolException Initializes a new instance of the ClabSymbolException class Parameters message The exception message which describes the reason for the exception METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters 160 CHAPTER 6 CLAB 1 0 API REFERENCE obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters info con
2. Parameters newVariable The variable object to add Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 6 4 NAMESPACE CLAB DATA 117 e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 118 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS Expression Abstract class for the different types of Expressions DECLARATION public class Expression Object PROPERTIES e Type public CLab Common ExprType Type get Returns the type of this expression CONSTRUCTORS e Constructor public Expression Constructor Parameters type The type of the expression This can be either an operator working on a left and right side or an id or integer expression METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 6 4 NAMESPACE CLAB DATA 119 e Finalize protected void Finalize Allows an
3. x 1 Add the constraint graph to th casper CGraph 1 2 static default casper SetVariableOrdering Casper CspVariableOrdering vo_minwidth casper object constraintGraph Set the variable ordering or minimum width Mak that also include the set of variables that are found in the rule an expression wrapper casper Expressions AddWrappedExpr new CSPExprWrapper expr1 variablesInRulel variablesInRule2 casper Expressions AddWrappedExpr new CSPExprWrapper expr2 Calculate the valid domains of the problem This runs the CSP search algorithm under the hood List lt CasperVarDom gt validDoms casper ValidDomains j Print out of valid domain values int i 0 i lt validDoms Count itt Console Write VarID validDoms i VarID for int j 0 j lt validDoms i DomainValues Count Writ Console WriteLine for j validDoms i DomainValues j Consol Chapter 4 CLab Configurator This section presents an overall look at the functionality of the graphical user interface we have provided and the use of threads in the application 4 1 Overview The graphical user interface provided CLab Configurator have been developed to be an example implementation of a client application for the CLab library The application is developed with standard Windows Forms to look familiar to most Windows users The application pro
4. Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprValueConst 238 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprValuelnt Implementation class for the integer type of value expressions Implements the abstract CSP ExprValue class DECLARATION public class CSPExprValuelnt CSPExprValue PROPERTIES e Value public int Value get set Gets or sets the value CONSTRUCTORS e Constructor public CSPExprValuelnt Initializes a new instance of the CSPExprValueInt class Parameters x value The value METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 239 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToStri
5. e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 6 2 NAMESPACE CLAB BDD 51 e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 52 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS BDDLayout Class representing and making the layout of the BDD problem The class has mapping from the CLab Data CP representation to the BDD representation and vice versa DECLARATION public class BDDLayout Object PROPERTIES e BddVarNum public int BddVarNum get Gets the number of BDD variables e LayoutTypes public System Collections Generic List CLab BDD BDDType LayoutTypes get Gets the the list of types used by layout e LayoutVariables public System Collections Generic List CLab BDD BDDVariable LayoutVari ables get Gets the variables used by layout e TypeNameTolndex public System Collections Hashtable TypeNameToIndex get Gets the hash table mapping type names to index e VariableNameTolndex public System Collections Hashtable VariableNameToIndex get 6 2 NAM
6. CLASS CSPExprVarBool Implementation class for the boolean variable type of variable expressions Implements the abstract CSPExprVar class DECLARATION public class CSPExprVarBool CSPExprVar PROPERTIES e VarID public int VarID get set Gets or sets the variable ID CONSTRUCTORS e Constructor public CSPExprVarBool Initializes a new instance of the CSPExprVarBool class Parameters x VarlID The var ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 243 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprVarBoo 244 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprVarEnum Implementation class for the enumeration variable type of variable expressions Implements the abstr
7. METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 231 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprNeg 232 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprNot DECLARATION public class CSPExprNotNeg CSPExpr PROPERTIES e Left public Casper Data CSPExpr Left get Gets the expression CONSTRUCTORS e Constructor public CSPExprNot Initializes a new instance of the CSPExprNot class Parameters left The left expression METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 233 e Finalize protected void Finalize Allows an to attempt to free resources and perform
8. public System Collections Generic List CLab CSP CSPType Types get Gets the list of CSP types e VarIDToCPVar public System Collections Generic List System String VarIDToCPVar get Gets the Casper Data CasperVarDom VarID property to the CLab Data Variable VariableName property mapping 6 3 NAMESPACE CLAB CSP 97 e VarIDToTypeName public System Collections Generic List System String VarIDToTypeName get Gets the Casper Data CasperVarDom VarID property to the CLab Data Variable TypeName property mapping CONSTRUCTORS e Constructor public CSPLayout Initializes a new instance of the CSPLayout class Parameters cp The CLab Data CP instance of the problem METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetCasperVarDomIndex public int GetCasperVarDomindex Gets the index of the Casper Data CasperVarDom object with the name cpVar Name 98 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters cpVarName Name of the Clab variable e GetCPVarFromVarID public string GetCPVarFromVarID Gets the variable name CLab Data Variable VariableName from the passed inn variable ID
9. Casper Data CasperVarDom VarID Parameters x varlID The var ID GetDomainIntFromDomainString public int GetDomainIntFromDomainString Gets the domain value s int representation Parameters cpVarName Name of the CLab variable domainString The domain string value GetDomainStringFromDomainInt public string GetDomainStringFromDomainint Gets the domain value s string representation Parameters cpVarName Name of the CLab variable x domainInt The domain int value GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 6 3 NAMESPACE CLAB CSP 99 e GetType public System Type GetType Gets the of the current instance e GetTypeFormat public CLab CPTypes GetTypeFormat Gets the type format CPTypes Parameters typeName Name of the type e GetTypeName public string GetTypeName Gets the name of the variable s type Parameters x varName The CLab variable name e GetVarIDFromCP Var public int GetVarIDFromCPVar Gets the variable ID Casper Data CasperVarDom VarID from the passed in vari able name CLab Data Variable VariableName Parameters cpVarName Name of the cp var e MakeCasperVarDoms public System Collections Generic List Casper Data CasperVarDom
10. exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public ClabException Initializes a new instance of the ClabException class Parameters message The exception message which describes the reason for the exception inner The inner exception e Constructor public ClabException Initializes a new instance of the ClabException class 148 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters message The exception message which describes the reason for the exception METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception 6 5 NAMESPACE CLAB
11. which provides the data needed for this class to work DECLARATION public class ClabBDD Object PROPERTIES e Layout public CLab BDD BDDLayout Layout get Gets the BDDLayout of the problem e Space public CLab BDD BDDSpace Space get Gets the BDDSpace of the problem e UnsatisfiableRule public string UnsatisfiableRule get Gets the unsatisfiable rule if one exist CONSTRUCTORS e Constructor public CIabBDD Initializes a new instance of the ClabBDD class Parameters Clab The current Clab instance cp The cp object of the problem 6 2 NAMESPACE CLAB BDD 79 symbols The symbols object of the problem initdbcache The initial db cache initbddnodes The initial number of bdd nodes maxincrease The maximum increase number x XA METHODS e CompileAllExpressions public buddy_sharp Bdd CompileAllExpressions Compiles all expressions Parameters compileMethod The compile method e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a
12. x domaintInt An integer representing a domain value 106 CHAPTER 6 CLAB 1 0 API REFERENCE GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Returns a System String that represents the current CLab CSP CSPTypeBool TypeFormat public CLab CPTypes TypeFormat _ Returns the CPTypes bool_type constant 6 3 NAMESPACE CLAB CSP 107 CLASS CSPTypeEnum A class for representing enumeration types in the CSP part of CLab The different possible domain values for an enumeration are encoded as a range with an end point The start point is assumed always to be 0 Implements the abstract CSPType class DECLARATION public class CSPTypeEnum CSPType PROPERTIES e End public int End get set Gets or sets the end of the range e TypeName public string TypeName get set Gets or sets the name of the type CONSTRUCTORS e Constructor public CSPTypeEnum Initializes a new instance of the CSPTypeEnumerator class Parameters typeName Name of the type METHODS 108 CHAPTER 6 CLAB 1 0 API REFERENCE e AddConstant public int AddConstant Adds a new enumeration domain value constant This method makes a mapping from string representation to int representation and vice versa Pa
13. The compiled grammar is located in the Auxiliary folder and is integrated in the compiled binaries 6 7 NAMESPACE COM CALITHA GOLDPARSER 175 6 7 1 Classes CLASS RuleException Internal exception class used by the parser engine DECLARATION public class RuleException Exception PROPERTIES e Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception e HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception e HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion e InnerException public System Exception InnerException get Gets the instance that caused the current exception e Message 176 CHAPTER 6 CLAB 1 0 API REFERENCE public string Message get Gets a message that describes the current exception e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor p
14. public class CasperException Exception PROPERTIES e Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception e HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception e HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion e InnerException public System Exception InnerException get Gets the instance that caused the current exception e Message 232 CHAPTER 7 CASPER API REFERENCE public string Message get Gets a message that describes the current exception Source public string Source get set Gets or sets the name of the application or the object that causes the error StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public CasperException Initializes a new instance of the CasperException class Parameters message The exception message which describes the reason for the exception e Constructor public CasperException Initializes a new ins
15. that everything should be done through this class DECLARATION public class Clab Object PROPERTIES e Cp public CLab Data CP Cp get Gets the CLab Data CP problem instance e Initbddnodes public int Initbddnodes get set Gets or sets the initial number of bdd nodes e Initdbcache public int Initdbcache get set Gets or sets the initial size of db cache e Maxincrease public int Maxincrease get set Gets or sets the BDD max increase number CONSTRUCTORS 6 1 NAMESPACE CLAB 37 e Constructor public Clab Initializes a new instance of the Clab class Parameters x fileName Name of the csp problem file e Constructor public Clab Initializes a new instance of the Clab class Parameters x xmlStream The cp file stream METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 38 CHAPTER 6 CLAB 1 0 API REFERENCE GetType public System Type GetType Gets the of the current instance GetUnsatisfiableRule pu
16. x y The right 2 complementary BDD representation e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e MkSameSize public void MkSameSize 29 98 99 299 Extends the smallest of the specified x or y so the lists gets equal length Modi fies one of them if they have unequal lenght Parameters x 2 complementary representation y 2 complementary representation 60 CHAPTER 6 CLAB 1 0 API REFERENCE e MkVal public System Collections Generic List buddy_sharp Bdd MkVal Makes a 2 complementary BDD representation of an integer value Parameters intVal The integer value MkVar public System Collections Generic List buddy_sharp Bdd MkVar Makes a 2 complementary BDD representation of the boolan vector representing the bdd variable Parameters Bddvar The boolean vector representing the bdd variable e Mod public System Collections Generic List buddy sharp Bdd Mod Calculates the result of the modulo operation between two 2 complementary BDD representations Parameters x 2 complementary BDD representation of the numerator y 2 complementary BDD representation of the denominator e Mul public System Collections Generic List buddy sharp Bdd Mul Calculates the result of the multiplication operation between two 2 complementary BDD representations Parameters x A 2 complementar
17. 1 0 API REFERENCE e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public SymbolException Initializes a new instance of the SymbolException class Parameters message The exception message which describes the reason for the exception e Constructor public SymbolException Initializes a new instance of the SymbolException class Parameters message The exception message which describes the reason for the exception inner The inner exception 6 7 NAMESPACE COM CALITHA GOLDPARSER 181 e Constructor protected SymbolException Initializes a new instance of the SymbolException class Parameters x info The System Runtime Serialization SerializationInfo that holds the serialized object data about the exception being thrown x context The System Runtime Serialization StreamingContext that con tains contextual information about the source or destination METHODS e Equals public bool Equals Determines whether the specified is equal to the current
18. BDD get Gets the BDD e Size public int Size get Gets the size CONSTRUCTORS e Constructor public PQbdd Initializes a new instance of the PQbdd class Parameters bc The BDD METHODS e CompareTo public int CompareTo IComparable implementation Compares PQbdds based on their size 6 2 NAMESPACE CLAB BDD 83 Parameters obj PQbdd object e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 84 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ValidAssignmentData Class which is used to get valid assignment data from the result BDD of the CP problem Con tains data structures which is filled with result data by Buddy_sharp and Buddy DECLARATION public class ValidAssignmentData Object PROPERTIES e BddVarTocpVar public System Int32 BddVarTocpVar get Gets the Bdd variabl
19. CLASS Program This class is working between CLab and the GUI class MainGui The searching part is run in its own thread so the application won t hang during a heavy search DECLARATION public class Program Object PROPERTIES e Modus public CLab CLabModus Modus get set Gets or sets the modus to use BDD if modus 0 or CSP if modus 1 e ProblemFilename public string ProblemFilename get set Gets or sets the problem filename CONSTRUCTORS e Constructor public Program Initializes a new instance of the Program class e Constructor public Program Initializes a new instance of the Program class Parameters x fileName Name of the file to be opened 8 1 NAMESPACE CLABGUI 259 METHODS e AddDataToGui public void AddDataToGui Adds the variable and domaine values data to GUI Parameters x vd The vd e ClabThreadIsAlive public bool ClabThreadIsAlive Method for checking 1f CLab is running a search e OpenFile public string OpenFile Returns the content of a text file Parameters fileName The file to get content from e PauseClabThreadIfRunning public bool PauseClabThreadIfRunning Pauses the CLab thread if running and resumes if paused e ReadTextFromFile public string ReadTextFromFile Reads the text from a file Parameters x fileName Name of the file 260 CHAPTER 8
20. Compile public buddy sharp Bdd Compile Compiles the specified expression Parameters x expression The expression 6 2 NAMESPACE CLAB BDD 57 e CompileRules public buddy sharp Bdd CompileRules Tries to compile all rules defined in the problem file Each expression is compiled to a BDD Afterwards the BDDs are and ed together depending on which ordering is chosen The order of the compilation can be set three different ways Static In the same order the expressions are written in the problem Ascending The order depends on the node count of each expression Smallest node count is and ed with the result BDD first Dynamic The two smallest BDDs are and ed and the result is placed back in the queue This is continued until we have only one element left in the queue which is the final result BDD Parameters x method The CLab Auxiliary Common CompileMethod representing which ordering to use e Div public System Collections Generic List buddy sharp Bdd Div Calculates the result of the division operation between two 2 complementary BDD representations Parameters x 2 complementary BDD representation of the numerator y 2 complementary BDD representation of the denominator e Equal public buddy sharp Bdd Equal _ Calculates a BDD representing the equal operation on two 2 complementary BDD representations Parameters x The left 2 complementary BDD repres
21. DT y pe BOON seers ii aces ohana ade na Ba aed pe oats 65 Class representing the boolean type BDD Ty pel niin 25226 0Seh a dida 68 Class representing the enumeration type BDDTypeRa ge lt it ld es 71 Class representing the range type BOO Varios A RA RG 8 RR 74 Class representing a CLab variable Class for BDD representation of the configuration space of a CP expression CEDBDD iS a Se 78 The main class for finding valid solutions the BDD way The class is de signed to be used by CLab Clab which provides the data needed for this class to work Priority queue node with IComparable implementation 6 2 NAMESPACE CLAB BDD Valid A Ssipniiment ata 0 IAEA AAA AAA RARA Class which is used to get valid assignment data from the result BDD of the CP problem Contains data structures which is filled with result data by Buddy_sharp and Buddy 50 CHAPTER 6 CLAB 1 0 API REFERENCE 6 2 1 Classes CLASS BDDComparer An System Collections Generic Comparer implementation when sorting a list of BDDs based on their node count Used in CLab BDD Space when CLab Auxiliary Common CompileMethod is set to cm_ascending DECLARATION public class BDDComparer Object CONSTRUCTORS e Constructor public BDDComparer Initializes a new instance of the BDDComparer class METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj
22. EXCEPTIONS 149 Parameters info context e GetType public System Type GetType Gets the runtime type of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 150 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabInternalErrorException Custom exception class used for internal errors Receiver should either rethrow the exception or halt the execution of ClabSharp DECLARATION notpublic class ClabInternalErrorException Exception PROPERTIES Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion InnerException public System Exception InnerException get Gets the instance that caused the current exception Message public string Message get 6 5 NAMESPACE CLAB EXCEPTIONS 151 Gets a message that describes the current exception e Source public string Source get set Gets or sets the name of the application or the object that c
23. ExprType type A ExpressionId ExpressionInt ExpressionNotNeg Expression left ExpressionBinary Expression left Expression right Figure 2 1 The figure shows the recursive expression structure of CLab 8 CHAPTER 2 CLAB 2 1 4 Status messages CLab supports status events which for instance can be used to run a progress bar All event handler functions which have been added to the status event StatusEvent is called with an int value representing the currently run operation when an event oc curs The StatusUpdateCount method can be used to find out how many up dates can be expected for a search A delegate is used as an event handler and defines the interface for the event handler function which can be added The delegate is called StatusEventHandler When CSP algorithms are used to search for valid domains the status event is updated each time the search is started for a new variable For the BDD approach the status event is updated each time a new expression is built and for each of the conjunction operations on the resulting BDDs The status event delegate defines the event handler function interface void MethodName int FieldName To add the method the operation StatusEvent new StatusEventHandler MethodName is run is used to add and to remove 2 1 5 CLab Code Example In this section we present a small code example on how to use CLab We have not in
24. Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetNextVar public int GetNextVar Gets the next variable according to the minimum width ordering Parameters x numberInQueue The number in queue 212 CHAPTER 7 CASPER API REFERENCE e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 7 3 NAMESPACE CASPER ALGORITHM VARIABLEORDERING 213 CLASS StaticVarOrder An implementation of a static variable order that is the variable ordering equals the ordering given in the cp file DECLARATION public class Static VarOrder Object CONSTRUCTORS e Constructor public StaticVarOrder Initializes a new instance of the class METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular t
25. Gets the runtime type of the current instance MemberwiseClone protected object MemberwiseClone 6 5 NAMESPACE CLAB EXCEPTIONS 153 Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 154 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabInvalidExpressionException Custom exception class triggered by invalid parsing during the building of expressions DECLARATION notpublic class ClabInvalidExpressionException Exception PROPERTIES Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion InnerException public System Exception InnerException get Gets the instance that caused the current exception Message public string Message get Gets a message that describes the current exception 6 5 NAMESPACE CLAB EXCEPTIONS 155 e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representati
26. Implements the abstract expression class DECLARATION public class ExpressionId Expression PROPERTIES e ld public string Id get Returns the Id value e Type public CLab Common ExprType Type get Returns the type of this expression CONSTRUCTORS e Constructor public ExpressionId Initializes a new instance of the ExpressionId class Parameters id A string with the name of the variable or an enumeration constant METHODS e Equals public bool Equals Determines whether the specified is equal to the current 6 4 NAMESPACE CLAB DATA 125 Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e RunCSPBuildExpr assembly Casper Data CSPExpr RunCSPBuildExpr Abstract method which runs CSPBuildExpr in CLab CSP CSPExpressionBuilder Dou ble dispatch pattern Parameters builder The CSPExpressionBuilder e ToString public string ToString 126 CHAPTER 6 CLAB 1 0
27. Ken Friis Larsen We make extensive use of sets in our implementations and since C does not have any internal set implementation we are using a publicly available Set implementation available in the package LTesi Collections The token parser which parses plain text to XML format has been developed with the free GOLD Parsing System The parser uses a compiled grammar table which have been compiled from a modified grammar file from CLab 1 0 with an dedicated application pro vided by the parsing system Tesi Colletions http www codeproject com csharp sets asp 33 34 CHAPTER 5 THIRD PARTY REQUIREMENTS Chapter 6 CLab 1 0 API Reference 6 1 Namespace CLab Namespace Contents Page Interfaces Classes UD dts ama a Gea eee a Ae AA eee 36 The interface class for the library The library is designed in such way that everything should be done through this class COMMON ds Milan Natal Maia eA de e clans Mate tc Aba AS 41 Defines common enum types and constant values used within CLab ValdDoMmaih A AAA AAA 43 Class with valid domain information for a particular variable A O a E EAS 46 Class with the valid domains of each variable This class has a list of ValidDomain objects for each variable This is the result representation returned out of the library 35 36 CHAPTER 6 CLAB 1 0 API REFERENCE 6 1 1 Classes CLASS Clab The interface class for the library The library is designed in such way
28. Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 182 CHAPTER 6 CLAB 1 0 API REFERENCE e GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters info context GetType public System Type GetType Gets the runtime type of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Creates and returns a string representation of the current exception 6 7 NAMESPACE COM CALITHA GOLDPARSER 183 CLASS TokenParser Token based parser using the GOLD Parsing system Grammar tables for parsing are compiled from the parser grammar located in the doc folder The compiled grammar is located in the Aux iliary folder and is integrated in the compiled binaries This source file was initially generated by the GOLD Parsing system based on grammar definition
29. Timestamp of the XML data optional metadata e Description public string Description get set Optional header information in the XML file Description of the XML data optional metadata e Rules public System Collections Generic List CLab Data Expression Rules get ji Gets the list of rule expression objects in the internal data representation 6 4 NAMESPACE CLAB DATA 115 e Types public System Collections Generic List CLab Data Type Types get Gets the list of type objects in the internal data representation e Variables public System Collections Generic List CLab Data Variable Variables get i Gets the List of variable objects in the internal data representation CONSTRUCTORS e Constructor public CP Initializes a new instance of the CP class Parameters x xmlFilename The XML filename e Constructor public CP Initializes a new instance of the CP class Parameters x stream The stream METHODS e AddRule public void AddRule Adds a rule expression object to the internal data representation Parameters 116 CHAPTER 6 CLAB 1 0 API REFERENCE x newRule The rule to add e AddType public void AddType Adds a type object to the internal data representation Parameters newType The type object to add e AddVariable public void AddVariable Adds a variable object to the internal data representation
30. a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a string representation of the name of the variable type and the variable name 6 5 Namespace CLab Exceptions Namespace Contents Page 6 5 NAMESPACE CLAB EXCEPTIONS 145 Interfaces Classes ClabException e do AN ee eae eee A ee ee eee 146 ClabException is a generic exception class used for separating exceptions which we throw and system exceptions Looping through the inner excep tions should reflect the entire stack of messages and what lead to the excep tion ClabInternalErrorException 0 0 0 cc cece annaearol 150 Custom exception class used for internal errors Receiver should either rethrow the exception or halt the execution of ClabSharp ClabInvalidExpressionException 00 e cece eee ees 154 Custom exception class triggered by invalid parsing during the building of expressions ClabSymbolException 0 c cece rr 158 Custom exception class used for internal errors Receiver should either rethrow the exception or halt the execution of ClabSharp ClabXMLParserException 0 n eee eeeees 162 Custom exception class used for errors during XML
31. declared with the attributes start and end each can consist of a sequence of digits possibly preceded by a minus sign lt typeDecl name UserType gt lt typeVar gt Visitor lt typeVar gt lt typeVar gt Employee lt typeVar gt lt typeDecl gt lt typeDecl name ARange gt lt range start 0 end 10 gt lt typeDecl gt The variabel element is used for declaring the variables to be used in the configura tion It consists of a single varDec1 element not shown in Figure 2 2 for each variable declaration The varDecl element can consist of one or more varName elements each representing a variable of that type Which type to use is an attribute varType to the varDecl element lt varDecl varType PrinterType gt lt varName gt Printer lt varName gt lt varName gt AnotherPrinter lt varName gt lt varDecl gt The rule element is used for declaring the rules or constraints to be used in the configuration The rule element can consist of one or more ruleDecl1 elements each denoting a single rule The elements left right not neg are all of the same type and can be used recursively Negation can be set by enclosing the expression to negate in a not element and inversion can be set by enclosing the expression to invert in a neg element The operators which can be used in the op element is amp amp Il lt lt gt gt l gt gt y Ky fi An exampl
32. e BuildCSPExpr public Casper Data CSPExpr BuildCSPExpr Builds the CSP expr for an CLab Data ExpressionId expression Parameters x idexpr The CLab Data ExpressionId expression e BuildCSPExpr public Casper Data CSPExpr BuildCSPExpr Builds the CSP expr for an CLab Data ExpressionInt expression Parameters x iExpr The CLab Data ExpressionInt expression e BuildCSPExpr public Casper Data CSPExpr BuildCSPExpr Builds the CSP expr for an CLab Data ExpressionNotNeg expression Parameters x nnExpr The CLab Data ExpressionNotNeg expression e BuildCSPExpr public Casper Data CSPExpr BuildCSPExpr Builds the CSP expr for an CLab Data ExpressionBinary expression Parameters bExpr The CLab Data ExpressionBinary expression e BuildCSPExpression public Casper Data CSPExprWrapper BuildCSPExpression Builds a csp expression out of the passed in clab expression Updates the constraint graph with new data from the current expression 94 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters expr The clab expression e BuildCSPExpressions public Casper Data CSPExpressions BuildCSPExpressions Builds csp expressions of all clab expressions defined in the CLab Data CP in stance Also updates the Constraint graph of the problem ConvertOperator public Casper StaticData Operators ConvertOperator Converts a clab ope
33. e Constructor public CLabTextParser Initializes a new instance of the class METHODS e CPtoXML public System IO MemoryStream CPtoxML Parses plain text CP to XML format Parameters input String with CP input to parse e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 6 6 NAMESPACE CLAB PARSERS 171 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e XMLtoCP public string XMLtoCP Parses XML input to plain text CP Parameters filename Filename of XML input file 172 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabXmlParser Parses and validates the input XML file Inserts types variables and rules to the set CP object DECLARATION public class ClabXmlParser Object CONSTRUCTORS e Constructor public ClabXmlParser Initializes a new instance of the ClabXmlParser class Parameters x cpOb ject The cp object which gets th
34. hash table e GetType 80 CHAPTER 6 CLAB 1 0 API REFERENCE public System Type GetType Gets the of the current instance GetValidDomains public CLab ValidDomains GetValidDomains Gets the valid domains MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e printout public void printout Prints the specified list of BDDs Parameters b The list of BDDs SetCompileMethod public void SetCompileMethod Sets the compile method Parameters compileMethod The compile method UpdateResultBddExpr public buddy sharp Bdd UpdateResultBddExpr Updates the result BDD with the results from an extre expression Parameters x extrakxpr The extra expression 6 2 NAMESPACE CLAB BDD 81 e UpdateResultBDDUserChoice public buddy sharp Bdd UpdateResultBDDUserChoice Updates the result BDD with a user chosen variable and domain value Makes an expression out of the variable and value and ands it with the old result BDD Parameters x var The chosen variable x domain The chosen domain value e UpdateStatus public void UpdateStatus Updates the CLab status method Parameters x value The value 82 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS PQbdd Priority queue node with Comparable implementation DECLARATION public class PQbdd Object PROPERTIES e BDD public buddy sharp Bdd
35. idDomain object Both the variable and the domain values are represented as St rings These objects are placed in a ValidDomains object which contains a list of the ValidDomain objects CLab has an internal mapping from this string representation of variables and domain values to the internal BDD or CSP representation The application using the CLab library does only need to know about a common representation irrespective of what solution approach is chosen 2 1 3 Expression structure Expressions are constructed recursively in the same way as in the language definition ex plained in section 2 2 1 Figure 2 1 shows the different classes which together are used to build any kind of expression supported by CLab All implementation classes imple ments the abstract Expressions class and when they are initialized a ExprType enum value has to be set ExpressionlId is used for representing a variable or a enumera tion constant and the enum value should be set to etid ExpressionlInt should as the name implies be used for integer values and the enum value should be set to et_val To negate or invert another Expression the ExpressionNotNeg class is used Here the enum value tells whether to invert or to negate by setting it to either et_not or et_neg The ExpressionBinary class is used when we need to do a binary operation on two Expressions and the enum value represents the operator Expressions abstract
36. preview of the usage and possibilities of the CLab and CaSPer libraries The binary directory contains compiled binary files of the source code ready to be used NET Framework 2 0 needs to be installed to be able to execute them The CLab Configurator can be run by executing the ClabGui exe file The web based API documentation can be found in the API directory Chapter 2 CLab 2 1 Overview CLab is an open source C library for fast backtrack free interactive product configura tion Two different solving techniques are implemented and the user of the library can choose which one to use for configuration The library is designed to seamlessly combine the two fundamentally different approaches of CSP and BDD in a single configurator tool That means that irrespective of what approach is chosen the usage of the library is the same Both approaches share the same input data into the library and in the opposite side they also share the same result data representation What is really going on between the input and the output is hidden under the hood To make it easy to alter the code and implement new functions each module has its own level of abstraction The first level is the classes for general representation of the configuration problem and its resulting data These objects are designed quite similar to the CP language definition and does not offer any special functionality for solving the problem All classes belonging to thi
37. protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode 6 1 NAMESPACE CLAB 45 Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 46 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ValidDomains Class with the valid domains of each variable This class has a list of ValidDomain objects for each variable This is the result representation returned out of the library DECLARATION public class ValidDomains Object PROPERTIES e ValidDoms public System Collections Generic List CLab ValidDomain ValidDoms get ji Gets the list of the valid domains CONSTRUCTORS e Constructor public ValidDomains _ Initializes a new instance of the ValidDomains class Parameters x validDoms A list of valid domains e Constructor public ValidDomains _ Initializes a new instance of the ValidDomains class METHODS 6 1 NAMESPACE CLAB 47 e addValidDomain public int addValidDomain Adds the valid domain to the list Parameters validDomain The valid domain to add t
38. set Gets or sets the range variables CONSTRUCTORS e Constructor public Symbols Initializes a new instance of the Symbols class 134 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters cp The CP object METHODS e CheckExpressionType public void CheckExpressionType Checks if the expressions have valid types Parameters expression The expression e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e FillAndCheckType public void FillAndCheckType Fills the type list after the type has been checked e FillAndCheckVar public void FillAndCheckVar Fills the variable list after the variable has been checked e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 6 4 NAMESPACE CLAB DATA 135 e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MakeSetOfList public Iesi Collections Set MakeSetOfList Makes a set of a list Parameters list The original list e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 136 CHAPTER 6 CLAB 1
39. to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e RunCSPBuildExpr assembly Casper Data CSPExpr RunCSPBuildExpr Abstract method which runs CSPBuildExpr in CLab CSP CSPExpressionBuilder Dou ble dispatch pattern Parameters builder The CSPExpressionBuilder e Type2oper public string Type2oper Converts the type to an operator sign for printout Parameters 120 CHAPTER 6 CLAB 1 0 API REFERENCE type The operator to print out 6 4 NAMESPACE CLAB DATA 121 CLASS ExpressionBinary An expression consisting of a left and right side and an operator Implements the abstract Expression class DECLARATION public class ExpressionBinary Expression PROPERTIES e Left assembly CLab Data Expression Left get Returns left side expression e Right assembly CLab Data Expression Right get Returns right side expression e Type public CLab Common ExprType Type get Returns the type of this expression CONSTRUCTORS e Constructor public Exp
40. 0 API REFERENCE CLASS Type The Type class represents a CLab type There are two variants of Type objects 1 Type String typeName ArrayList states contains a enumeration of valid states for the type 2 Type String typeName int startOfRange int endOfRange contains a set range DECLARATION public class Type Object PROPERTIES e TypeName public string TypeName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public Type Initializes a new instance of the Type class Parameters typeName Name of the type METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 6 4 NAMESPACE CLAB DATA 137 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns the name of the type 138 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS TypeEnum The Type clas
41. API REFERENCE Returns a System String that represents the current System Object e Type2oper public string Type2oper Converts the type to an operator sign for printout Parameters type 6 4 NAMESPACE CLAB DATA 127 CLASS ExpressionInt Expression consisting of an integer Implements the abstract Expression class DECLARATION public class ExpressionInt Expression PROPERTIES e IntegerValue public int IntegerValue get Returns the integer value of this expression e Type public CLab Common ExprType Type get Returns the type of this expression CONSTRUCTORS e Constructor public ExpressionInt Initializes a new instance of the ExpressionInt class Parameters integer The integer value of this expression METHODS e Equals public bool Equals Determines whether the specified is equal to the current 128 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClon
42. An enumeration is a finite set of strings The Boolean type is the range from 0 to 1 Range and enumeration types can be defined by the user A CP description consists of a type declaration a variable declaration and a rule declaration The type declaration is optional if no range or enumeration types are defined cp type typedecl variable vardecl rule ruledecl typedecl id integer integer id idlst vardecl vartype idlst vartype bool id idlst id idlst ruledecl exp The identifier in CLab has been altered from the defined identifier in CLab 1 0 to support strings identifiers that start with numbers An identifier is hence a sequence of numbers letters underscore and the character or a string enclosed with the character An integer is a sequence of digits possibly preceded by a minus sign The symbol start a comment that extends until the end of the line The only comments which are stored in the XML format see Section 2 2 2 is comments which explicitly describes the file with Description lt text gt Author lt text gt Date YYYY MM DD The syntax of expressions is as follows 2 2 CONFIGURATION LANGUAGE DEFINITION 11 xp integer id exp exp exp exp op exp The semantics associativity and precedence of arithmetic logical and relational oper ators are defined as in C C Hence amp a
43. CLab and CaSPer User Manual Torbj rn Meistad Yngve Raudberget and Geir Tore Lindsve September 2006 IT University of Copenhagen Rued Langgaards Vej 7 DK 2300 Copenhagen S Copyright 2006 Torbj rn Meistad Yngve Raudberget and Geir Tore Lindsve Contents 1 Introduction 1 0 1 Installing instructions o 2 CLab lll o So Th chy i he cB eS ea lS ah ES Gah SS OS BS 2 1 1 Main interface of CLab 2 2 0 2626 de ee a aa 2 1 2 Valid Domains representation 2 1 3 Expression stt cture a a re Grae beige Acne goa ate g 2 1 4 Status messages A wae ge A ag Ee leg 2 1 5 CLab Code Example amp 49 008 69 Sede Se Re RO a da 2 2 Configuration Language Definition 4 2 2 1 CP Language Definition sd a Se ete haved 2 2 2 XML Language Definition 2 600 duna ds ee die dee aed ed ee 2 37 Parsi eos we shoe te ee ele o it de a o a Doel Clap XIE Parser tir hs pes eS A ie Ee Bas 23 2 Ll o Parser es yei y o pei e eee ee Dace Pee ig gale Bao 2 3 3 eT TesiParser hf a tl acy da dr tE 2A Errorhandlngs s s ecs mocs mors mie ad dh me ee be we ee do 3 CaSPer del COVERVICW 1 hoe Reo ee Mos ale MSR ale BASS Ss ESS 3 1 1 Main Interface class of CaSPer a eet 3 1 2 Expression structure dead ad led ad e Soke Sod 111 10 12 15 15 17 17 18 31 3 Stats MESSAGES os Yess Ze Bes Boss Se Ae Ee MAS 3 2 Error handlings 4 Sa 88 cede tg ane Ma eee aes a ae acer a aces 3 2 1 Ca
44. E COM CALITHA GOLDPARSER e Parse public void Parse Parses the specified source Parameters source The source in string representation e ToString public string ToString Returns a that represents the current 185 186 CHAPTER 6 CLAB 1 0 API REFERENCE Chapter 7 CaSPer API Reference 7 1 Namespace Casper Namespace Contents Page Interfaces Classes EM ri AE OS AAA A EA A 188 The interface of the Casper library This class supports searching for valid domains and reducing domains based on user selected domain values us ing the CSP algorithm Select value forward checking and Generalized look ahead StaticeData AAA A Rape Ae eee ee eA 192 A class for Caspers static data 187 188 CHAPTER 7 CASPER API REFERENCE 7 1 1 Classes CLASS Csp The interface of the Casper library This class supports searching for valid domains and reduc ing domains based on user selected domain values using the CSP algorithm Select value forward checking and Generalized look ahead DECLARATION public class Csp Object PROPERTIES e CasperVarDoms public System Collections Generic List Casper Data CasperVarDom Casper VarDoms get Gets the variable and domain list e CGraph public Casper Data ConstraintGraph CGraph get set Gets or sets the constraint graph e Expressions public Casper Data CSPExpressions Expressions get set Gets or s
45. ESPACE CLAB BDD 53 Gets the hash table mapping variable names to index CONSTRUCTORS e Constructor public BDDLayout Initializes a new instance of the BDDLayout class Parameters cp The CLab Data CP instance of the problem METHODS e BooleanVector public System Collections Generic List System Int32 BooleanVector Makes boolean vectors of variables Parameters nextBDDvar The next BDD variable x varNumber The variable number e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 54 CHAPTER 6 CLAB 1 0 API REFERENCE GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Returns a System String that represents the current CLab BDD BDDLayout 6 2 NAMESPACE CLAB BDD 55 CLASS BDDSpace Class for making BDDs based on the types variables and expressions of a CP problem Uses the BDDLayout mappi
46. GUI API REFERENCE e SaveFile public void SaveFile Saves the file Parameters text The text e SaveFileAs public void SaveFileAs Saves the file as Parameters x fileName Name of the file text The text e SetBDDCompileMethod public void SetBDDCompileMethod Sets the BDD compile method Parameters x compileMethod The compile method e SetCSP VariableOrdering public void SetCSPVariableOrdering Sets the CSP variable ordering Parameters varOrder The variable ordering e StartClab public bool StartClab Starts a new CLab instance and fills the GUI with initial data 8 1 NAMESPACE CLABGUI 261 e StartClabInitialSearchThread public void StartClabInitialSearchThread Starts the clab initial search thread e StopClab public void StopClab _ Sets the CLab reference to null e StopClabThreadIfRunning public void StopClabThreadIfRunning Stops the clab thread if running e StripPathFromFilename public string StripPathFromFilename Strips the path from filename Parameters x filename A System String that represents the filename with full path e UpdateGuiDomains public void UpdateGuiDomains Updates the GUI domains with the valid domains Parameters x vd The valid domaines CLab ValidDomains e ValueChosenSearchThread public void ValueChosenSearchThread Starts the clab value chose
47. HAPTER 6 CLAB 1 0 API REFERENCE CLASS Bval Class for BDD representation of the configuration space of a CP expression DECLARATION public class Bval Object PROPERTIES e BDDList public System Collections Generic List buddy_sharp Bdd BDDList get set Gets or sets the BDD list e DefCon public buddy sharp Bdd DefCon get set Gets or sets the default configuration CONSTRUCTORS e Constructor public Bval Initializes a new instance of the Bval class Parameters bddList The list of BDDs defcon The default configuration METHODS 6 2 NAMESPACE CLAB BDD 11 e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 78 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabBDD The main class for finding valid solutions the BDD way The class is designed to be used by CLab Clab
48. Interfaces Classes ClabSharp Gah gs AA OE N E 256 Main class of the GUI Does nothing but to initialize the GUI ParameterBitmapSingleton 0 00 0 c ccc cece eee e teen eens 257 A singleton for the different bitmaps representing the domain status for each domain value PROGRAM a ero de da etc AA dt eran o Del oda a a aa Na 258 This class is working between CLab and the GUI class MainGui The searching part is run in its own thread so the application won t hang during a heavy search 255 256 CHAPTER 8 GUI API REFERENCE 8 1 1 Classes CLASS ClabSharpGui Main class of the GUI Does nothing but to initialize the GUI DECLARATION public class ClabSharpGui Object 8 1 NAMESPACE CLABGUI 257 CLASS ParameterBitmapSingleton A singleton for the different bitmaps representing the domain status for each domain value DECLARATION public class ParameterBitmapSingleton Object CONSTRUCTORS e Constructor protected ParameterBitmapSingleton Initializes a new instance of the ParameterBitmapSingleton class METHODS e GetBitmap public System Drawing Bitmap GetBitmap Gets the bitmap representing the passed in int value Parameters STATUS The STATUS e Instance public ClabGui ParameterBitmapSingleton Instance _ Creates a new instance if one doesn t exist Return the existing instance otherwize 258 CHAPTER 8 GUI API REFERENCE
49. Lab The XML schema we have defined for CLab can be shown in simplified form in Fig ure 2 2 The solid lines show connections to inner elements and dotted lines shows the recursive structure in rules The XML structure has in addition to a header element three main elements type 2 2 CONFIGURATION LANGUAGE DEFINITION 13 Co ETS range start end y varName gt megan gt none A Figure 2 2 Simplified XML Schema for the CLab document format Note that denotes entities which can occur several times Dotted lines denote recursive connections variable rule which each explicitly denotes the same declarations as in the CP lan guage The header element is used for storing meta data for describing the problem configuration lt header gt lt description gt Printer Example lt description gt lt author gt Torbjorn Meistad Yngve Raudberget and Geir Tore Lindsve lt author gt lt date gt 2006 08 16 lt date gt lt header gt The type element is used for declaring the variable type to be used in the configura tion It consists of a single typeDec1 element not shown in Figure 2 2 for each type declaration The typeDec1 element can consist of either one or more typeVar ele ments or a range element Former is the enumerator type equal to the identifier in the CP language and can consist of letters numbers underscore and the character A range 14 CHAPTER 2 CLAB is
50. Make CasperVarDoms Makes the casper variables with domain values Casper Data CasperVarDom and the mapping from CLab Data CP representation to this representation The method 1s for internal use of this class 100 CHAPTER 6 CLAB 1 0 API REFERENCE e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab CSP CSPLayout 6 3 NAMESPACE CLAB CSP 101 CLASS CSPType An abstract class used by classes representing types in the CSP part of CLab The different pos sible values like strings for the enumeration type or integers for the range type are all encoded as ranges All of the types must have an end point DECLARATION public class CSPType Object PROPERTIES e End public int End get set Gets or sets the end of the range e TypeName public string TypeName get set Gets or sets the name of the type CONSTRUCTORS e Constructor public CSPType Initializes a new instance of the CSPType class Parameters typeName Name of the type end The end value 102 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt t
51. MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab BDD BDDLayoutTypeBoo e TypeFormat public CLab CPTypes TypeFormat Returns the CPTypes bool_type constant 68 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS BDDTypeEnum Class representing the enumeration type DECLARATION public class BDDTypeEnum BDDType PROPERTIES e BDDvarNum public int BDDvarNum get set Gets or sets the BDD variable number e DomainSize public int DomainSize get set Gets or sets the size of the domain e IndexToValue public System Collections ArrayList IndexToValue get Gets the list mapping index to value e TypeName public string TypeName get set Gets or sets the string representation of the name of the type e ValueToIndex public System Collections Hashtable ValueToIndex get Gets the hashtable mapping value to index 6 2 NAMESPACE CLAB BDD 69 CONSTRUCTORS e Constructor public BDDTypeEnum Initializes a new instance of the BDDLayoutTypeEnum class Parameters typeName Name of the type domainSize Size of the domain indexToValue List mapping index to value valueTolndex Hashtable mapping value to index METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters ob
52. Not all placeholder code has been replaced removed to facilitate further use DECLARATION public class TokenParser Object CONSTRUCTORS e Constructor public TokenParser Initializes a new instance of the TokenParser class Parsing from a file defined by Parameters filename Filename of input file for parsing xw The XML writer to write output to e Constructor public TokenParser Initializes a new instance of the TokenParser class Parameters stream The stream to parse xw The XML writer to write output to METHODS e CreateObjectFromNonterminal 184 CHAPTER 6 CLAB 1 0 API REFERENCE public object CreateObjectFromNonterminal Manage a nonterminal token object Parameters token Token to manage Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 6 7 NAMESPAC
53. The villain e SelectValue public System Nullable System Int32 SelectValue Implementation of Select Value Forward Checking from Dechter page 134 Internal method used by the LookAhead method Parameters var Variable to be checked x 1 The index var has in the variable list 202 CHAPTER 7 CASPER API REFERENCE CLASS LookAhead VarDom The class which stores the information of a variable and its domaine values Used by General izedLookahead DECLARATION public class LookAheadVarDom Object PROPERTIES e DomainValues public Iesi Collections Set DomainValues get set Gets or sets the domain values e SelectedValue public System Nullable System Int32 SelectedValue get Gets the current selected value of the variable e VarID public int VarID get set Gets og sets the variable ID CONSTRUCTORS e Constructor public LookAheadVarDom Initializes a new instance of the LookAheadVarDom class Parameters x varlID The variable ID x domainValues The domain values 7 2 NAMESPACE CASPER ALGORITHM 203 METHODS e AddToRemoved public void AddToRemoved Parameters val e DomainSize public int DomainSize Gets the domain size e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free re
54. a structures like a hash table GetType public System Type GetType Gets the of the current instance LookAhead public System Collections Generic List Casper Algorithm LookAhead VarDom LookAhead The Generalized Lookahead routine from Dechter page 133 Parameters x varDons List of CasperVarDom objects with variable and domain data e MakeLookAheadVarDoms public Casper Algorithm Lookahead Variables MakeLookAheadVarDoms Method for making LookAheadVar objects from CasperVarDom objects for internal use in this class Different variable orderings can be made with the constraint graph Parameters x casperVarDoms List of CasperVarDom objects varOrder The var order Graph The constraint graph e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current PruneNextDomain public int PruneNextDomain Checks each domain value for the future variables domains in forwardCheck Here we do the actual consistency check with the provided consistency implementation 7 2 NAMESPACE CASPER ALGORITHM 201 Parameters x CurrentVar Currently checked variable nextVar The variable and domain the method runs consistency check on e Remove public void Remove Updates the AllRemovedValues structure with the removed value of variable vic tim caused by variable villain Parameters x victim The victim x villain
55. ableOrdering Namespace Contents Page Interfaces Variable Ordering iu a A Ree ee ees 210 Interface for variable ordering The algorithm uses the GetNextVar method Classes MinimumWidthOrder Class for supporting minimum width ordering Static VarQrder a A a 213 An implementation of a static variable order that is the variable ordering equals the ordering given in the cp file 210 CHAPTER 7 CASPER API REFERENCE 7 3 1 Interfaces INTERFACE IVariableOrdering Interface for variable ordering The algorithm uses the GetNext Var method DECLARATION public interface VariableOrdering METHODS e GetNextVar public int GetNextVar All ordering implementations has to have a method for getting the next variable in relation to the passed in number in queue This method is used by the algorithm Parameters x number InQueue The number in queue 7 3 2 Classes CLASS MinimumWidthOrder Class for supporting minimum width ordering DECLARATION public class Minimum WidthOrder Object CONSTRUCTORS e Constructor 7 3 NAMESPACE CASPER ALGORITHM VARIABLEORDERING 211 public MinimumWidthOrder Initializes a new instance of the MinimumWidthOrdering class Parameters cGraph The constraint graph METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void
56. abstract Expression class ExpressionNotNeg iii Aa 130 An negated expression consisting of a left expression and negation type Im plements the abstract Expression class dd e o 133 Class for checking if the problem is valid Runs type and variable checks The Type class represents a CLab type There are two variants of Type objects 1 Type String typeName ArrayList states contains a enumeration of valid states for the type 2 Type String typeName int startOfRange int endOfRange contains a set range Pye En a SR AR 138 The Type class represents a CLab type CSPTypeEnum represents an enu meration type with a list of valid states domain Implements the abstract Type class Wy PCR anges a A ew dasae te dod os 141 The Type class represents a CLab type TypeRange represents a range type Implements the abstract Type class Variables tito dl ss 143 The Variable class represents a CLab variable In addition to the types set by Type objects CLab has an internal boolean type named bool 114 CHAPTER 6 CLAB 1 0 API REFERENCE 6 4 1 Classes CLASS CP The CP object contains the internal data representation parsed from the input XML file DECLARATION public class CP Object PROPERTIES e Author public string Author get set Optional header information in the XML file Author of the XML data optional metadata e Date public string Date get set Optional header information in the XML file
57. act CSPExprVar class DECLARATION public class CSPExprVarEnum CSPExprVar PROPERTIES e VarID public int VarID get set Gets or sets the variable ID CONSTRUCTORS e Constructor public CSPExprVarEnum _ Initializes a new instance of the CSPExprVarEnum class Parameters x varlID The var ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 245 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprVarEnum 246 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprVarInt Implementation class for the integer variable type of variable expressions Implements the CSP ExprVar abstract class DECLARATION public class CSPExprVarInt CSPExprVar PROPERTIES e VarID publi
58. ariables public Iesi Collections Set Variables get set Gets or sets the list of adjacent nodes e VariableWidth public int VariableWidth get set Gets or sets the width of the variable CONSTRUCTORS e Constructor public AdjacencyList _ Initializes a new instance of the AdjacencyList class METHODS e AddAllVars public void AddAllVars Adds a set of variable ids to the adjacency list 7 4 NAMESPACE CASPER DATA 217 Parameters x vars The set of variables to add to the adjacency list e AddVar public void AddVar Adds a single variable id to the adjacency list Parameters x varlD The variable id to add to the adjacency list e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance 218 CHAPTER 7 CASPER API REFERENCE e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e UpdateVarWidth public void UpdateVarWidth Update
59. auses the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public ClabInternalErrorException Initializes a new instance of the ClabInternalErrorException class Parameters message The exception message which describes the reason for the exception METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters 152 CHAPTER 6 CLAB 1 0 API REFERENCE obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters info context GetType public System Type GetType
60. ble for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance 6 1 NAMESPACE CLAB 43 CLASS ValidDomain Class with valid domain information for a particular variable DECLARATION public class ValidDomain Object PROPERTIES e Domains public System Collections Generic List System String Domains get Gets the valid domains e VarName public string VarName get Gets the name of the variable CONSTRUCTORS e Constructor public ValidDomain _ Initializes a new instance of the ValidDomain class Parameters varName Name of the variable typeName Name of the type typeFormat The CPTypes type format domains The list of domain values e Constructor public ValidDomain Initializes a new instance of the ValidDomain class 44 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters varName Name of the variable typeName Name of the type typeFormat The CPTypes type format METHODS e AddValidDomain assembly CLab ValidDomain AddValidDomain Adds a valid domain Parameters x domain The valid domain to add e EmptyValidDomain assembly void EmptyValidDomain Empties the valid domain list e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize
61. blic string GetUnsatisfiableRule Gets the unsatisfiable rule if BDD modus is chosen This information is not possible to retrieve in CSP modus GetValidDomains public CLab ValidDomains GetValidDomains Gets the valid domains for the constraint problem GetValidDomainsExtraRule public CLab ValidDomains GetValidDomainsExtraRule Gets the valid domains for extra rule added by the user The rule in this case is a chosen domain value for a single variable Parameters variable The variable that has been assigned a domain value by the user selectedDomain The selected domain value for the variable GetValidDomainsExtraRule public CLab ValidDomains GetValidDomainsExtraRule Gets the valid domains for an extra rule The rule can be any expression Parameters expr The added expression InitializeProblemSolver 6 1 NAMESPACE CLAB 39 public CLab ValidDomains InitializeProblemSolver Initializes the specified modus BDD if modus 0 or CSP if modus 1 Parameters modus The modus e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e SetBddCompileMethod public void SetBddCompileMethod Sets the BDD compile method Parameters compileMethod e SetCSPVariableOrdering public void SetCSPVariableOrdering Sets the CSP variable ordering CspVariableOrdering Parameters varOrdering The va
62. c int VarID get set Gets or sets the variable ID CONSTRUCTORS e Constructor public CSPExprVarInt _ Initializes a new instance of the CSPExprVarlnt class Parameters x varlID The var ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 247 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprVarlnt 248 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprWrapper Stores wrapped expression objects along with a set of its variables IDs Used during consistency to filter out expressions which have variables which isn t set yet DECLARATION public class CSPExprWrapper Object PROPERTIES e RuleExpression public Casper Data CSPExpr RuleExpression get set The contained express
63. c ped 256 vi Chapter 1 Introduction This document describes version 1 0 of CLab and version 1 0 of CaSPer CLab is a C software tool for fast backtrack free and complete interactive product configuration using constraint programming or binary decision diagrams CaSPer is a C library for solving CSP problems with CSP algorithms Chapter 2 describes the CLab library Chapter 3 describes the CaSPer library which is used for handling CSP Chapter 4 describes CLab Configurator which is the client GUI application we have developed to demonstrate usage of the software Chapter 5 describes the third party requirements for CLab Chapter 6 to 8 is API references for CLab CaSPer and the GUI 1 0 1 Installing instructions For all official versions of this thesis we enclose the project source code binary files and web based API documentation on a supplementary CD Everything can also be downloaded as a zip file from http tihlde org torbjorm clab All source code for CLab CaSPer and CLab Configurator is available in the source directory Visual studio 2005 and NET 2 0 has been used as the development environment To open all parts use the solution file of the project ClabSharp sIn If the solution is built using a Visual Studio version supporting NET 2 0 binary files should be created Two test 2 CHAPTER 1 INTRODUCTION projects are included ClabSharpTest and CasperTest Both are console applications which gives a
64. ce of CLab The Clab class is the main class of CLab When Clab is initialized it starts parsing the configuration problem The Clab class has two constructors One takes a XML file name as an argument while the other one takes a memory stream with the XML file Using either the XML file name or the memory stream the internal configuration problem representation is made and symbolically checked Using the Clab instance it is now possible to initialize a problem solver CLab supports solving configuration problems using either BDDs or CSP algorithms The ini tialization returns all domain values using the valid domains representation which encodes the variables and their domain values as strings in the same form as in the XML file Af terwards valid domain values can be computed reflecting the rules of the problem using the chosen method This operation returns the valid domain representation as well which now might be reduced because of the rules It is now possible for the user of the library to select a one of the valid domain values for a variable to further reduce the problem Each time this operation is run valid domain computation is performed and the results are returned Because of this the configuration process is guaranteed to be backtrack free It is also possible to add an extra rule to the problem which also returns the reduced valid domains Adding extra rules can lead to a reduced or solved problem or to a problem with no p
65. claimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e RunCSPBuildExpr assembly Casper Data CSPExpr RunCSPBuildExpr Abstract method which runs CSPBuildExpr in CLab CSP CSPExpressionBuilder Dou ble dispatch pattern Parameters 132 CHAPTER 6 CLAB 1 0 API REFERENCE builder The CSPExpressionBuilder e ToString public string ToString Returns a textual representation of the not neg expression e Type2oper public string Type2oper Converts the type to an operator sign for printout Parameters type 6 4 NAMESPACE CLAB DATA 133 CLASS Symbols Class for checking if the problem is valid Runs type and variable checks DECLARATION public class Symbols Object PROPERTIES e AllVariables public lIesi Collections Set AllVariables get Gets the set of all variables e BoolVariables public Iesi Collections Set BoolVariables get set Gets or sets the bool variables e EnumerationVariables public Iesi Collections Set EnumerationVariables get Gets the enumeration variables e RangeVariables public lIesi Collections Set RangeVariables get
66. cluded class and namespace definitions nor the specification of the namespaces and DLLs we rely on A complete working copy can be found in the source code in the CLabSharpTest project x A simple example of using the CLabSharp library using the printer example file Loading the printerExample xml file Change the path to match yours String xmlFile printerExample xml Console WriteLine Starting Clab Start a Clab instance from the XML file Clab clab new Clab xmlFile xkxxxkxxxxxProblem solving using BDD x x x xx x xx clab InitializeProblemSolver CLabModus bdd_modus xkxxxxkxxxxxxProblem solving using CSPxxxxx xxxx just uncomment the line below clab InitializeProblemSolver CLabModus csp_modus BDD compile method 2 2 CONFIGURATION LANGUAGE DEFINITION 9 clab SetBddCompileMethod BddCompileMethod cm_ascending This line prints out the progress of the search clab StatusEvent new Clab StatusEventHandler ctCSP PrintStatus Adding the rule User Visitor manually can be done like this CLab Data ExpressionBinary binaryExpr new CLab Data ExpressionBinary new CLab Data ExpressionId User Common ExprType et_eq new CLab Data ExpressionId Visitor Adding the created rule to the CP structure clab Cp AddRule binaryExpr Start the Valid Domains Computation independent o
67. d UpdateAdjacencyList Updates the adjacency list representation of the graph by adding all neighbours of a variable to its adjacency list Creates the adjacency list 1f 1t doesn t exist Parameters x interconNodes A list of interconnected nodes 224 CHAPTER 7 CASPER API REFERENCE CLASS CSPExpr An abstract class for CSP Expressions All Expression classes implements this class DECLARATION public class CSPExpr Object CONSTRUCTORS e Constructor public CSPExpr Initializes a new instance of the CSPExpr class METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 7 4 NAMESPACE CASPER DATA 225 e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 226 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprBin DECLARATION public class CSPExprBin CSPExpr PROPERTIES e Left public Casper Data CSPExpr Left get Gets the
68. e Creates a shallow copy of the current RunCSPBuildExpr assembly Casper Data CSPExpr RunCSPBuildExpr Abstract method which runs CSPBuildExpr in CLab CSP CSPExpressionBuilder Dou ble dispatch pattern Parameters builder The CSPExpressionBuilder ToString public string ToString 6 4 NAMESPACE CLAB DATA Returns a textual representation of the expression e Type2oper public string Type2oper Converts the type to an operator sign for printout Parameters type 129 130 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ExpressionNotNeg An negated expression consisting of a left expression and negation type Implements the abstract Expression class DECLARATION public class ExpressionNotNeg Expression PROPERTIES e Left assembly CLab Data Expression Left get Gets the left expression e Type public CLab Common ExprType Type get Returns the type of this expression CONSTRUCTORS e Constructor public ExpressionNotNeg _ Initializes a new instance of the ExpressionNotNeg class Parameters type The operator left The left expression METHODS 6 4 NAMESPACE CLAB DATA 131 e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is re
69. e DECLARATION public class BDDTypeBool BDDType PROPERTIES e BDDvarNum public int BDDvarNum get set Gets or sets the BDD variable number e DomainSize public int DomainSize get set Gets or sets the size of the domain e TypeName public string TypeName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public BDDTypeBool Initializes a new instance of the BDDLayoutTypeBoo class Parameters typeName Name of the type x domSize Size of the domain 66 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetDomainValue public string GetDomainValue Method that gets the Domain value at index Index can be 0 to domain size I Parameters x index The index of the domain value e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance 6 2 NAMESPACE CLAB BDD 67 e MemberwiseClone protected object
70. e public string Message get Gets a message that describes the current exception 6 5 NAMESPACE CLAB EXCEPTIONS 167 e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public TokenParserException Initializes a new instance of the TokenParserException class Parameters message The exception message which describes the reason for the exception inner The inner exception e Constructor public TokenParserException Initializes a new instance of the TokenParserException class Parameters message The exception message which describes the reason for the exception 168 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a deri
71. e data from the xml file METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 6 6 NAMESPACE CLAB PARSERS 173 e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e InitializeParser public void InitializeParser Initializes the parser e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e Parse public void Parse Parses the specified stream Parameters x stream The stream e Parse public void Parse Parses the specified XML file Parameters x xmlUrl URL for the XML file 174 CHAPTER 6 CLAB 1 0 API REFERENCE 6 7 Namespace com calitha goldparser Namespace Contents Page Interfaces Classes Rule Exception 0 ASES A A ta 175 Internal exception class used by the parser engine SymbolException eo A it 179 Internal exception class used by the parser engine e 183 Token based parser using the GOLD Parsing system Grammar tables for parsing are compiled from the parser grammar located in the doc folder
72. e of the ruleDec1 element 2 3 PARSING lt ruleDecl gt lt left gt lt left gt lt id gt Printer lt id gt lt left gt lt operator gt lt operator gt lt right gt lt id gt Simple lt id gt lt right gt lt left gt lt operator gt gt gt lt operator gt lt right gt lt left gt lt id gt Papersize lt id gt lt left gt lt operator gt lt operator gt lt right gt lt id gt A3 lt id gt lt right gt lt right gt lt ruleDecl gt 2 3 Parsing 15 There are two parsers implemented in CLab One which parses XML input and injects the data in the internal data structure and another which parses plain CP text to XML In addition there is a CLabTextParser class which is a helper class for converting XML to plain text and XML to plain text CP 2 3 1 ClabXMLParser To parse XML input data to objects in the internal data structure we use standard classes from the System Xml and System Xm1l Schema namespaces A XmlReader is set up to traverse the complete XML structure and inject the input as objects in the internal data structure The public methods available from the ClabXMLParser class is void ClabXmlParser CP cpObject 16 CHAPTER 2 CLAB This is the constructor for the XML parser The input is the CP object which will hold the information from the XML file void InitializeParser This method is called internally It carries out the following operation e Se
73. e printer example can be seen below Description CLab 1 0 Example Author CLab Crew Date 2006 08 16 type userType Visitor Employee paperType A3 A4 A5 printerType Simple Advanced inkType Color Black variable userType User paperType Papersize printerType Printer inkType Ink rule Printer Simple gt gt Papersize A3 Printer Simple gt gt Ink Black Papersize A3 gt gt Ink Black User Visitor gt gt Printer Simple 2 2 2 XML Language Definition The Extensible Markup Language XML is a W3C recommended general purpose markup language for creating special purpose markup languages and can be used to both describe and contain data XML is ideal for documents containing structured information where the information can contain both content and a definition of what role that content plays The XML data is structured as a tree with elements and the entire tree structure is called a document XML has no data description separate from the data itself unlike fixed or delimited data formats The documents are self describing The data has specially for matted tags around it that give the data a name as well as a position in the document s tree structure We can see from this that XML as a document format is ideal for storing object structures in a structure and well defined way which is the main decision for choosing it for C
74. e that describes the current exception e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public ClabXMLParserException Initializes a new instance of the ClabXML ParserException class Parameters message The exception message which describes the reason for the exception inner The inner exception e Constructor public ClabXMLParserException Initializes a new instance of the ClabXML ParserException class Parameters 164 CHAPTER 6 CLAB 1 0 API REFERENCE message The exception message which describes the reason for the exception METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exception
75. e to CP variable mapping e CpVarNum public int CpVarNum get Gets the number of CP variables e Dom public System Int32 Dom get Gets the list of domain size for each variable e DomStart public System Int32 DomStart get Gets the list with the index of the BDD variable where the encoding of each CP variable starts DomStart i index of the BDD variable where the encoding of CSP 99599 variable 1 starts 6 2 NAMESPACE CLAB BDD 85 CONSTRUCTORS e Constructor public ValidAssignmentData Initializes a new instance of the ValidAssignmentData class Parameters layout The BDDLayout instance METHODS e ClabEnd public void ClabEnd Runs the ClabEnd method of buddy _sharp Bdd e CreateValidAssignmentData public void CreateValidAssignmentData Method to create the valid assignment data Use the Bdd valExist i j method to retrieve the results Parameters resultBdd The result BDD to create the valid assigment data on e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 86 CHAPTER 6 CLAB 1 0 API REFERENCE e GetHashCode public int GetHashCode Serves as a hash function for a particular ty
76. eName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public BDDTypeRange Initializes a new instance of the BDDLayoutTypeRange class 72 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters typeName Name of the type x startOfRange The start of the range x domainSize Size of the domain METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetDomainValue public string GetDomainValue Method that gets the Domain value at index Index can be 0 to domain size ds Parameters index The index of the domain value e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 6 2 NAMESPACE CLAB BDD 73 e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab BDD BDDLayoutRange e TypeFormat public CLab CPTypes TypeFormat Returns the CPTypes ran
77. eOrdering public Casper CspVariableOrdering VariableOrdering get set Gets or sets the variable ordering CONSTRUCTORS e Constructor public GeneralizedLookahead Initializes a new instance of the GeneralizedLookahead class Parameters expressions The expressions variableOrdering The variable ordering cGraph The constraint graph 7 2 NAMESPACE CASPER ALGORITHM 199 METHODS e BacktrackDomains public void BacktrackDomains This method backtracks the changes the variable villain executed on the other vari ables domains Parameters x villain The villain e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e ForwardCheck public bool ForwardCheck Loops through future variables with respect to the current variable This method checks if one of the future variables domains is empty with the current assignment Parameters x currentVar The variable we are currently investigating x i The index currentVar has in the variable list e GetHashCode public int GetHashCode 200 CHAPTER 7 CASPER API REFERENCE Serves as a hash function for a particular type is suitable for use in hashing algo rithms and dat
78. efines the event handler function interface void MethodName int FieldName To add the method the operation StatusEvent new StatusEventHandler MethodName is run is used to add and to remove 3 2 Error handling As with CLab CaSPer throws a single expression type CasperException to fa cilitate an easy error handling In addition to the times when CaSPer itself throws this exception all system exceptions are enclosed in this exception type Since all exceptions thrown out of CaSPer are enclosed within a CasperException object CLab only needs to focus on catching this single exception type from CaSPer and take the necessary measures What CLab does is to again enclose this exception in a ClabException which is thrown out to the client application 3 2 ERROR HANDLING 25 3 2 1 Casper Code Example In this section we present a small code example on how to use the CaSPer library We have not included class and namespace definitions nor the specification of the namespaces and dlls we rely on A complete working copy can be found in the source code in the CasperTest project A simple example of using the CaSPer Library x Consider the following constraint problem x variables x0 x1 x2 Domain for all variables 0 1 Rules x 1 x0 x1 x 2 xl x2 x Csp casper new Csp Create domains 0 2 as a list of integers List lt int gt domain0 new List lt int gt List lt int gt do
79. em Type GetType Gets the of the current instance 7 4 NAMESPACE CASPER DATA 221 e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CasperVarDom 222 CHAPTER 7 CASPER API REFERENCE CLASS ConstraintGraph A class which represents the constraint graph of a csp problem DECLARATION public class ConstraintGraph Object PROPERTIES e CGraph public System Collections Hashtable CGraph get Gets the constraint graph CONSTRUCTORS e Constructor public ConstraintGraph Initializes a new instance of the ConstraintGraph class METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection 7 4 NAMESPACE CASPER DATA 223 e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e UpdateAdjacencyList public voi
80. emValStructure public System Collections Hashtable RemValStructure get Gets or sets the removed values structure CONSTRUCTORS e Constructor public RemovedValues nitializes a new instance of the RemovedValues class Initial t f the R dValues cl METHODS e Clear public void Clear Clears the removed value structure e Equals public bool Equals Determines whether the specified is equal to the current set 208 CHAPTER 7 CASPER API REFERENCE Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance Insert public void Insert Inserts the specified removed value The key is the specified variable Parameters removedValue The removed value x var The variable MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current Remove public void Remove 7 3 NAMESPACE CASPER ALGORITHM VARIABLEORDERING 209 Sets the value at key var in the remValStructure to be null Parameters x var The variable 7 3 Namespace Casper Algorithm Vari
81. entation y The right 2 complementary BDD representation e Equals 58 CHAPTER 6 CLAB 1 0 API REFERENCE public bool Equals Determines whether the specified is equal to the current Parameters obj Expr2BddVec public CLab BDD Bval Expr2BddVec _ Compiles a expression into a Bval object Parameters expression The expression to be compiled Extend public void Extend Extends the specified x with k elements Parameters x The 2 complementary BDD representation to be extended k Number of elements to extend with Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType 6 2 NAMESPACE CLAB BDD 59 public System Type GetType Gets the of the current instance e Integer2Bool public buddy sharp Bdd Integer2Bool Converts the specified 2 complementary BDD represantation x to a BDD Parameters x The 2 complementary representation e LessThan public buddy sharp Bdd LessThan Calculates a BDD representing the less than operation on two 2 complementary BDD representations Parameters x The left 2 complementary BDD representation
82. enum_ type constant 110 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS CSPTypeRange A class for representing range types in the CSP part of CLab The different possible domain values for a range are encoded as a range with a start point and an end point Implements the abstract CSPType class DECLARATION public class CSPTypeRange CSPType PROPERTIES e End public int End get set Gets or sets the end of the range e Start public int Start get Gets the start point of the range e TypeName public string TypeName get set Gets or sets the name of the type CONSTRUCTORS e Constructor public CSPTypeRange Initializes a new instance of the CSPTypeRange class Parameters typeName Name of the type 6 3 NAMESPACE CLAB CSP 111 start The start of the range end The end of the range METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetIntRepOfDomainString public int GetIntRepOfDomainString Gets the int representation of the stri
83. ers rule Current expression Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance IsConsistent public bool IsConsistent Main method for Consistency checks Parameters allAssignedVars All assigned variables including currAss and nex tAss Hashtable of LookAheadVarDom objects x CurrAss Current assignment 7 2 NAMESPACE CASPER ALGORITHM 197 nextAss Next assignment e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 198 CHAPTER 7 CASPER API REFERENCE CLASS GeneralizedLookahead Implementation of Generalized lookahead with Select value forward checking DECLARATION public class GeneralizedLookahead Object FIELDS e ASCENDINGORDER public int ASCENDINGORDER Constant which represent ascending variable ordering e MINWIDTHORDER public int MINWIDTHORDER Constant which represent the minimum width variable ordering PROPERTIES e Variabl
84. es of tokens The grammar file which the parser uses are based on the same grammar file used in CLab 1 02 and it is compiled into tables which are used in runtime parsing As the parser accepts a sequence of tokens it determines based on the compiled tables when the grammars respective rules are complete and verifies the syntactic correctness of the token sequence The end result of the process is a derivation which represents the token sequence organized following the rules of the grammar The TokenParser class implements a parser which depending on the accepted to ken takes the required actions to write the input to a specified XML stream It uses a standard XmIWriter from the System Xm1 namespace 2 3 3 CLabTextParser As previously stated ClabTextParser is a helper class used by our GUI application It is developed so that it is trivial to move data between the textual user interface and the XML files These are the public methods in the ClabTextParser String XMLtoCP string filename Parses a XML file and prints the data to a string and returns it It carries out the following Operations e Creates a new CP object from the specified filename The CP class then uses the ClabXMLParser to get the data from the XML file e Prints the contents of the CP structure to a string with the use of the toString method for the content objects and returns that string GOLD Parsing System http www devincook com goldpar
85. ets the expressions e OmitTestOnSingleValuedDomains public bool OmitTestOnSingleValuedDomains get set Gets or sets a value indicating whether single valued domains should be omited 7 1 NAMESPACE CASPER 189 e VariableOrdering public Casper CspVariableOrdering VariableOrdering get Gets the variable ordering CONSTRUCTORS e Constructor public Csp Initializes a new instance of the Csp class The default Implementation of ICon sistent is used Parameters expressions The expressions casperVarDons The list with variables domains e Constructor public Csp Initializes a new instance of the Csp class CasperVarDom objects must be added afterwards to use the valid domains methods The default implementation of IConsistent is used Parameters expressions The expressions e Constructor public Csp Initializes a new instance of the Csp class CasperVarDom objects must be added and a consistent implementation of IConsitent must be set afterwards to use the valid domains methods 190 CHAPTER 7 CASPER API REFERENCE METHODS e AddCasperVarDom public int AddCasperVarDom Adds a new variable and domain to the problem Parameters x vardom The new variable and domain e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Fi
86. f the choice of CSP or BDD approach ValidDomains vd clab GetValidDomains Console WriteLine n n Console WriteLine n nValid domains after adding user Console Write Papersize A4 n Simulating the interactive selection during a configuration session we select Papersize A4 vd clab GetValidDomainsExtraRule Papersize A4 Print out of the remaining valid domains for int i 0 i lt vd ValidDoms Count 1 ValidDomain v ValidDomain vd ValidDoms i n v VarName for int j 0 j lt v Domains Count j Console Write Console Write v Domains j 2 2 Configuration Language Definition CLab supports two different input languages which both compile to the same internal data structure Due to the nature of being derived from CLab 1 0 CLab supports the same CP 10 CHAPTER 2 CLAB language as CLab 1 0 with some alterations related to string identifiers This language is defined in Section 2 2 1 In addition we have developed a XML structure which can be used to store a configuration problem Since XML is a cross platform language we considered it to be a good way of making the CP language accessible to a wide variety of systems and platforms The XML structure is defined in Section 2 2 2 2 2 1 CP Language Definition The CP language has two basic types range and enumeration A range is a consecutive and finite sequence of integers
87. ge type constant 74 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS BDDVariable Class representing a CLab variable DECLARATION public class BDDVariable Object PROPERTIES e BddVar public System Collections Generic List System Int32 BddVar get Gets the BDD variable list e Typelndex public int Typelndex get Gets the index of the belonging type CONSTRUCTORS e Constructor public BDDVariable Initializes a new instance of the BDDLayoutVariable class Parameters bddvVar The BDD variables which together makes a Clab variable x typelndex Index of belonging type METHODS e Equals public bool Equals Determines whether the specified is equal to the current 6 2 NAMESPACE CLAB BDD 75 Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab Data BDDLayoutVariable 76 C
88. he valid domains according to the new rule Returns the remaining valid do mains int Clab StatusUpdateCount Returns the maximum number of calls to the status event Can For instance be used to set the max value of a progress bar int Clab SetCSPVariableOrdering CspVariableOrdering varOrdering Sets the variable ordering to be used when solving the problem with CSP algorithms The argument CspVariableOrdering defines variable ordering to use There are two op tions Method Description vo_static Iterate through the variables according to their variable index vominwidth Iterate through the variables according to their adjacency lists Variable with the largest list is chosen first The default method is vo_static int Clab SetBddCompileMethod BddCompileMethod compileMethod The argument compileMethod defines the compilation approach There are three op tions Method Description cm static Conjoin the BDDs of the rules in the order they appear in the CP file cm_dynamic Add the BDDs of the rules to a work list In each iteration conjoin the two smallest BDDs and add the result to the work list Return the resulting single BDD in the work list cm_ascending Sort the BDDs of the rules according to their size Conjoin the sorted BDDs from left to right The default method is cm_dynamic 2 1 OVERVIEW 7 2 1 2 Valid Domains representation Each variable and its valid domains are represented as a Val
89. in 6 2 NAMESPACE CLAB BDD 63 METHODS e BooleanVarNumber public int BooleanVarNumber Calculates the number of BDD variables needed using the domain size Parameters x domainSize Size of the domain e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetDomainValue public string GetDomainValue Method that gets the Domain value at index Index can be 0 to domain size Esa Parameters x index The index of the domain value e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 64 CHAPTER 6 CLAB 1 0 API REFERENCE GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Returns a System String that represents the current CLab BDD BDDLayoutType TypeFormat public CLab CPTypes TypeFormat Returns a constant from the CPTypes enumeration representing the current type 6 2 NAMESPACE CLAB BDD 65 CLASS BDDTypeBool Class representing the boolean typ
90. ion object e VariablesInExpr public Iesi Collections Set VariablesInExpr get set Set of variables which the contained expression object consists of CONSTRUCTORS e Constructor public CSPExprWrapper Constructor Parameters anExpr An expression object representing a rule variablesInExpr Set of variable IDs used in the rule METHODS 7 5 NAMESPACE CASPER EXCEPTIONS 249 e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 7 5 Namespace Casper Exceptions Namespace Contents Page Interfaces 250 CHAPTER 7 CASPER API REFERENCE Classes Casper EXCODGON SS A TIT eee ee 251 Custom exception class used for exceptions thrown out of the library 7 5 NAMESPACE CASPER EXCEPTIONS 251 7 5 1 Classes CLASS CasperException Custom exception class used for exceptions thrown out of the library DECLARATION
91. ived class sets the with information about the exception Parameters info context 6 5 NAMESPACE CLAB EXCEPTIONS 157 e GetType public System Type GetType Gets the runtime type of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 158 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabSymbolException Custom exception class used for internal errors Receiver should either rethrow the exception or halt the execution of ClabSharp DECLARATION notpublic class ClabSymbolException Exception PROPERTIES Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion InnerException public System Exception InnerException get Gets the instance that caused the current exception Message public string Message get 6 5 NAMESPACE CLAB EXCEPTIONS 159 Gets a message that describes the current exception e Source public string Source get set
92. j e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetDomainValue public string GetDomainValue Method that gets the Domain value at index Index can be 0 to domain size ie Parameters index The index of the domain value 70 CHAPTER 6 CLAB 1 0 API REFERENCE GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString gt Returns a System String that represents the current CLab BDD BDDLayoutTypeEnum TypeFormat public CLab CPTypes TypeFormat Returns the CPTypes enum type constant 6 2 NAMESPACE CLAB BDD 71 CLASS BDDTypeRange Class representing the range type DECLARATION public class BDDTypeRange BDDType PROPERTIES e BDDvarNum public int BDDvarNum get set Gets or sets the BDD variable number e DomainSize public int DomainSize get set Gets or sets the size of the domain e StartOfRange public int StartOfRange get Gets the start of the range e TypeName public string Typ
93. left expression e Oper public Casper StaticData Operators Oper get Gets the operator e Right public Casper Data CSPExpr Right get Gets the right expression CONSTRUCTORS e Constructor public CSPExprBin Initializes a new instance of the CSPExprBin class Parameters left The left expression right The right expression oper The operator 7 4 NAMESPACE CASPER DATA 227 METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprBin 228 CHAPTER 7 CASPER API REFERENCE CLASS CSPExpressions A class which keeps track of the expressions for a CSP problem DECLARATION public class CSPExpressions Object PROPERTIES e WrappedExprList public Syste
94. luedDomains Set Get property This property allows setting or getting the switch for omitting searches on variables with single valued domain That is variables which are part of a partial configuration Default is false 22 CHAPTER 3 CASPER int Casper AddCasperVarDom CasperVarDom vardom This method adds vardom to the list over variables and domain data and updates the internal mapping The int returned is the internal index it gets inside CaSPer List lt CasperVarDom gt Casper ValidDomainsUserChoice CasperVarDom var int domainVal This method runs the valid domains method after reducing the var object to only have domainVal as valid domain value That is adding domainVal to the partial configura tion The valid domains results are returned as a list of variables and domain data null is returned if the problem for some reason is not valid A reason could be passing in an invalid domain value or that Val idDomains method is not run first List lt CasperVarDom gt Casper ValidDomains This method runs the valid domains method The valid domains results are returned as a list of variables and domain data if the problem is valid Otherwise nul 1 is returned 3 1 2 Expression structure Expressions are constructed recursively almost in the same way as in CLab Figure 3 1 shows the different classes which together are used to build the expressions CaSPer sup ports There are three different ab
95. m Collections Generic List Casper Data CSPExprWrapper Wrapped ExprList get set Gets or sets the wrappet expression list CONSTRUCTORS e Constructor public CSPExpressions _ Initializes a new instance of the CSPExpressions class METHODS e AddWrappedExpr public int AddWrappedExpr Adds the wrappet expression Parameters wrappedExpr The wrappet expression e Equals public bool Equals Determines whether the specified is equal to the current 7 4 NAMESPACE CASPER DATA 229 Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 230 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprNeg DECLARATION public class CSPExprNeg CSPExpr PROPERTIES e Left public Casper Data CSPExpr Left get Gets the expression CONSTRUCTORS e Constructor public CSPExpNeg Initializes a new instance of the CSPExprNeg class Parameters left The left expression
96. mainl new List lt int gt List lt int gt domain2 new List lt int gt Add values domain0 Add domain0 Add domainl Add domainl Add domain2 Add domain2 Add l to all domains r r 0 i T r r Create variable objects with variable ids 0 1 2 from the domains casper AddCasperVarDom new CasperVarDom 0 domain0 casper AddCasperVarDom new CasperVarDom 1 domainl casper AddCasperVarDom new CasperVarDom 2 domain2 Make the rules as expression objects casper Expressions new CSPExpressions CSPExpr exprl new CSPExprBin new CSPExprVarlInt 0 new CSPExprVarlInt 1 StaticData Operators eq CSPExpr expr2 new CSPExprBin new CSPExprVarInt 0 new CSPExprVariInt 2 StaticData Operators gt Make a set of which variables are found in which rule 26 Set variablesInRul Set variablesInRul CHAPTER 3 CASPER new HybridSet new HybridSet variablesInRulel Add variablesInRulel Add variablesInRule2 Add variablesInRule2 Add Creating a Constraint Graph is optional but required if one wishes to use the minimum width ordering of variables ConstraintGraph constraintGraph new ConstraintGraph Add the variableInRule sets into the constrintGraph as adjacency lists constraintGraph UpdateAdjacencyList variablesInRulel constraintGraph UpdateAdjacencyList variablesInRule2 xxxxxvariable ordering
97. mp and denote logical negation division modulus equality inequality conjunction and disjunction respectively The only exception is the pipe operator gt gt that denotes implication The precedence and associativ ity is shown in Table 1 Notice that the convention of following C C precedence causes the pipe operator to have higher precedence than is usual for logical implication Operators Associativity hies right to left x left to right pos left to right gt gt left to right lt lt gt gt left to right left to right amp amp left to right left to right Table 2 1 Precedence and associativity of operators The semantics of an expression is the set of variable assignments that satisfy the expres sion For example assume that the type of variable x and y is the range 4 8 The set of assignments to x and y that satisfies the expression x 2 y is then 4 6 5 7 An assignment for which there exists an undefined operator in the expression is assumed not to satisfy the expression Thus the set of assignments to x and y that satisfies x y 2 is 8 4 Conversion between Booleans and integers is also defined as in C C True and false is converted to 1 and 0 and any non zero arithmetic expression is converted to true Due to these conversion rules it is natural to represent the Boolean constants true and false with the integers 1 and 0 12 CHAPTER 2 CLAB The CP file for th
98. mpl class Parameters expressions The expressions to be used as rules METHODS e AssignedVarsContainsAll public bool AssignedVarsContainsAll Verifies whether the assigned variables contains all the variables in the rule or not Parameters x vars Set of variables in the current rule e ConsistentCheckExpression public int ConsistentCheckExpression Returns the currently selected value for the variable associated in the expression Parameters 7 2 NAMESPACE CASPER ALGORITHM 195 rule Current expression e ConsistentCheckExpression public int ConsistentCheckExpression Returns the currently selected value for the variable associated in the expression Parameters rule Current expression e ConsistentCheckExpression public int ConsistentCheckExpression Returns the currently selected value for the variable associated in the expression Parameters rule Current expression e ConsistentCheckExpression public int ConsistentCheckExpression Returns the Int Const value of the terminal expression Parameters x rule Current expression e ConsistentCheckExpression public int ConsistentCheckExpression Returns the result of the negation Parameters x rule Current expression e ConsistentCheckExpression public int ConsistentCheckExpression Returns the result of binary expressions 196 CHAPTER 7 CASPER API REFERENCE Paramet
99. n for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance 7 2 Namespace Casper Algorithm Namespace Contents Page Interfaces 7 2 NAMESPACE CASPER ALGORITHM 193 Classes CONSISICNE 25 56 A A So og RL 194 CaSPers default implementation of the Consistent interface GeneralizedLookahead 0 cc cece cece cece teen eee e een e nas 198 Implementation of Generalized lookahead with Select value forward checking LookAhead Var Do 5 0 A A A oe ees 202 The class which stores the information of a variable and its domaine values Used by GeneralizedLookahead Lookahead Variables 0 cece eee eect eee eee ene ee eeeee 205 Class storing the variables and domaines used by GenerelizedLookahed Removed Vales td ads 207 Class for keeping track of which variable removed which values from the domain of this variable This is used under resetting the variable s domain when backtracking so that we are sure we only reset the domain to the values removed by the 194 CHAPTER 7 CASPER API REFERENCE 7 2 1 Classes CLASS Consistent CaSPers default implementation of the Consistent interface DECLARATION public class Consistent Object CONSTRUCTORS e Constructor public Consistent Initializes a new instance of the ConsistentI
100. n search thread Parameters 262 CHAPTER 8 GUI API REFERENCE x guild The GUI variable ID for chosen variable domainVal The chosen domain value e Write CPToXml public void WriteCPToXml Writes a xml file Writes the CP text to XML Parameters x fileName Name of the file x text The CP text e WriteTextFile public void WriteTextFile Writes a text file Parameters x fileName Name of the file text The text Bibliography 263
101. nalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone 7 1 NAMESPACE CASPER 191 protected object MemberwiseClone Creates a shallow copy of the current e SetVariableOrdering public void SetVariableOrdering Parameters x varorder e ValidDomains public System Collections Generic List Casper Data CasperVarDom Valid Domains This method runs the forward checking algorithm in the GeneralizedLookahead class If the data field omitTestOnSIgnleDomains is set to true one valued domain variables are jumped over e ValidDomainsUserChoice public System Collections Generic List Casper Data CasperVarDom Valid DomainsUserChoice Parameters Var x domainVal 192 CHAPTER 7 CASPER API REFERENCE CLASS StaticData A class for Caspers static data DECLARATION public class StaticData Object METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e GetHashCode public int GetHashCode Serves as a hash functio
102. nd domain values If the algorithms needs special structures these can easily be build from this representation The expression and constraint graph representa tions are described in detail later The library is designed not to be dependent of a specific algorithm Therefore the algorithmic part is loosely connected to the data representation part of the library This is done to allow other algorithms to be added using the same basic data and to allow the usage of the implemented algorithm without using all the other parts of the library The current implementation contains Generalized Look Ahead with Select Value Forward Checking 19 20 CHAPTER 3 CASPER 3 1 1 Main Interface class of CaSPer The CSP class is the main class of the CaSPer library Variables and domain data expres sions and optionally the constraint graph is the basic data needed for setting up the library for solving a problem The class has to main methods one for calculation of the problems valid domains and one for reducing the problem with an user selected value When an error occurs the CSP class throws a CasperException with an error message This exception has to be handled by the user application Main public methods Casper CSP CSPExpressions expressions List lt CasperVarDom gt casperVarDoms This is one of the constructors of CSP It carries out the following operations e Initializing the class with the input data e Making a ma
103. ng public string ToString Returns a System String that represents the current Casper Data CSPExprValuelnt 240 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprVar An abstract class for representing the variable kind of expressions Extends the abstract CSP Expr class DECLARATION public class CSPExprVar CSPExpr PROPERTIES e VarID public int VarID get set Gets or sets the variable ID CONSTRUCTORS e Constructor public CSPExprVar Initializes a new instance of the CSPExprVar class Parameters x varlID The var ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 241 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExpr 242 CHAPTER 7 CASPER API REFERENCE
104. ng of cp variables to BDD variables DECLARATION public class BDDSpace Object PROPERTIES e LayoutBdd public buddy sharp Bdd LayoutBdd get Gets the BDD representation of the CSP problem before the expressions is compiled 1n e UnsatisfiableRule public string UnsatisfiableRule get Gets the unsatisfiable rule if one exist CONSTRUCTORS e Constructor public BDDSpace Initializes a new instance of the BDDSpace class Parameters cp The CP instance of the problem layout The BDDLayout instance of the problem symbols The CLab Data Symbols instance of the problem clabBdd The ClabBDD instance of the problem E E E 56 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Abs public System Collections Generic List buddy_sharp Bdd Abs Calculates the absolute value of a 2 complementary BDD representation Parameters x The 2 complementary BDD representation e Add public System Collections Generic List buddy sharp Bdd Add Calculates the result of the Add operation between two 2 complementary BDD rep resentations Parameters x A 2 complementary BDD representation y Another 2 complementary BDD representatino e Bool2Integer public System Collections Generic List buddy_sharp Bdd Bool2Integer Converts the specified BDD x to a 2 complementary BDD representation Parameters x The BDD e
105. ng representation of a domain value Parameters domainString The string representation of a domain value e GetStringRepOfDomainInt public string GetStringRepOfDomainInt _ Gets the string representation of an int within the range 112 CHAPTER 6 CLAB 1 0 API REFERENCE Parameters x domainlInt The domain int e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab CSP CSPTypeRange e TypeFormat public CLab CPTypes TypeFormat Returns the CPTypes range type constant 6 4 Namespace CLab Data Namespace Contents Page Interfaces Classes A A cease eT de Gethin ie GE A Ga eh tes Te A Wit es Oe oa 114 The CP object contains the internal data representation parsed from the input XML file Expressions ieena A dd AR Rae 118 Abstract class for the different types of Expressions 6 4 NAMESPACE CLAB DATA 113 Expression BID 0005 RARA FAA EE RNA RRR ES 121 An expression consisting of a left and right side and an operator Imple ments the abstract Expression class Expressionld RAR ARA ARA A ESAS 124 An expression consisting of a single id element Implements the abstract expression class Expressionint 0 AA SARA ART A 127 Expression consisting of an integer Implements the
106. o free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetIntRepOfDomainString public int GetIntRepOfDomainString Gets the int representation of the string representation of a domain value Has to be implemented by classes implmementing this abstract class Parameters domainString The string representation of a domain value e GetStringRepOfDomainInt public string GetStringRepOfDomainInt Gets the string representation of an int within the range of a type Has to be imple mented by classes implmementing this abstract class Parameters 6 3 NAMESPACE CLAB CSP 103 x domaintInt An integer representing a domain value GetType public System Type GetType Gets the of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Returns a System String that represents the current CLab CSP CSPType TypeFormat public CLab CPTypes TypeFormat Returns a constant from the CPTypes enumeration representing the current type 104 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS CSPTypeBool A class for representing boolean types in the CSP part of CLab The differen
107. o the list e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 48 CHAPTER 6 CLAB 1 0 API REFERENCE 6 2 Namespace CLab BDD Namespace Contents Page Interfaces Classes BODCOMpPAL 0000 AR dS Poh A eed oa ge eS 50 An System Collections Generic IComparer implementation when sorting a list of BDDs based on their node count BDDLayo t ui eek oe oe Pe he aA La Sed eh AAA AAA RA A 52 Class representing and making the layout of the BDD problem The class has mapping from the CLab Data CP representation to the BDD repre sentation and vice versa BDDSpaCe 32 025 otc ooh SO Oe OE Os SR OS 55 Class for making BDDs based on the types variables and expressions of a CP problem Uses the BDDLayout mapping of cp variables to BDD variables BED By A eg A ws od I Ra ee 62 Abstract class representing variable types Used by CLab BDD Layout BD
108. of the problem 6 3 NAMESPACE CLAB CSP 89 METHODS e AddExtraRule public void AddExtraRule Adds an extra rule to the problem Does not run a search for valid solutions this has to be done to get the reduced valid domaines after adding the new expression Parameters newExpr The new expression e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance 90 CHAPTER 6 CLAB 1 0 API REFERENCE e GetValidDomains public CLab ValidDomains GetValidDomains Updates the CLab ValidDomains instance with the domain information from the current Casper CSP object Before a search is run all domain values are possible and returned e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ObserveStatusChanged public void ObserveStatusChanged Observes the status for changes and updates the current CLab Clab instance Parameters x currentlyRunVar The currently r
109. on of the frames on the call stack at the time the current exception was thrown e TargetSite public System Reflection MethodBase TargetSite get Gets the method that throws the current exception CONSTRUCTORS e Constructor public ClabInvalidExpressionException Initializes a new instance of the ClabInvalidExpressionException class Parameters expressionType Type of the expression textValue The text value e Constructor public ClabInvalidExpressionException Initializes a new instance of the ClabInvalidExpressionException class Parameters expressionType Type of the expression x integerValue The integer value 156 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetObjectData public void GetObjectData When overridden in a der
110. ossible solutions When an error occurs Clab throws a ClabExcept ion with an error message This exception has to be handled by the user application Main public methods Clab Clab string fileName This is one of the constructors of Clab It carries out the following operation 2 1 OVERVIEW 5 e Parsing and type checking the CP problem XML file given in XMLFileName Clab Clab Stream XMLStream This is one of the constructors of Clab It carries out the following operation e Parsing and type checking the CP problem XML file given as the stream XMLSt ream ValidDomains Clab InitializeProblemSolver CLabModus modus Initializes the problem solver for the specified modus Returns all domain values in the configuration problem The argument modus defines which problem solver to use There are two options Method Description bddmodus Use BDDs to solve the problem csp modus Use CSP algorithms to solve the problem ValidDomains Clab GetValidDomains Calculates the valid domains according to the rules of the problem and any rules added later in the process Returns the valid domains ValidDomains Clab GetValidDomainsExtraRule String variable String selectedDomain Calculates the valid domains with the extended or new partial configuration Returns the remaining valid domains ValidDomains Clab GetValidDomainsExtraRule Expression expr 6 CHAPTER 2 CLAB Calculates t
111. other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprNot 234 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprValue An abstract class for representing the value kind of expressions Extends the abstract CSPExpr class DECLARATION public class CSPExprValue CSPExpr PROPERTIES e Value public int Value get set Gets or sets the value CONSTRUCTORS e Constructor public CSPExprValue Initializes a new instance of the CSPExprValue class Parameters x value The value METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 235 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is
112. parsing TokenParserExceptiom iS hoe be te CASO ee ee 166 Exception for error handling during token parsing 146 CHAPTER 6 CLAB 1 0 API REFERENCE 6 5 1 Classes CLASS ClabException ClabException is a generic exception class used for separating exceptions which we throw and system exceptions Looping through the inner exceptions should reflect the entire stack of messages and what lead to the exception DECLARATION public class ClabException Exception PROPERTIES e Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception e HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception e HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion e InnerException public System Exception InnerException get Gets the instance that caused the current exception 6 5 NAMESPACE CLAB EXCEPTIONS 147 e Message public string Message get Gets a message that describes the current exception e Source public string Source get set Gets or sets the name of the application or the object that causes the error e StackTrace public string StackTrace get Gets a string representation of the frames on the call stack at the time the current
113. pe is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current ValidAssignmentData 6 3 Namespace CLab CSP Namespace Contents Page Interfaces Classes CRBCSP nt a a a Riad dde dio ns 88 The main class for finding valid solutions with the CSP approach The class is designed to be used by CLab Clab which provides the data needed for this class to work CSPExpressionBuilder ooooooooooonccccnccccccrr or 92 Class for making Casper s CSP representation of the expressions Casper Data CSPExpr E O O IS 96 6 3 NAMESPACE CLAB CSP 87 Class representing and making the layout of the CSP problem The class has mapping from the CLab CLab Data CP representation to the CSP representation and vice versa CSP pent tt dtu tee dos a Meciiatentencedtadts 101 An abstract class used by classes representing types in the CSP part of CLab The different possible values like strings for the enumeration type or integers for the range type are all encoded as ranges All of the types must have an end point CSP TypeBool no te a o 104 A class for representing boolean types in the CSP part of CLab The differen
114. played in Figure 4 1 ee S Vv o Figure 4 1 The autocompletion of delimiter characters The final menu option is the Help menu which Problem Editor The Problem Editor is an editor for the configuration files used by CLab and can open save both plain text CP files and XML files A screenshot of the editor can be seen in Figure 4 2 te CLab Configurator Ve Description CLab 1 0 Example CLab Crew 2006 08 16 userType Visitor Employee paperType A3 A4 A5 printerType Simple Advanced inkType Color Black variable userType User printerType Printer inkType Ink paperType Papersize rule Printer Simple gt gt Papersize A3 Printer Simple gt gt Ink Black Papersize A3 gt gt Ink Black User Visitor gt gt Printer Simple Figure 4 2 The Problem Editor The editor have built in syntax highlighting for comments and the strings type variable rule and bool which all are used for own purposes in the configuration file In addition 4 1 OVERVIEW 29 it provides an option for autocompletion of the delimiter characters shown in Figure 4 1 Be aware though that the implementation of the syntax highlighting has broken support for undo redo so the editor does not have any integrated support for these actions This is due to parsing of the editing line when inserting text and this is registered by the undo service in CF Set pa
115. pping from variable ID to internal index for all variables in casperVarDoms Casper CSP CSPExpressions expressions This is one of the constructors of CSP If this constructor is used variables and domain data has to be added afterwards before using any search functionality It carries out the following operation e Initializing the class with the input data Casper CSP 3 1 OVERVIEW 21 This is one of the constructors of CSP If this empty constructor is used both variables and domain data and expressions have do be added afterwards before using the search functionality ConstraintGraph Casper ConstraintGraph Set Get property This property allows setting or getting the optional constraint graph The constraint graph is needed for certain variable orderings like minimum width ordering void Casper SetVariableOrdering CspVariableOrdering varorder Sets the variable ordering used by the searching algorithm The argument varorder de fines which variable ordering to use There are two options Method Description vo_static Iterate through the variables according to their variable index vo minwidth Iterate through the variables according to their adjacency lists Variable with the largest list is chosen first Default variable ordering 1s static CSPExpressions Casper Expressions Set Get property This property allows setting or getting the expressions data Boolean Casper OmitTestOnSingleVa
116. rameters constant The constant Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetIntRepOfDomainString public int GetIntRepOfDomainString Gets the int representation of the string representation of a domain value Uses the internal mapping from string to int Parameters domainString The string representation of a domain value 6 3 NAMESPACE CLAB CSP 109 e GetStringRepOfDomainInt public string GetStringRepOfDomainInt _ Gets the string representation of an int within the range of a type Uses the internal mapping from int to string Parameters x domaintInt An integer representing an enumeration domain value con stant e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current CLab CSP CSPTypeEnum e TypeFormat public CLab CPTypes TypeFormat Returns the CPTypes
117. rameters The Set Parameters tab let users assign values to variables in the config uration file during execution A screenshot of this tab can be seen in Figure 4 3 te CLab Configurator File Edit Run Settings Help gt unK Problem Editor Set parameters Visitor Simple Black AAA AAA NAAA AAA Run time 00 00 00 070101 Figure 4 3 The Set Parameters tab As we can see from the screenshot this interface provides drop down lists for each variable in the configuration The list contains all values in the domain although some have symbols denoting the availability of them The symbols follows the structure presented in Table 4 1 At current state CLab does not support backtracking during configuration This means that as soon as a value is chosen for a variable then it cannot be changed to another value without restarting the configuration 30 CHAPTER 4 CLAB CONFIGURATOR Symbol Description Green The value is chosen by the user Blue The value is chosen by CLab since it is the only available value in the domain Grey Values not chosen for a variable when another value is chosen Red with white X Unavailable due to the current constraints None Value is available Table 4 1 Symbol structure for the Set Parameter tab in CLab Configurator Error messages CLab Configurator provides a common interface for all error messages displayed All exceptions which occur within CLab are caugh
118. rator to a Casper operator Casper StaticData Operators Parameters input The input Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table 6 3 NAMESPACE CLAB CSP e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 95 96 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS CSPLayout Class representing and making the layout of the CSP problem The class has mapping from the CLab CLab Data CP representation to the CSP representation and vice versa DECLARATION public class CSPLayout Object PROPERTIES e CpVarToVarID public System Collections Hashtable CpVarToVarID get Gets the CLab Data Variable VariableName property to the Casper Data CasperVarDom VarID property mapping e TypeNameTolndex public System Collections Hashtable TypeNameToIndex get Gets the CLab Data Variable TypeName property to the index of this type mapping e Types
119. rding to that Since they are all enclosed in a ClabException a client application is only required to catch this exception type for error handling If the client application requires different measures taken for different types of error it is trivial to collect the inner exceptions and act upon them The message property of the ClabException object contains the error message from the underlying exception so it is strictly not needed to go in the inner exceptions All the custom exception classes in CLab are located in the Clab Exceptions namespace Chapter 3 CaSPer 3 1 Overview CaSPer is a library for solving CSP problems using CSP algorithms Currently only one algorithm is implemented but the library is designed to easily support other algorithms The library consists primary of two parts The first part is the general data representation part of a CSP problem while the other is the algorithmic part The data is represented as variables with domain data as CasperVarDom objects and expressions as CSPExpr objects Another optional data type is the constraint graph represented as a ConstraintGraph object with multiple AdjacencyList objects inside The CasperVarDom class is designed to be small and easy with a variable ID and a list of ints representing the domain values The variables should be encoded with subse quent int values as IDs starting from 0 This design should make it possible to encode any kinds of variables a
120. representing the value kind of expressions Extends the abstract CSPExpr class CSPRxprValneC onst 20 Li A a dd OS 236 Implementation class for the constant type of value expressions Implements the abstract CSPExprValue class CSPExpr Valuclt iia 238 Implementation class for the integer type of value expressions Implements the abstract CSPExprValue class ESPESPEV E A ae fee oe te aa ta cas 240 An abstract class for representing the variable kind of expressions Extends the abstract CSPExpr class ESPEXpPEVSEBOOL 9 his a AA alete doles AA A eee 242 Implementation class for the boolean variable type of variable expressions Implements the abstract CSPExprVar class ESPEXPEV ALETAS ses ds ow ee OF Oe ed aa asin Sa act 244 Implementation class for the enumeration variable type of variable expres sions Implements the abstract CSPExprVar class CSPE XE Vart A le alg nace al ete ok oy la Sd a a et 246 Implementation class for the integer variable type of variable expressions Implements the CSPExprVar abstract class CSPExprWrapper ed 248 Stores wrapped expression objects along with a set of its variables IDs Used during consistency to filter out expressions which have variables which isn t set yet 216 CHAPTER 7 CASPER API REFERENCE 7 4 1 Classes CLASS Adjacency List A class representing a list of adjacent nodes in a Constraint Graph DECLARATION public class AdjacencyList Object PROPERTIES e V
121. ressionBinary Initializes a new instance of the ExpressionBinary class Parameters left The left expression type The operator right The right expression 122 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e RunCSPBuildExpr assembly Casper Data CSPExpr RunCSPBuildExpr Abstract method which runs CSPBuildExpr in CLab CSP CSPExpressionBuilder Dou ble dispatch pattern 6 4 NAMESPACE CLAB DATA 123 Parameters builder The CSPExpressionBuilder e ToString public string ToString Returns a textual description of the expression e Type2oper public string Type2oper Converts the type to an operator sign for printout Parameters type 124 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ExpressionId An expression consisting of a single id element
122. riable ordering e SetStatusUpdateCount assembly void SetStatusUpdateCount Sets the status update count which is the maximum number of status updates for a specific search Can be used to set the maximum value of a progress bar Parameters suc The suc 40 CHAPTER 6 CLAB 1 0 API REFERENCE e StatusUpdateCount public int StatusUpdateCount Method which return the maximal number of calls to the status event for a search depending on which modus is chosen Can be used to set the max value of a progress bar UpdateStatus assembly void UpdateStatus _ Updates the status of the currently checked value Parameters value The currently checked value VariableCount public int VariableCount Returns the number of variables 6 1 NAMESPACE CLAB 4 CLASS Common Defines common enum types and constant values used within CLab DECLARATION public class Common Object FIELDS e BDDINITDBCACHE public int BDDINITDBCACHE The initial cache used by BDD e BDDMAXINCREASE public int BDDMAXINCREASE The max increase of BDD e INITBDDNODES public int INITBDDNODES Number of initial BDD nodes METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 42 CHAPTER 6 CLAB 1 0 API REFERENCE e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suita
123. ring a search This may be useful when you need the computer for something else since a search takes up as much of the CPU resources as it can The third party BDD package we use for solving the configuration problems with BDDs Buddy_sharp crashes if it is run more than once without restarting the GUI This is because Buddy_sharp is not thread safe We have chosen not to deal with this issue for Making Windows Forms thread safe http www codeproject com csharp threadsafeforms asp 4 2 THREADS 31 multiple reasons If we run the search and GUI in the same thread the issue is solved but that leaves us in many cases with a solution which seems not to respond We think of this solution as worse since even if it crashes when the problem is run from scratch it is possible to run one complete configuration with BDDs It should be possible to make Buddy_sharp thread safe and solve the issue completely though this is not a part of this thesis 32 CHAPTER 4 CLAB CONFIGURATOR Chapter 5 Third party requirements The development of CLab and CaSPer have been facilitated with some third party con tributions We have made sure that none of the contributions have licenses which conflicts with CLab or each other and are free to use For solving configuration problems using BDDs we are using the BuDDy package implemented by J Lind Nielsen in C and the Buddy_sharp C wrapper for BuDDy implemented by Rune M ller Jensen and
124. rotected object MemberwiseClone Creates a shallow copy of the current 140 CHAPTER 6 CLAB 1 0 API REFERENCE e ToString public string ToString Returns the names of the type and its valid states 6 4 NAMESPACE CLAB DATA 141 CLASS TypeRange The Type class represents a CLab type TypeRange represents a range type Implements the abstract Type class DECLARATION public class TypeRange Type PROPERTIES e EndOfRange public int EndOfRange get set Gets or sets the integer value of the end of the range e StartOfRange public int StartOfRange get set Gets or sets the integer value of the start of the range e TypeName public string TypeName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public TypeRange Initializes a new instance of the TypeRange class Parameters typeName Name of the type startOfRange The start of the range endOfRange The end of the range 142 CHAPTER 6 CLAB 1 0 API REFERENCE METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a par
125. s e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters 6 5 NAMESPACE CLAB EXCEPTIONS 165 info context e GetType public System Type GetType Gets the runtime type of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 166 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS TokenParserException Exception for error handling during token parsing DECLARATION public class TokenParserException Exception PROPERTIES Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion InnerException public System Exception InnerException get Gets the instance that caused the current exception Messag
126. s level is in the Clab Data namespace At the next level we have the two different solving approaches For the BDD approach we have the namespace Clab BDD and for CSP the namespace Clab CSP Both namespaces has classes with the special data representations they need derived from the general data representation Both namespaces have a main interface class which ties the functionality of each approach together and offer methods for usage by the main interface class Clab Clab again hides how two approaches work for the user by offering the methods needed for making an end user application for running product configuration When we perform a configuration problem with CLab an initial calculation of valid domains is calculated This returns a list of variables and their valid domain values in the same representation as in the problem definition Now the user can select one of the valid 4 CHAPTER 2 CLAB domain values and in that way make a partial configuration knowing that the selected domain value leads to a full valid configuration Then a new calculation of valid domains is run which might lead to further reductions of the valid domains For instance might a domain for a certain variable be reduced to contain only one value and the partial configu ration is extended The user is for each iteration presented with fewer values to select from Eventually there is only one solution left and the problem is solved 2 1 1 Main interfa
127. s represents a CLab type CSPTypeEnum represents an enumeration type with a list of valid states domain Implements the abstract Type class DECLARATION public class TypeEnum Type PROPERTIES e EnumeratorsList public System Collections Generic List System String EnumeratorsList get Gets the list of valid states for the type e GetDomain public string GetDomain get Gets a string representation of the valid states for the type in the form value1 value2 value3 valueN e TypeName public string TypeName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public TypeEnum Initializes a new instance of the TypeEnum class Parameters 6 4 NAMESPACE CLAB DATA 139 typeName Name of the type x enumeratorsList List of valid states for the type METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone p
128. s the width of the variable 7 4 NAMESPACE CASPER DATA 219 CLASS CasperVarDom A class with variable and domain information used by the Csp class DECLARATION public class CasperVarDom Object PROPERTIES e DomainValues public System Collections Generic List System Int32 DomainValues get set Gets or sets the domain values e ValidValues public lIesi Collections Set ValidValues get set Gets or sets the valid values e VarID public int VarID get set Gets or sets the variable ID CONSTRUCTORS e Constructor public CasperVarDom Initializes a new instance of the CasperVarDom class Parameters x varlID The variable ID domainValues The domain values 220 CHAPTER 7 CASPER API REFERENCE e Constructor public CasperVarDom Initializes a new instance of the CasperVarDom class Parameters x varlID The variable ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public Syst
129. ser 2The grammar is the same as in CLab 1 0 with the addition to the identifier so that strings enclosed with the character and identifiers which starts with a number is accepted 18 CHAPTER 2 CLAB MemoryStream CPtoXML string input Parses the input string and returns a stream with the XML representation of the input data It carries out the following operations e Creates a new stream to write the XML data to Checking to see if the input contains header data This must be handled outside of the TokenParser since the latter ignores commented lines If header data is found proper header elements are created in the XML stream Sends the input data to the TokenParser with the stream as an argument e After the TokenParser is done the stream is returned 2 4 Error handling To facilitate an easy error handling CLab throws a single expression type ClabException There are some other expression types defined and used internally e C ab nternalErrorException e C ab nvalidExpressionException e C LabSymbolException e C abXMLParserException e TokenParserException Currently the different exceptions are handled the same way they are all enclosed in an exception object of type ClabException including all system exceptions The reason for separating the different exceptions is to be able to know exactly what part of CLab failed and to be able to act differently acco
130. shows the recursive expression structure of CaSPer Figure 3 2 shows how the different expressions for each rule is represented Each ex pression is placed inside a CSPExprWrapper class which also consists of a set of all the variable IDs within the expression This set is used to determine whether an expression should be checked by the consistency method for a certain assignment of variables The Expressions class keeps track of all these classes 3 1 3 Status messages CaSPer supports status events and this function is used to tell CLab when it should up date its status All event handler functions which have been added to the status event 24 CHAPTER 3 CASPER CSPExpressions List lt CSPExprWrapper gt Expressions CSPExpr Wrapper CSPExpr Expr Set VariablesInExpr CSPExpr abstract Figure 3 2 The figure shows how the expressions for all the rules are represented StatusEvent is called with an int value representing the currently run operation when an event occurs The StatusUpdateCount method can be used to find out how many updates can be expected for a search A delegate is used as an event handler and defines the interface for the event handler function which can be added The delegate is called StatusEventHandler The status event is updated each time the search is started for a new variable in the ValidDomains or the ValidDomainsUserChoice meth ods The status event delegate d
131. sources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetNextValue public System Nullable System Int32 GetNextValue 204 CHAPTER 7 CASPER API REFERENCE Parameters x StartFromBeginning e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ResetDomain public void ResetDomain Method used by the algorithm to reset the domain during backtracking Parameters removedVals The removed values which should be reset UpdateDomainWithRemoved public void UpdateDomainWithRemoved Updates the domain with removed values in the removed set The removed set is emptied 7 2 NAMESPACE CASPER ALGORITHM 205 CLASS Lookahead Variables Class storing the variables and domaines used by GenerelizedLookahed DECLARATION public class Lookahead Variables Object PROPERTIES e VarDoms public System Collections Hashtable VarDoms get set Gets or sets the variables and domaines e VarOrder public Casper Algorithm VariableOrdering IVariableOrdering VarOrder get set Gets or sets the variable ordering CONSTRUCTORS e Cons
132. sper Code Example 2 224 434 6486 24 8 444545 244 CLab Configurator Ali OVEIVIEW AAA AL PICAS inte A A A A IAS A en a ES Third party requirements CLab 1 0 API Reference 6 1 Namespace CLab 220 birra bancada OlT CIASSES A e A A A AE DA 6 2 Namespace CLab BDD o 6 2 1 Classes 25 do Bold A A AAA 6 3 Namespace CLab CSP OIl A A BAe Sie Dee Baer Pe Bre 6 4 Namespace CLab Data 0 0 0 2 0 0 00002 eee 6 4 1 Classes ay causada bea e a Sak a 6 5 Namespace CLab Exceptions 2005 Goel EIA 6 6 Namespace CLab Parsers 0 0 0 000000 ee eee 6 61 Classes ais altos Ue Gel Dae SG A le ea a 6 7 Namespace com calitha goldparser 6 74 AIASSES ls tt A ine RA AS e CaSPer API Reference TL Namespace Casper acarrea lcd E 1 SA ON 7 2 Namespace Casper Algorithm E E A RA A EE GE Os DE ae oe 7 3 Namespace Casper Algorithm VariableOrdering 1v 27 27 30 33 35 35 36 48 50 86 88 112 114 144 146 169 170 174 175 FSM A Maven Beit Weve Bee 3 les Sexe 210 few ae ESE a a at E 210 7 4 Namespace Casper Data 214 TAT A AA IN Te aie Nee ee 216 7 5 Namespace Casper Exceptions 249 TIA ASS e el ds a 251 8 GUI API Reference 255 8 1 Namespace ClabGUi 255 8 1 1 Classes e lii it IO AR AN Neate ye Bla
133. stract classes where the top one is the common class representing all others There are own implementation classes for the following expres sions e Integer values which should use the CSPExprValuelInt class e Enumeration constants which should use the CSPExprValueConst class e Boolean variables which should use the CSPExprVarBool class 3 1 OVERVIEW 23 e Enumeration variables which should use the CSPExprVarEnunm class e Integer variables which should use the CSPExprVarlInt class Negated CSPExpr objects which should use the CSPExprNeg class Inverted CSPExpr objects which should use the CSPExprNot class e CSPExpr objects with an operator which should use the CSPExprBin class Each implementation class uses the double dispatch pattern towards the consistent im plementation This way each expression type has its own special method and we avoids type testing CSPExpr abstract A CSPExpr Value CSPExprNeg CSPExprNot CSPExpr Var CSPExprBin abstract CSPExpr left CSPExpr left abstract CSPExpr left ConsistentCheck ConsistentCheck CSPExpr right A Expression Expression A Operators oper ConsistentCheck Expression CSPExprValuelnt CSPExpr ValueConst CSPExprVarBool CSPExprVarEnum CSPExprVarInt AA EE Y VEA ee AE ConsistentCheck ConsistentCheck ConsistentCheck ConsistentCheck ConsistentCheck Expression Expression Expression Expression Expression Figure 3 1 The figure
134. suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns a System String that represents the current Casper Data CSPExprValue 236 CHAPTER 7 CASPER API REFERENCE CLASS CSPExprValueConst Implementation class for the constant type of value expressions Implements the abstract CSP ExprValue class DECLARATION public class CSPExprValueConst CSPExprValue PROPERTIES e Value public int Value get set Gets or sets the value CONSTRUCTORS e Constructor public CSPExprValueConst _ Initializes a new instance of the CSPExprValueConst class Parameters x constantlD The constant ID METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj 7 4 NAMESPACE CASPER DATA 237 e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType
135. t possible domain values for a range are encoded as a range with an end point The start point is assumed always to be 0 Implements the abstract CSPType class ESP Ea a e S 107 A class for representing enumeration types in the CSP part of CLab The different possible domain values for an enumeration are encoded as a range with an end point The start point is assumed always to be 0 Implements the abstract CSPType class CSP TypeRa ge unda i E sel a ERA REEE NE a a 110 A class for representing range types in the CSP part of CLab The different possible domain values for a range are encoded as a range with a start point and an end point Implements the abstract CSPType class 88 CHAPTER 6 CLAB 1 0 API REFERENCE 6 3 1 Classes CLASS ClabCSP The main class for finding valid solutions with the CSP approach The class is designed to be used by CLab Clab which provides the data needed for this class to work DECLARATION public class ClabCSP Object PROPERTIES e Csp public Casper Csp Csp get Gets the Casper CSP object of the problem e Layout public CLab CSP CSPLayout Layout get Gets the CSPLayout of the problem CONSTRUCTORS e Constructor public CIabCSP Initializes a new instance of the ClabCSP class Parameters clab The CLab Clab object cp The CLab Data CP object of the problem x symbols The CLab Data Symbols object
136. t and displayed in the GUI There is one exception which gets a special treatment when it comes to being presented and that is an exception which occurs while saving a configuration file If the contents of the editor differs from the defined language then an error will be displayed telling what is wrong and give the user an option to move the cursor to the location of the error 4 2 Threads Since a search might take some time to carry through the search is run in its own thread If this is not done the GUI would seem not to response The search thread updates the GUI when it is finished with a search Since Windows Forms is not thread safe it is not allowed to get or set any property on a Windows Forms Control from another thread than the thread which handles the message queue The GUI thread To deal with this problem we use the InvokeRequired property If this property returns t rue we make a call to the Invoke method which can enqueue a delegate with the data needed to update the GUI The delegate is enqueued into the message queue of the GUI control we want to update and run by the GUI thread Therefore the MainGUI class has a method for each kind of update which is run from another thread We have also defined delegates for different kinds of input to support the methods and their input data By running the search in its own thread we get a more responsive GUI We have also taken the advantage to make it possible to pause the search du
137. t possible domain values for a range are encoded as a range with an end point The start point is assumed always to be 0 Implements the abstract CSPType class DECLARATION public class CSPTypeBool CSPType PROPERTIES e End public int End get set Gets or sets the end of the range e TypeName public string TypeName get set Gets or sets the name of the type CONSTRUCTORS e Constructor public CSPTypeBool Initializes a new instance of the CSPTypeBoo class Parameters typeName Name of the type METHODS 6 3 NAMESPACE CLAB CSP 105 e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetIntRepOfDomainString public int GetIntRepOfDomainString Gets the int representation of the string representation of a domain value Parameters domainString The string representation of a domain value e GetStringRepOfDomainInt public string GetStringRepOfDomainInt Gets the string representation of an int within the range of a type Parameters
138. tance of the CasperException class Parameters 7 5 NAMESPACE CASPER EXCEPTIONS 253 message The exception message which describes the reason for the exception inner The inner exception METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception 254 CHAPTER 7 CASPER API REFERENCE Parameters info context e GetType public System Type GetType Gets the runtime type of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception Chapter 8 GUI API Reference 8 1 Namespace ClabGui Namespace Contents Page
139. text GetType public System Type GetType Gets the runtime type of the current instance MemberwiseClone protected object MemberwiseClone 6 5 NAMESPACE CLAB EXCEPTIONS 161 Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 162 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS ClabXMLParserException Custom exception class used for errors during XML parsing ClabXmlParser throws this excep tion as a result when any one of these exceptions are caught in the parser XmlExceptionXmlSchemaVal idationExceptionSystem IO FileNotFoundExceptionInvalidOperationExceptionClabInvalidExpressionException DECLARATION notpublic class ClabXML ParserException Exception PROPERTIES e Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception e HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception e HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion e InnerException public System Exception InnerException get Gets the instance that caused the current exception e Message 6 5 NAMESPACE CLAB EXCEPTIONS 163 public string Message get Gets a messag
140. ticular type is suitable for use in hashing algo rithms and data structures like a hash table e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Returns the name of the type and its range 6 4 NAMESPACE CLAB DATA 143 CLASS Variable The Variable class represents a CLab variable In addition to the types set by Type objects CLab has an internal boolean type named bool DECLARATION public class Variable Object PROPERTIES e TypeName public string TypeName get set Gets or sets the name of the variable type e VariableName public string VariableName get set Gets or sets the name of the variable CONSTRUCTORS e Constructor public Variable Initializes a new instance of the Variable class Parameters typeName Name of the type to use for this variable variableName Name of the variable METHODS e Equals 144 CHAPTER 6 CLAB 1 0 API REFERENCE public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetHashCode public int GetHashCode Serves as a hash function for
141. tructor public LookaheadVariables _ Initializes a new instance of the LookaheadVariables class Parameters varOrderType The variable ordering cGraph The constraint graph METHODS 206 CHAPTER 7 CASPER API REFERENCE Equals public bool Equals Determines whether the specified is equal to the current Parameters obj Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetType public System Type GetType Gets the of the current instance GetVar public Casper Algorithm LookAheadVarDom GetVar _ Gets the variable which belongs to number in queue Parameters x numberInQueue The number in queue MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 7 2 NAMESPACE CASPER ALGORITHM CLASS Removed Values 207 Class for keeping track of which variable removed which values from the domain of this vari able This is used under resetting the variable s domain when backtracking so that we are sure we only reset the domain to the values removed by the DECLARATION public class RemovedValues Object PROPERTIES e R
142. ts up the XML validation service which validates the input data against the XML schema defined in CLab void Parse Stream stream Parses the specified stream It carries out the following operation e Sets up a new reader object which parses XML input from the specified stream void Parse String XMLUr1 Parses the specified XML file It carries out the following operation e Sets up a new reader object which parses XML input from the specified file location The Parse methods call the internal method RunParse which is the main parse method When it hit start elements attributes are stored and records to keep track of where the parser is in the document structure are updated Most of the data injection is done when the parser hit a corresponding end element It checks to see what type of element it is and the action taken depends on that and its content Since the traversal of the document structure is done from the top to bottom we cannot inject data before we hit an end element To facilitate that we store the data in stacks until it is time to store it to the CP object The ClabXMLParser throws and ClabXMLParserException when it encounters an error 2 3 PARSING 17 2 3 2 TokenParser The token based parser used for parsing plain CP text to XML is implemented with the use of the free GOLD Parsing System GOLD uses the LALR algorithm to analyze syntax and a Deterministic Finite Automaton to identify different class
143. ublic RuleException Initializes a new instance of the RuleException class Parameters message The exception message which describes the reason for the exception e Constructor public RuleException Initializes a new instance of the RuleException class Parameters 6 7 NAMESPACE COM CALITHA GOLDPARSER 177 message The exception message which describes the reason for the exception inner The inner exception e Constructor protected RuleException Initializes a new instance of the RuleException class Parameters x info The System Runtime Serialization SerializationInfo that holds the serialized object data about the exception being thrown x context The System Runtime Serialization StreamingContext that con tains contextual information about the source or destination METHODS e Equals public bool Equals Determines whether the specified is equal to the current Parameters obj e Finalize protected void Finalize Allows an to attempt to free resources and perform other cleanup operations before the is reclaimed by garbage collection e GetBaseException public System Exception GetBaseException When overridden in a derived class returns the that is the root cause of one or more subsequent exceptions 178 CHAPTER 6 CLAB 1 0 API REFERENCE e GetHashCode public int GetHashCode Serves as a hash f
144. un var RunCSPSearch public void RunCSPSearch _ Runs the CSP search with the expressions defined and return the valid domaines for the problem RunCSPSearchUserChoice public void RunCSPSearchUserChoice _ Runs the CSP search reduced with a user chosen domain value for a variable Returns the valid domaines for the problem after this reduction Parameters x var The chosen variable x domVal The chosen domain value 6 3 NAMESPACE CLAB CSP e SetVariableOrdering public void SetVariableOrdering Sets the variable ordering Parameters variableOrder The variable ordering 91 92 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS CSPExpressionBuilder Class for making Casper s CSP representation of the expressions Casper Data CSPExpr DECLARATION public class CSPExpressionBuilder Object PROPERTIES e ConstraintGraph assembly Casper Data ConstraintGraph ConstraintGraph get Gets the constraint graph e CSPExpressions public Casper Data CSPExpressions CSPExpressions get Gets the CSP expressions CONSTRUCTORS e Constructor public CSPExpressionBuilder Initializes a new instance of the CSPExpressionBuilder class Parameters x layout The Casper CSP layout cp The CLab Data CP instance of this problem x symbols The CLab Data Symbols instance for this problem METHODS 6 3 NAMESPACE CLAB CSP 93
145. unction for a particular type is suitable for use in hashing algo rithms and data structures like a hash table GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters info context GetType public System Type GetType Gets the runtime type of the current instance MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current ToString public string ToString Creates and returns a string representation of the current exception 6 7 NAMESPACE COM CALITHA GOLDPARSER 179 CLASS SymbolException Internal exception class used by the parser engine DECLARATION public class SymbolException Exception PROPERTIES e Data public System Collections IDictionary Data get Gets a collection of key value pairs that provide additional user defined information about the exception e HelpLink public string HelpLink get set Gets or sets a link to the help file associated with this exception e HResult protected int HResult get set Gets or sets HRESULT a coded numerical value that is assigned to a specific excep tion e InnerException public System Exception InnerException get Gets the instance that caused the current exception e Message public string Message get Gets a message that describes the current exception 180 CHAPTER 6 CLAB
146. ved class returns the that is the root cause of one or more subsequent exceptions e GetHashCode public int GetHashCode Serves as a hash function for a particular type is suitable for use in hashing algo rithms and data structures like a hash table e GetObjectData public void GetObjectData When overridden in a derived class sets the with information about the exception Parameters info context 6 6 NAMESPACE CLAB PARSERS 169 e GetType public System Type GetType Gets the runtime type of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current e ToString public string ToString Creates and returns a string representation of the current exception 6 6 Namespace CLab Parsers Namespace Contents Page Interfaces Classes Chab Text Parser viii sk oe ace bei A Sag be AA 170 TextParser for converting from plain text CP to XML or XML to CP Parsing from XML utilizes the ClabXmlParser class CDA MIE SESCE 62 ica SAS AA ARS ROSE NER AAA 172 Parses and validates the input XML file Inserts types variables and rules to the set CP object 170 CHAPTER 6 CLAB 1 0 API REFERENCE 6 6 1 Classes CLASS CLabTextParser TextParser for converting from plain text CP to XML or XML to CP Parsing from XML utilizes the ClabXm IParser class DECLARATION public class CLabTextParser Object CONSTRUCTORS
147. vides both an editor Problem Editor and an interface Set Parameters for executing a problem configuration and setting values for each variable These are separated in two tabs in the interface This section details the menu options available the functionality of the editor and the functionality of the executing interface Menu options CLab Configurator covers the necessary options one might expect from a editing environment The File menu covers operations per file basis such as saving opening and closing It also contains the Exit options to quit the application The Edit menu covers clipboard options Cut Copy Paste The Run menu contains menu equivalents to the buttons in the interface These options are Start Search Pause Search Stop Search and Restart The Settings menu is the interface to adjust the current parameters for the execution of aconfiguration problem A user may choose to solve a configuration problem with either BDD or CSP There are also several options available which only applies when using BDDs These include the compile method to use Static Dynamic Ascending Setting initial DB Cache and number of BD nodes and the Max Increase value For CSP we can adjust the variable ordering to either Static or Minimum Width The final setting available is an option to turn autocompletion on or off When enabled the autocompletion feature will 27 28 CHAPTER 4 CLAB CONFIGURATOR automatically enter closing characters as dis
148. y BDD representation y Another 2 complementary BDD representation 6 2 NAMESPACE CLAB BDD 61 e Neg public System Collections Generic List buddy_sharp Bdd Neg pis A a Negates the specified 2 complentary BDD representation x Parameters x 2 complementary BDD representation to be negated ShiftLeft public System Collections Generic List buddy_sharp Bdd ShiftLeft Shifts each bit shiftAmount positions to the left Parameters x The 2 complementary representation of a BDD shiftAmount Number of positions x should be shifted left e Truncate public void Truncate Truncates the specified x Parameters x x Thex 62 CHAPTER 6 CLAB 1 0 API REFERENCE CLASS BDDType Abstract class representing variable types Used by CLab BDD Layout DECLARATION public class BDDType Type PROPERTIES e BDDvarNum public int BDDvarNum get set Gets or sets the BDD variable number e DomainSize public int DomainSize get set Gets or sets the size of the domain e TypeName public string TypeName get set Gets or sets the string representation of the name of the type CONSTRUCTORS e Constructor public BDDType Initializes a new instance of the BDDLayoutType class Parameters layoutTypeName Name of the layout type x bddVarNum The number of BDD variables x domainSize Size of the doma
149. ype is suitable for use in hashing algo rithms and data structures like a hash table 214 CHAPTER 7 CASPER API REFERENCE e GetNextVar public int GetNextVar Since the variables are stored increasingly we return the number from input without any calculation Parameters x number InQueue The number in queue e GetType public System Type GetType Gets the of the current instance e MemberwiseClone protected object MemberwiseClone Creates a shallow copy of the current 7 4 Namespace Casper Data Namespace Contents Page Interfaces Classes Adjaceney Base enni a AY at E 216 A class representing a list of adjacent nodes in a Constraint Graph Casper VarDomi eee e een a dt eat 219 A class with variable and domain information used by the Csp class Constramt rap A he ha eee toe bo a MANIA ha oe 222 A class which represents the constraint graph of a csp problem CSP E0035 40g arin ox e Rhea Ge ease oe Ss EG Ae A 224 An abstract class for CSP Expressions All Expression classes implements this class 7 4 NAMESPACE CASPER DATA 215 ESPESPEDI EAS EA ARA 226 CSPEXDPTESSIONS CA A AA E cd 228 A class which keeps track of the expressions for a CSP problem CSPEXDENGS a ad e E o ee AE 230 Implementation class for negation of an expression ESPEXPE O borrar a do tt cada 232 Implementation class for invertion of an expression ESPE Vane da ds a A ee cheered 234 An abstract class for

Download Pdf Manuals

image

Related Search

CLab clabsi bundle clabsi definition clabsi medical abbreviation clabe number mexico clabsi prevention clabber girl clabsi nhsn clabsi guidelines clabel app clabbered milk clabsi infection clabber girl baking powder clabsi icd 10 clabe interbancaria clab fee schedule 2024 clabough\u0027s campground clabe ganadera clabbers clabe interbancaria bbva clabos clabough\u0027s campgrounds in pigeon forge tn clabe o clave clabel ct221b clabel matlab clabe interbancaria santander

Related Contents

少量のグリースをつけて差し込んでください。  Quick Start Manual Jabra GOTM 660 Bluetooth® headset System  Pro-Lok Blue Punch - The Locksmith Security Association  r - mediaTUM  Manual for RO-50G-E01 - Equipos Osmosis Inversa Domestica  BETRIEBSANLEITUNG FÜR PLASMASCHNEIDGERÄT  User`s manual - Design Systems & Technologies  Graco PD120974A User's Manual  Digital inDicators - Lesman Instrument Company  

Copyright © All rights reserved.
Failed to retrieve file