• No results found

4.4 Car Configuration Rules

4.4.1 Rules

There are 3 rules which define relations between options, namelyrequire, include and exclude. The other two rules,newPriceanddiscount, change the price of the option de- scribed by the rule.

Require rule

The rulerequire (4.1) is used on options which require the presence of at least one other options. For example, to have black leather seats, you at least need to have leather seats. The first parameter of the function is the option which requires at least one of the options {y1, . . . ,yn}. This rule does not provide any relation between the options {y1, . . . ,yn}or if

optionxis required by any option.

ϕ=req(option,requiredOptions)

ϕ=req(x,y1,y2, . . . ,yn) (4.1)

Include rule

Some options include other options. For example, the Safety Plus Pack (Figure 1.1) con- tains several safety related options such as Driver Attention Alert and Automatic Emer- gency Braking. For this purpose, theinclude(4.2) rule can be used. If optionx is chosen, the options{y1, . . . ,yn}are included and thus free of charge.

ϕ=incl(option,includedOptions)

ϕ=incl(x,y1,y2, . . . ,yn) (4.2)

Exclude rule

There are several options that exclude each other. For example, it is not possible to have a red bodywork and a blue bodywork at the same time. These exclusions are defined with the exclude(4.3) rule. If optionxis chosen, the options{y1, . . . ,yn}are excluded.

ϕ=excl(option,excludedOptions)

ϕ=excl(x,y1,y2, . . . ,yn) (4.3)

newPrice rule

In some cases, an option will get a different price than the one specified for the option. For these cases, the rulenewPrice(4.4) can be used. This rule defines the price of the option with tax included and excluded. For the calculations, only the price with tax included is used. In most cases, a condition is applied to this rule. When in this thesis the rulenewPriceis used, the price with tax excluded is omitted for clarity.

ϕ=newPrice(option,priceIncl,priceExcl)

ϕ=newPrice(x,pI,pE) (4.4)

Discount rule

It is possible that the price of options must be decreased due to some discount. Thediscount (4.5) rule can be used to decrease, or increase, the price of an option. This rule is in most cases used with a condition. In this rule, the discount with tax included and excluded is provided together with the option identifier. Just as with thenewPricerule, only the discount with tax included will be used when in this thesis the rulediscountis used; the discount with tax excluded is omitted. The discount is provided as a negative value and should be interpreted as a decreasing of the price and not as a negative discount, which would lead to increasing the price.

ϕ=discount(option,discountIncl,discountExcl)

ϕ=discount(x,dI,dE) (4.5)

4.4.2 Conditions

There are two conditions that can be applied to the rules described in Section4.4.1. These conditions areonlyIfandnotIf.

Only if

TheonlyIf(4.6) condition is used for rules that only apply if several options are satisfied. Thus, if the options{y1, . . . ,yn}are satisfied, then rulexapplies. Otherwise, this rule must be ignored.

ϕ=rule.onlyIf(options)

ϕ= x.onlyIf(y1,y2, . . . ,yn) (4.6)

Not if

WhereonlyIfincludes the rule if the condition is met, the conditionnotIf(4.7) will exclude the rule if the condition is fulfilled. So, the rulexdoes not apply if the options{y1, . . . ,yn} are all satisfied.

ϕ=rule.notIf(options)

ϕ=x.notIf(y1,y2, . . . ,yn) (4.7)

4.5

Example

As an example, we take a simplified version of the Volkswagen Beetle as provided by Bet- terBe. The environment contains the car and the Equipment Groups. In the dataset provided by BetterBe, there are 129 Equipment Groups.

The car has 11 options, with identifiers 131 until 141. The options, with the Equipment Groups they belong to, are: Gloss Paint (131), Metallic Paint (132, metallicPaint), Board Com- puter (133), Anti Theft Alarm (134, antiTheftProtection), Telephone Packet (135), Executive Packet (136), Cloth Upholstery (137), Leather Clothing (138, fullLeatherInterior), Red Paint (139, paintRed), Grey Paint (140, paintGrey), Silver Paint (141, paintSilver).

The car has 21 mandatory Equipment Groups, such as ’audioSystem’, ’frontAirbag’ and ’powerSteering’. Next to these mandatory Equipment Groups, the car has 33 optional Equipment Groups and 75 forbidden Equipment Groups.

Next to the options and Equipment Groups, the car also contains rules. For this example, the simplified set of rules is separated into three groups and sorted on the option the rule belongs to. There are 11 rules for the paint:

excl(131, 132)

excl(132, 131)

req(139, 131) req(139, 137, 138) excl(139, 140, 141)

req(140, 132) req(140, 137, 138) excl(140, 139, 141)

req(141, 132) req(141, 137, 138) excl(141, 139, 140)

