You are on page 1of 4

# PROBLEM 3

## BAI TOAN: Mt trng i hc c R phng hc, mi phng hc c thuc tnh l v tr v

sc cha (s ch ngi trong phng). V tr l mt thuc tnh phc hp gm cc thng
tin: M phng, tng lu v to nh. C N mn hc c m trong mt hc k. Mt mn
hc c th c chia thnh nhiu lp hc nu s sinh vin ng k hc mn hc
vt qu kh nng cha ca mt phng. C M sinh vin ng k mn hc. Mi ngy
c chia thnh 04 ca hc, bui sng 02 ca hc v bui chiu 02 ca hc.

Yu cu:
1. Hy xc nh cc rng buc cng v rng buc mm cho bi ton xp thi
kho biu theo bi ton t t trn
2. Hy m hnh ho bi ton di dng bi ton tho mn rng buc v nh x
sang bi ton t mu th.

## Xc inh cc rng buc cng v rng buc mm trong bi

ton:
Rng buc cng:
i. Vo cung mt thi gian( ca) trong ngy, mt phng hc khng th
c hn mt lp hc.
ii. Phng hc khng th c lp hc vi s sinh vin nhiu hn sc cha ca
phng.
iii. Vo cung mt thi gian (ca) trong ngy, mt sinh vin khng th tham gia nhiu
hn mt lp hc.
iv. Mt lp hc khng th din ra trong 2 ca lin tip 2 phng khc nhau (ta
nh, tng lu)

## Rng buc mm:

i. S lp hc ti cung mt thi gian (ca) khng ln hn tng s
phng.
ii. S lp hc ca mt mn hc cng nho cng tt.
iii. Chn phng cho lp phu hp vi s sinh vin ca lp nht (cng t
ch trng cng tt).
iv. Th t u tin chn ca cho lp hc (ex: 1,2,3,4..)
v. Cc ca hc ca mt sinh vin trong ngy l lin tuc.
vi. S ca hc ti a trong ngy ca sinh vin.

## Cc rng buc cng (hard constraints) phi c thoa mn tt c c th to ra

c p n ung. Cc rng buc mm khng nht thit phi thoa mn tt c tuy nhin
nu thoa mn cng nhiu rng buc mm se c c p n tt nht c th.

## BAI TOAN THOA MAN RANG BUC (Constraint Satisfaction

Problems)
+ Tp hu hn cc bin: v1, v2, v3,, vn
+ Min gi tr khc rng ca cc bin: Dv1, Dv2, Dv3,,Dvn
+ Tp hu hn cc rng buc: C1, C2, C3,, Cn

## Ap dung bi ton thoa man rng buc cho bi ton xp thi

khoa biu sinh vin trng H. Chin lc xp theo th t tng
mn hoc (subject).
-

Tp cc phng R = { R1,R2,..,Rr };
Tp cc mn hc S = {S1, S1,, Sn};

## Tp cc lp hc ca mn Si bt k L = { course1, course2, course3,, coursek };

Tp cc ca hc trong tun T = {t1, t2, t3,, t20} (1 ngy hoc c 4 ca hc, gi su73 trong
tun c 5 ngy hc nn tng s ca = 4 x 5 = 20 ca).
o Phn lp (course) cho tng mn hc (subject) da vo danh sch sinh vin ng k v
kh nng cha ca cc phng hc(Room) cn li nhm thoa mn cc rng bu c cng.
C 2 hng phn lp: da vo ca hc (cung ca hc se c nhiu lp ca m t mn hc)
nhm ti u ha ca hc v phn lp hc da vo phng hc (cc lp hc se s dung
chung phng) nhm ti u lng phng s dung.
o Kt hp hai hng ta c bi ton thoa mn rng buc nh sau:
Tp hu hn cc bin: course1, course2, course3,, coursek ca cung mt mn
(subject).
Min gi tr khc rng ca cc bin:
Dcourse1={R{R1,R2,..,Rr};T{ t1, t2, t3,, tt} } ;
Dcourse2={R{R1,R2,..,Rr};T{ t1, t2, t3,, tt} } ;
Dcourse3={R{R1,R2,..,Rr};T{ t1, t2, t3,, tt} } ;

## Dcoursek={R{R1,R2,..,Rr};T{ t1, t2, t3,, tt} } ;

(Vi Dcourse={R,T} l danh sch cc phng cn trng hoc ca trng m coursei c th
hc (thoa mn rng buc: kh nng cha ca cc phng phi ln hn s sinh vin
tham gia coursei).

## Tp hu hn cc rng buc: C={Cc lp hc din ra cung ca hc c phng khc nhau;

Cc lp hc cung phng hc c ca hc khc nhau.}

## Cc rng buc cng (hard constraints) c th c biu thnh bi ton t mu

th (graph coloring problem).

## Anh xa qua bi ton t mu thi (Graph Coloring Problem)

Example: c 5 lp hc (course) ca mn hc (subject) S i no .

## V = {course1, course2, course3, course4, course5}

E = {a,b,c,d,e}
Color = {red, blue, green, yellow}

## Cc cnh a, b, c, d th hin cc lp hc (course) 1, 2, 3, 4 din ra cung ca hc

do cc lp hc 1, 2, 3, 4 din ra trong cc phng khc nhau. Cnh e th hi n

## lp 4, 5 cung phng hc nn c ca hc khc nhau.

Cc kha hc vi phm mt trong cc rng buc trong C c t mu khc nhau.
Thut ton t mu:
REPEAT untill all vertices are colored
Choose the next vertice from V to be colored by selecting the
one whose neighbors have already used the most colors. Break
ties by choosing the one with the most uncolored neighbors.
Color that vertice with the first color in the set of all colors that
has not already been used by one of the neighbors.
END.
Tng t nh vy, ta p dung cho cc mn hc khc trong tp:
S = {S1, S1,, Sn}\{Si}
(Th t chn mn phu thuc vo khoa, ngnh, cc mn bt buc)