Parameters which form the solution can be implemented by the
class
parameter:
Some slots have defined default values. It is not compulsory, but
it
makes the parameter definition of a particular application
easier.
)
(role concrete)
(pattern-match reactive)
(slot active
(create-accessor read-write))
(slot priority
(default yes)
(access read-write)
(create-accessor read-write))
(slot param-type
(create-accessor read-write))
(slot param-value
(default independent)
(access initialize-only)
(create-accessor read-write))
(multislot param-domain
(create-accessor read-write))
(create-accessor read-write))
From the point of view of access, there are two types of slots. The first type provides only the possibility of reading the values assigned to the slots. The second type enables to change the values of these slots. For read-only slots it is enough to set their values only once when instances are created. It is possible to do using CLIPS features - setting the initialize-only access (which contains reading too) to the slot. If the value of a slot can be changed the access to this slot has to be read-write.
The slot param-domain has the form (param-domain <domain type> <domain>). It defines the type of the domain and the values which can be assigned to the parameter (in the room allocation problem only enumerative type is allowed). <domain> represents one or several values depending on the type of the domain.
The class component is dedicated to the representation
of
components which can form the artefact. But a particular
application can use a large number of different components. That
is
why the class component does not represent a particular
component (it cannot create instances - it is an abstract class),
but serves as the parent class for the definition of all possible
components. This parent class contains only information which
concerns all components (and they can inherit it from the parent
class component).
Information which is common to all components is only the name
of
the component and the number of components of the same name.
)
(role abstract)
(slot comp-number
(create-accessor read-write))
(access initialize-only)
(create-accessor read-write))
Different component types can be defined by subclasses of the
parent class component. These subclasses have the
following general form:
Every component type is represented by exactly one subclass. In
this way the number of these subclasses is equal to the number
of
different component types which are available. The number and the
definition of slots are different for different component types
and
depend on a particular application.
)
(role concrete)
(pattern-match reactive)
...
Since components are predefined (and their features are not
changed during the search for the solution), their slots are
available only for reading. Every slot (concerning a component)
has
the form
Constraints can be defined as instances of the class
constraint
which has the following form:
(access initialize-only)
(create-accessor read-write))
The slots which are used only to read information and for which
there is no need to change their values are defined as
initialize-only.
Since the priority of a constraint can vary during the search for
the solution depending on the state of other constraints, the
slot
priority enables to change its value.
)
(role concrete)
(pattern-match reactive)
(slot priority
(create-accessor read-write))
(multislot cons-param
(create-accessor read-write))
(slot cons-violation
(create-accessor read-write))
(multislot viol-param
(default no)
(access read-write)
(create-accessor read-write))
(slot active
(access read-write)
(create-accessor read-write))
(default yes)
(access read-write)
(create-accessor read-write))
The slot cons-param contains the list of all parameters which are relevant to the constraint. If some of them violate the constraint, the value of the slot cons-violation is set to yes and this parameter is registered in the viol-param slot. If there is no parameter to violate some constraint, the slot viol-param of this constraint is empty.
Since the management of the slots viol-param is not
trivial
(modification of a part of the slot content always occurs), it
is
not possible to use default accessors. New accessors have the
form
)
(bind ?self:viol-param (delete$ ?self:viol-param ?position ?position))
)