• No se han encontrado resultados

EL PERFIL PROFESIONAL EN LA DIMENSIÓN PERSONAL a Aspecto cognitivo

AREQUIPA PERÚ

EL PERFIL PROFESIONAL EN LA DIMENSIÓN PERSONAL a Aspecto cognitivo

The rule language provides a small number of language constructs on top of Essence. The

additions are mostly in the form of new operators. These operators have special meaning and are handled specifically by Conjure. where,letting, andfindstatements are taken

from Essenceand given new meanings.

5.5.1 Guarded rewriting: wherestatements

Essenceuseswherestatements for validity checking of instance data. The rule language

reuseswherestatements as syntax for guards. Guards are used in most rewriting system to limit the applicability of a rule. A rule is only applied if its guards can be evaluated totrue.

5.5.2 Guarding operators: has*

These operators are commonly used in thewherestatements of a rule.

All three operators listed in this section evaluate to a boolean value. They can be freely used in conjunction with existing Essenceoperators. For example, awherestatement in a

rule can contain a disjunction (\/) of two expressions both built using the rule language operatorhasRepresentation.

5.5.2.1 hasDomain

The operatorhasDomaintakes two arguments. Its first argument is an expression. Its second argument is adomain pattern. The second argument gives the expected domain for the first argument.hasDomainis used in infix form.

An expression of the form&x hasDomain `set (size &n) of &tau`will be evaluated totrue if the expression bound to the meta-variable &x has a domain that matches the pattern on the right. In order to match this pattern, the domain of&xhas to be a set domain, with a known cardinality. It also needs to not have any other attributes. Domain patterns are described in more detail inSection 5.4. In addition to evaluating totrue, such an expression will also introduce values for meta-variables&nand&tau. &nwill be bound to an integer expression, whereas&tauwill be bound to a domain. The same expression will be evaluated tofalseif the domain of&xcannot be successfully pattern matched to the domain on the right-hand side. In this case, the meta-variables&xand&tau will not be bound to any value.

5.5.2.2 hasType

The operator hasType is similar to hasDomain. It also takes two arguments, and is used in infix form. Its first argument is an expression, its second argument is atype pattern. In Essence, every expression has a type. The type of an expression can be calculated by

For example, if a decision variable has the domain set (size 3) of int(0..9), its type will be set of int.

5.5.2.3 hasRepresentation

The operatorhasRepresentationis only used in vertical expression refinement rules. Its first argument is an expression, and its second argument is an identifier.

An expression of the form&x hasRepresentation Matrix1Dwill be evaluated totrue

if&xis bound to an abstract decision variable or problem parameter that is being represented using theMatrix1Drepresentation. It will be evaluated to false otherwise.

5.5.3 refn

Depending on context, the operator refn can be seen as a shorthand for ‘refinement’ or ‘refinement of’.

In a representation selection rule,refn does not take any arguments. It is merely an identifier which is handled specifically during rule application. Representation selection rules are written in terms of domains and not full declarations of decision variables or problem parameters. When applying a rule, Conjureprojects the domain out of a declara-

tion statement and uses it for pattern matching. Representation selection rules also do not output full declarations by themselves. They output a replacement domain instead, and Conjureis responsible to generate a new declaration together with a new name using the

generated domain.

This arrangement limits the ability to refer to the generated decision variable within the representation selection rule itself. Because the new decision variable is not even give a name yet. The operatorrefn is used to fill this gap, it can be used in a representation selection rule to refer to the decision variable which will be generated as a result of applying the rule. For example, if a rule outputs a matrix domain and the rule wants to post an

The samerefn keyword is used in expression refinement rule to have a very similar meaning. There is one important difference though: in expression refinement rules,refn

is actually an operator which takes a single argument. It takes as argument an abstract decision variable or problem parameter and returns the refinement of the argument. In order to do this, the argument has to have a representation selected for it in the representations selection phase. Typically, a rule will use ahasRepresentationoperator in awhereclause to check which representation something has, before callingrefnon it.

5.5.4 domSize

The operatordomSizeis a shorthand for‘domain size’. It takes as input an Essenceexpression

and returns an integer expression representing the size of the domain of its argument. For constant expressions, it returns1.

For example,domSize(int(1..9))is 9,domSize(set (size 2) of int(1..9))is9 ** 2which is equal to81.

5.5.5 Deep replace

In rules, sometimes all occurrences of a certain subexpression needs to be replaced by some other subexpression. Conjureprovides a way to accomplish this in the rule language: the

deep-replace operator.

The syntax for deep-replace is demonstrated by example:&body i –> m[i] . In this example,&bodyis a meta-variable,iand mcan be any expression. The effect of using the deep-replace operator is replacing all occurrences ofiin&bodywithm[i].

For example if&bodyis(i + 3) ** j, after deep-replace if the result will be(m[i] + 3) ** j.