There are two rules for clothing:

excl(137, 138)

excl(138, 137)

There are two rules for the executive packet:

5

Encoding

This chapter contains an encoding from the car configuration models provided by BetterBe into MaxSAT Problems. The encoding will answer Research Question"How can we encode the car configuration models to MaxSAT problems?".

In the encoding of the elements, the logical equivalence of the implies operator (5.1a) and the distributivity of the implication (5.1b), disjunction (5.1c) and the negation (5.1d) operators are used.

a →b≡ ¬a∨b (5.1a)

a(pq)(a p)(aq) (5.1b)

a∨(p∧q)≡(a∨p)∧(a∨q) (5.1c)

¬(a∨b)(¬a∧ ¬b)

¬(ab)(¬a∨ ¬b) (5.1d)

For the remainder of this thesis, the following notation for a clause will be used: ω = (φ,w)whereφis the formula in CNF andwthe weight of the clause. For hard clausesw=>

will be used.

The WCNF format has one restriction on the weight of a clause, namelyw > 0. This

leads to two cases which have to be encoded in a clever way. In the first case, w = 0, the price does not influence the total cost of the car. In the second case,w < 0, the price of the

clause lowers the total cost of the car.

In a MaxSAT solver, the weight of all falsified clauses is summed up. The total sum of these clauses must be the price of the car. For example, if option x costs e500, then the option will be added to the clause database as the negative soft clauseω = (¬x, 500). If the

customer wants optionsxon the car, thenx = T. This leads to falsifying(¬x, 500)and 500

is added to the total weight. With this encoding, all selected options will be positive literals in the resulting model of the formula and the optimum cost is the correct price of the car.

5.1

Car

Without the presence of the car, there is nothing to satisfy, so the car literal will be added as a hard unit clause to the database. For the car literal, the literal 1 is reserved. As the car is not free, there will also be a soft unit clause with a weight. This weightW will be initiated as the pricepof the car and weightW will be adjusted based on the options and the rules

later on in the encoding. These changes to the costWare further explained in the upcoming sections. For the car the clauses(1,>)and(¬1,W)are needed.

5.2

Options

For every option with identifier xi the literal xi represents this option. This will be used throughout the whole thesis for clarity. No distinction between the identifier and the literal will be made. For every option xi with price pi where pi > 0, the clause (¬xi,pi)will be added to the clause database. For options with pricepi = 0, three different encodings will be compared. In the first encoding, two soft clauses will be added. These clauses are(¬xi, 1) and(xi, 1). Whether you choosexi =Forxi = T, these clauses ensure that the total price of the car will be increased by 1. The total price of the car will then be too high. For the price of the car to be still correct, the base priceW will be decreased by one on beforehand. We call this encodingSOFT-2. In the second encoding,SOFT-1, just one soft clause(xi∨ ¬xi, 1)will be added. Sincexi∨ ¬xi = T, the clause is always satisfied and thus no costs are added. The third encoding,HARD, uses the fact thatxi∨ ¬xi =Tand adds the hard clause(xi∨ ¬xi,>). Besides the price of an option, also the connection between the option and the Equipment Groups must be encoded. Letx be the option and(y1, . . . ,yn)be the Equipment Groups it belongs to. This relation can be described asx → (y1∧. . .∧yn). This can be encoded into CNF as can be seen in Equation5.2. The resulting clauses will be hard clauses, since this relation always exists. Thus for everyyi ∈ {y1, . . . ,yn}the clause(¬x∨yi,>)is added.

ϕ=x→(y1∧. . .∧yn) ϕ= (x→y1)∧. . .∧(x→yn) ϕ= (¬x∨y1)∧. . .∧(¬x∨yn)

(5.2)

5.3

Equipment Groups

Every Equipment Group with identifierxiwill be represented by literalxi. The literal of this Equipment Group will be the same for all vehicles. For all mandatory Equipment Groups

xi ∈ {x1, . . . ,xn}, the positive unit clause (xi,>)is added. This will make sure that these Equipment Groups must be satisfied.

Since optional Equipment Groups do not have to be satisfied and they do not influence the final price of the car by themselves, no clauses have to be added.

Every Equipment Group which is neither mandatory nor optional is forbidden and is not allowed on the car. To ensure that they will not be added, all these forbidden Equipment Groupsxi ∈ {x1, . . . ,xn}will be added as the negative unit clause(¬xi,>).

As explained in Chapter 4, for every Equipment Group that is on the car, at least on of the options that belong to the Equipment Group must be satisfied as well. Letx be the Equipment Group and (y1, . . . ,yn) the options that belong to Equipment Group x. This relation between the Equipment Group and options can be described asx →(y1∨. . .∨yn). Equation5.3 shows the encoding into CNF. For every Equipment Groupxi ∈ {x1, . . . ,xn} with corresponding options{y1, . . . ,ym}the clause(xi∨y1∨. . .∨ym,>)must be added to the clause database.

