Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from constraint import *
- def check_attendance(M,P,S):
- if S==0:
- return False
- if M==0 and P==0:
- return False
- return True
- def check_simona(S,V):
- if (V>=13 and V<15) or V==16 or V==19:
- return True
- return False
- def check_marija(M,V):
- if M==0:
- return True
- else:
- if (V>=14 and V<16) or V==18:
- return True
- return False
- def check_petar(P,V):
- if P==0:
- return True
- else:
- if (V>=12 and V<14) or (V>=16 and V<20):
- return True
- return False
- if __name__ == '__main__':
- problem = Problem(BacktrackingSolver())
- # ---Dadeni se promenlivite, dodadete gi domenite-----
- problem.addVariable("Marija_prisustvo", [0,1])
- problem.addVariable("Simona_prisustvo", [0,1])
- problem.addVariable("Petar_prisustvo", [0,1])
- problem.addVariable("vreme_sostanok", [12,13,14,15,16,17,18,19])
- # ----------------------------------------------------
- # ---Tuka dodadete gi ogranichuvanjata----------------
- problem.addConstraint(check_simona,("Simona_prisustvo","vreme_sostanok"))
- problem.addConstraint(check_attendance,("Marija_prisustvo","Petar_prisustvo","Simona_prisustvo"))
- problem.addConstraint(check_marija,("Marija_prisustvo","vreme_sostanok"))
- problem.addConstraint(check_petar, ("Petar_prisustvo", "vreme_sostanok"))
- # ----------------------------------------------------
- [print(solution) for solution in problem.getSolutions()]
- #tocna e ali ne mi printa vo soodveten redosled guess treba da si doktor za toa da go postignes na olku prosta zadaca
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement