Constraint Satisfaction Problem

 Constraint Satisfaction Problem 

This is one of the most popular Machine Learning based algorithm and code for this is given below in python using Numpy in scratch format.


import numpy as np
rooms={'A':'','B':'A','C':'B','D':'','E':'','F':'D'}
person={'x':['P'],'y':['P'],'z':['P'],'a':['Q'],'b':['Q'],'s':['R']}
contory=['P','Q','R']
hotelLiving={'A':[],'B':[],'C':[],'D':[],'E':[],'F':[]}
count=0
for i in hotelLiving:
    for j in person:
        for z in rooms:
            if(rooms[z]==''):
                for a in hotelLiving:
                    if hotelLiving[a]==[j]:
                      count+=1
                      break
                if count==0:
                      if hotelLiving[z]==[]:
                        hotelLiving[z].append(j)
                count=0
                
for i in hotelLiving:
    for j in person:
        for z in rooms:
            if(rooms[z]!=''):
                for a in hotelLiving:
                    
                    if hotelLiving[a]==[j]:
                        count+=1
                        break
                if count==0:
                    if(hotelLiving[z]==[]):
                        hotelLiving[z].append(j) 
                count=0
                                 
print(hotelLiving)    
  

         
                

Comments

Popular posts from this blog

Multiple inheritance,friend function and multiple file in oop(object oriented programming)

Concepts of OOP (object oriented programming)

Concepts in c++........