ϕ=x→(y1∨. . .∨yn)

5.4

Car Configuration Rules

5.4.1 Rules

Require rule

The rulerequirecan be encoded as proposed in Equation5.4. The encoding of the rule will lead to one clauseωwhereω = (¬x∨y1∨. . .∨yn,>).

ϕ=req(x,y1,y2, . . . ,yn) ϕ=x →(y1∨y2∨. . .∨yn) ϕ=¬x∨y1∨y2∨. . .∨yn

(5.4)

Exclude rule

The encoding ofexcludecan be seen in Equation5.5. For every optionyi ∈ {y1, . . . ,yn}the clauseωi = (¬x∨ ¬yi,>)is added to the clause database.

ϕ=excl(x,y1,y2, . . . ,yn) ϕ=x→(¬y1∧ ¬y2∧. . .∧ ¬yn) ϕ= (x→ ¬y1)∧(x→ ¬y2)∧. . .∧(x→ ¬yn) ϕ= (¬x∨ ¬y1)∧(¬x∨ ¬y2)∧. . .∧(¬x∨ ¬yn) ϕ=ω1ω2∧. . .∧ωn (5.5) Include rule

The encoding5.6 of the includerule will lead to a clause ωi whereωi = (¬x∨yi,>)for every optionyi ∈ {y1, . . . ,yn}.

Since there is no surcharge for the included options, the price of the included options must be subtracted from the total priceWwhen the rule is satisfied. Because it is not allowed to subtract the cost of the options by using a negative weight, the costwis subtracted on beforehand from the base priceW of the car. This costw = ni=1pi where pi is the price of optionyi is then also used in the new unit clauseωz = (z,w). The fresh literalzrepresents the discount provided by theincluderule. Ifw = 0, this clause is omitted. If the include

rule is unsatisfied, the clauseωz is falsified and the cost of the clause is added to the total price of the car.

The MaxSAT solver will by itself ensure the satisfiability ofz when theincluderule is satisfied, but can still satisfyzwithout satisfying the rule. To prevent this from happening,

z must only be satisfied when all options in the rule are satisfied. For every option k ∈ {x,y1, . . . ,yn}, a clause(k∨ ¬z,>)is added. This ensures that if an option in the rule is not satisfied,¬z=Tand thusωz = F.

ϕ=incl(x,y1,y2, . . . ,yn) ϕ= x(y1∧y2∧. . .∧yn) ϕ= (x→y1)∧(x→y2)∧. . .∧(x→yn) ϕ= (¬x∨y1)∧(¬x∨y2)∧. . .∧(¬x∨yn) ϕ= ω1∧ω2∧. . .∧ωn (5.6) newPrice rule

ThenewPricerule,newPrice(x,pI,pE), can be used to change the price of an option. When changing the price of an option, it is not useful to change the weight of the corresponding

clause, because there could be other rules that also influence the price. For the weight of the clause the difference between the old and the new price will be calculated. This difference, the discountd, will be calculated asd= pI−pwherepis the price of the optionx. For the encoding, three cases are distinguished.

If d<0 then the price of the option must be decreased. To decrease the price of the

option, the price of the carW is decreased with|d|and the clause(z,|d|)is added wherez

is a fresh literal. Ifd>0then the price will thus be increased. The clauseωz = (¬z,d)is added together with the two clauses(¬x∨z,>)and(x∨ ¬z,>)to ensure the price of the

option is increased. These two clauses ensure that the clauseωzis falsified if and only ifxis satisfied. And ifd=0, the price of the option will stays the same and thus no extra clause

or changes are needed.

Discount rule

The encoding of thediscountrule, discount(option,dI,dE), is similar to the encoding of thenewPricerule. The difference is that the discount d does not has to be calculated, but is already known as dI. The discount dI is provided as a negative value and should be interpreted as a decreasing of the price and not as a negative discount.

If dI <0, then clause (z,|d|)is added and W = W− |dI|. If dI> 0 then the clauses

(¬z,dI),(¬x∨z,>)and(x∨ ¬z,>)are added. And ifd=0, no clauses are needed.

5.4.2 Conditions

The encoding of the conditions will result in a set of only positive or negative literals. These literals must then be used in the encoding of the rule the condition is applied to.

Only if

TheonlyIfcondition is used for rules that only applies if several options are satisfied. In the encoding (5.7) of this condition,xrepresents the encoding of the rule. Once the rule and the condition are encoded, the formulaϕmust be rewritten in CNF.

