• No results found

Partial Calculation of Objective Function

6. T 0 = ‐ Average Δ E/log 0.93;

4.3.4 Partial Calculation of Objective Function

To be able to have better and faster performance for this algorithm, it is very important to develop an approach to calculate the partial change in objective value (energy function) at each iteration for each executed move rather than calculating the overall energy value each time. Therefore, to be able to calculate the change in energy value we need to apply the following formula:

∆OF=∆E =

φ

*∆STC +

ψ

*∆SCC +

ω

*∆SAvail

where

φ

=50,

ψ

=1, and

ω

=1.

4.3.4.1 Time Availability Hard Constraint Partial Penalty Value

For each lecture Lx, to calculate partially the change in time availability

violations penalty value (∆Savail), it is important to keep track of:

− The list of periods (LP) allowed for lecture Lx.

− The period Px assigned to Lx.

− A 0/1 tag value (AvailableConflictTag);

Whenever a new Period value Px is assigned to Lx, Px will be first checked if it

belongs to the list of allowed periods LP of Lx or not. If it belongs, then the tag value

AvailableConflictTag will be set to zero and the change in availability penalty value

(∆SAvail) will be decremented by one if the previous AvailableConflictTag was one,

and Lx will move from the availability constraint violation status to the no violation

status, or, ∆SAvail might remain the same if the old tag value was set zero (there was

already no violation). On the other hand, if the new Px is not listed in LP, then

AvailableConflictTag will be set to one and ∆SAvail will be increased by one if the old

tag value was zero or it will remain the same if the old tag was one (already in violation and continues). Therefore, ∆SAvail value will be either:

− decremented by -1 − or incremented by +1 − or remains the same

4.3.4.2 Teacher Conflicts Hard Constraint Partial Penalty Value

To calculate the change in the teachers’ conflicts penalty value ∆STC, a new

two-dimensional array data structure is needed to save how many lectures are assigned for each teacher at specific period (time); For example, when we have

lectures L1 and L2 such that L1 has teacher T1, period Px and room Rx, and L2 has

teacher T2, period Py and room Ry, and both of them has conflicts with other lectures,

as shown below in Figure 4.6, and the algorithm tries to swap their values, this swap move will be accepted only if it solves partially or completely those conflicts and

∆STC <0.

  Figure 4.6: The Change in Teachers Conflicts Penalty When a Swap Move is Applied.

Therefore, ∆STC = ∆STC1 for T1+ ∆STC2 for T2, where:

− ∆STC1=New conflicts After Swap from PxÆPy – Existing Old Conflicts

= +

- +

− ∆STC2 = New conflicts After Swap from PyÆPx – Existing Old Conflicts

= +

Check what you can observe from the following three examples for calculating

∆STC1 for lecture L1 with T1 while studying different kinds of moves:

- If

- If

- If

Therefore, the value of ∆STC1 will be in the range [-1, 1] and this will give the

conclusion that for the perturb move of SA algorithm, the value of ∆STC of swapping

the assignments of L1 and L2 (∆STC = ∆STC1 + ∆STC2) will be between the range [-2, 2]

4.3.4.3 Curriculum Conflicts Hard Constraint Partial Penalty Value

To measure the change in the curricula’s conflicts penalty value ∆SCC, a two-

dimensional data structure similar to that of teachers’ conflicts should be built in which we can keep track of the number of lectures belonging to the same curriculum and assigned to the same period and follow the same calculation methods we used in

section 4.3.4.2.

4.3.4.4 Overall Conflicts Penalty Value

To be able to compare our objective function value with that of the value coming from ITC2007 standard solution validator (Di Gaspero, McCollum and Schaerf, 2007), we have to write another method that goes in parallel with our formula and that would calculate the overall conflicts value that counts the conflicts between the courses. For example, assume:

- Curriculum1 has courses C1, C2 and C3;

- Curriculum2 has courses C1, C2, and C4 Px Py

Old: 5 1

New: 4 2

∆STC1 = (3+1)-(4+0) = 0. Nothing changed

because L1 is removed from a conflicting

period to another conflicting one. 

Px Py

Old: 5 0

New: 4 1

∆STC1 = (3+0)-(4+0) = -1. This is a good

move because it removes L1 from a

conflicting period to a period that has no teacher conflicts; thus, improving ∆STC1.

Px Py

Old: 1 5

New: 0 6

∆STC1 = (0+5)-(0+4) = +1. This is a bad move

where ∆STC1 is getting worse because L1 is

removed from a non-conflicting period to a conflicting period. 

- Teacher1 teaches courses C1 and C2.

If it happen that C1 and C2 has a conflicting lecture L at Period1, then, in our

method, we count the following three conflicts:

- Period1 at Curriculum1: L1 of C1 conflicts with L2 of C2.

- Period1 at Curriculum2: L1 of C1 conflicts with L2 of C2.

- Period1 at Teacher1: L1 of C1 conflicts with L2 of C2.

On the other hand, the standard solution validator counts those as one conflict between C1 and C2. Therefore, a new data structure is needed to be developed to keep track of possible conflicts between courses and calculate the objective value in the validator’s way. This can be done by building from the start a set of possible conflicts’ objects where each one includes two courses that might have the same curriculum or the same teacher in common. And, we should have a two-dimensional array of conflicts similar to the one we built in section 4.3.4.2, that counts the number of conflicts happened at each period.