For the rulesinclude,newPriceanddiscount, the condition must also be satisfied for the discount to be valid. So, for everyyi ∈ {y1, . . . ,yn}the clause(yi∨ ¬z,>), wherezis the literal used for the discount, is added.

ϕ=x.onlyIf(y1,y2, . . . ,yn) ϕ= (y1∧y2∧. . .∧yn)→x ϕ=¬(y1∧y2∧. . .∧yn)∨x ϕ=¬y1∨ ¬y2∨. . .∨ ¬yn∨x (5.7) Not if

The encoding ofnotIfis presented in Equation5.8. Just like the encoding ofonlyIf, does

xrepresent the encoding of the rule and must the formulaϕstill be rewritten in CNF. Also, clauses are added to ensure that the discount is only applied when the condition is met. For everyyi ∈ {y1, . . . ,yn}the clause(¬yi∨ ¬z,>)is added.

ϕ=x.notI f(y1,y2, . . . ,yn) ϕ= (¬y1∧ ¬y2∧. . .∧ ¬yn)→x ϕ=¬(¬y1∧ ¬y2∧. . .∧ ¬yn)∨x ϕ=y1∨y2∨. . .∨yn∨x

Condition Example

We take as an example the ruleexclude(x1,y1,y2).onlyI f(z1,z2). The encoding ofexclude provides the clauses(¬x∨ ¬y1,>)and(¬x∨ ¬y2,>). TheonlyIfcondition has as its en- coding the formula¬z1∨ ¬z2∨x. When substituting xwith the encoding of the rule, we have¬z1∨ ¬z2∨((¬x∨ ¬y1,>)∧(¬x∨ ¬y2,>)). Rewriting this into WCNF leads to the following two clauses:(¬z1∨ ¬z2∨ ¬x∨ ¬y1,>)and(¬z1∨ ¬z2∨ ¬x∨ ¬y2,>).

5.5

Encoding Validation

Now an encoding is presented, this encoding must be validated. Because the car configura- tion models provided by BetterBe are not in a mathematical representation, it is not possible to write done a formal proof. To validate the encoding, the amount of satisfiable instances and the costs of these instances are compared. To do these comparisons, the MaxSAT in- stances are solved by Open-WBO. For the options withp = 0, the encodingHARD is used. As can be seen in Chapter6, Open-WBO andHARD are the best choices to solve these car configuration problems.

At first, the results of Open-WBO are compared to the results of BetterBe. During this validation is assumed that the BetterBe Solver produces the correct results. When these re- sults match, it is save to conclude that Open-WBO produces correct results on the encoding. Now it is set that Open-WBO generates correct results, it is not yet ensured that the encoding is correct. The possibility exists that the implementation of Open-WBO contains some mistakes or bugs which could lead to the correct result, while the encoding is incorrect. To verify the correct behaviour of Open-WBO and prevent the encoding from containing er- ror, the results are also compared to the results of the other three MaxSAT solvers described in Section6.1. If all these results match, it is safely to conclude that the encoding is verified and Open-WBO is behaving correctly.

During both validations, not only the MaxSAT problems of the plain car models are solved, but also instances in which some Equipment Groups are made mandatory. Eight different sets of Equipment Groups will be used. For the comparison, a selection between some common and uncommon combinations of Equipment Groups is made. This leads to a total of nine comparisons. For these comparisons, all 12845 instances provided by BetterBe are used.

Before performing any comparison, the encoding is validated by experts of BetterBe. These experts know how the rules in their car configuration models must be interpreted and if the encoding to Boolean algebra is valid. According to these experts are the rules are encoded correctly and can be compared to the BetterBe solver.

5.5.1 BetterBe

To compare the results, both solvers will solve the car configuration problems for the same sets of Equipment Groups. Table5.1shows the amount of satisfiable vehicles found by the solvers per set of Equipment Groups. The bottom row contains the differences between both solvers. A positive value tells us that Open-WBO has found more satisfiable instances than BetterBe and a negative value that Open-WBO has found less instances.

As can be seen in the table, there are some differences between the two solvers. For the ’metallicPaint’ instances does Open-WBO find less satisfiable vehicles, but it finds more sat- isfiable vehicles for the other instances. Besides the differences in the amount of satisfiable instances, there are also some differences in the costs found by both solvers. These differ- ences in percentages can be seen in Figure5.1. In 8.1% of the cases does Open-WBO produce

8.1%

87.4% 4.5%

Lower result Same result Higher result

FIGURE5.1: Prices of the solutions of Open-WBO compared to BetterBe

a cheaper result, in 4.5% of the cases produces Open-WBO a more expensive result and in 87.4% of the cases do they provide the same result.

There are three explanations for the differences in the results. At first, BetterBe has some

Related documents