Beispiel #1
0
    def trouveLaSolution(self):

        # consistance des noeuds + arcs
        print "|+| Fait la consistance des noeuds"
        VARS.consistanceDesNoeuds()
        print "|+| Fait la consistance des arcs"
        CONTS.consistanceDesArcs()
        afficheEtats()

        afficheNombreVarsEtContraintes()
        print "|+| Applique l'heuristique Variable Ordering"
        PSC.variableOrdering()

        print "|+| Applique le Forward Checking"
        #		sol = PSC.backtrack(0, False)
        sol = PSC.forwardChecking(0, False, True)
        if sol != PSC.ECHEC:
            afficheUneSolutionPossible()
        else:
            print "|-| Aucune solution trouvee"
Beispiel #2
0
	def trouveLaSolution(self):
		
		# consistance des noeuds + arcs
		print "|+| Fait la consistance des noeuds"
		VARS.consistanceDesNoeuds()
		print "|+| Fait la consistance des arcs"
		CONTS.consistanceDesArcs()
		afficheEtats()

		afficheNombreVarsEtContraintes()
		print "|+| Applique l'heuristique Variable Ordering"
		PSC.variableOrdering()
		
		print "|+| Applique le Forward Checking"
#		sol = PSC.backtrack(0, False)
		sol = PSC.forwardChecking(0, False, True)
		if sol!=PSC.ECHEC:
			afficheUneSolutionPossible()
		else:
			print "|-| Aucune solution trouvee"
def featureExtraction(pairs, CombinedStrokes):
    Feature = []

    try:
        for pair in pairs:
            # print(pair)
            geo_features = geometric_features(CombinedStrokes, pair)
            shape_context = PSC.getAllPSC(CombinedStrokes, pair)
            final_feature = np.append(geo_features, shape_context)
            # print(Label)
            Feature.append(final_feature)
    except Exception as e:
        print(e)

    return Feature
def feature_extraction(strokes, SLT):
    Label = 0
    Feature = []
    #print("SLT::",SLT)
    try:
        for pair in SLT:
            #print(pair)
            geo_features = geometric_features(strokes, pair)
            shape_context = PSC.getAllPSC(strokes, pair)
            #       print('s:',shape_context)
            final_feature = np.append(geo_features, shape_context)
            Feature.append(final_feature)
    except Exception as e:
        print(e)
    #print(Feature)
    return np.asarray(Feature)
def featureExtraction(pairs, CombinedStrokes, labeledgraph):
    Feature = []

    try:
        for pair in pairs:
            # print(pair)
            geo_features = geometric_features(CombinedStrokes, pair)
            shape_context = PSC.getAllPSC(CombinedStrokes, pair)
            final_feature = np.append(geo_features, shape_context)
            Label = getRelationId(labeledgraph[pair[0]][pair[1]])
            # print(Label)
            final_feature = np.append(final_feature, Label)
            Feature.append(final_feature)
    except Exception as e:
        print(e)

    return Feature
def feature_extraction(strokes, GT, SLT):
    Label = 0
    Feature = []

    try:
        for pair in SLT:
            # print(pair)
            geo_features = geometric_features(strokes, pair)
            shape_context = PSC.getAllPSC(strokes, pair)
            final_feature = np.append(geo_features, shape_context)
            if (GT[pair[0]][pair[1]] == '*'):
                Label = 1
            else:
                Label = 0
            final_feature = np.append(final_feature, Label)
            Feature.append(final_feature)
    except Exception as e:
        print(e)

    return Feature
Beispiel #7
0
print "\t@version: 2.3  date: 31/03/2008 modified by Thomas Leaute"
print "\t@version: 2.2  date: 28/06/2007 modified by Thomas Leaute"
print "\t@version: 2.1  date: 04/05/2007 modified by Thomas Leaute"
print "\t@version: 2.0  date: 03/05/2007 modified by Thomas Leaute"
print "\t@version: 1.1  date: 02/05/2007 modified by Thomas Leaute"
print "\t@version: 1.0  date: 05/03/2007 created by Vincent Schickel-Zuber"
print "\t@author: [email protected] date: 05/03/2007"
print "\t@copyright: EPFL-IC-IIF-LIA 2007"
#-------------------------------------------------------------------------------
import copy
import libPSC
import PSC
import libPlan

## contiennent les variables et les contraintes
VARS = PSC.Variables()
CONTS = PSC.Contraintes()

## contient la liste de tous les etats
ETATS = []


## Une contrainte d'axiome de cadre pour un etat et une proposition donnes
class ContrainteAxiomeCadre(libPSC.Contrainte):

    ## \var varPre
    # Variable correspondant a la proposition au debut de l'etat

    ## \var varPost
    # Variable correspondant a la proposition a la fin de l'etat
Beispiel #8
0
def run( algo, grille ):

	# des bugs, oops, debug
	print "|+| Chargement du probleme"
	
	# variable globales
	global PROBLEME
	
	# allez-vous choisir la facile grille A ?
	if grille=="A":
		PROBLEME=[[9,X,X,X,X,X,X,X,2], 
			   [3,X,7,1,X,X,4,X,8],
			   [X,1,X,X,5,4,X,6,X],
			   [X,X,1,X,X,X,X,7,X],
			   [X,X,4,X,X,X,9,X,X],
			   [X,2,X,X,X,X,8,X,X],
			   [X,8,X,3,2,X,X,4,X],
			   [7,X,3,X,X,6,2,X,1],
			   [4,X,X,X,X,X,X,X,5]]
			   
	# ou la diabolique grille B ?
	elif grille=="B":
		PROBLEME=[[X,X,X,X,X,X,X,X,X], 
				[X,X,7,8,3,X,9,X,X],
				[X,X,5,X,X,2,6,4,X],
				[X,X,2,6,X,X,X,7,X],
				[X,4,X,X,X,X,X,8,X],
				[X,6,X,X,X,3,2,X,X],
				[X,2,8,4,X,X,5,X,X],
				[X,X,X,X,9,6,1,X,X],
				[X,X,X,X,X,X,X,X,X]]
			   
	# ou encore une autre ?
	else:
		print "|-| Grille" , grille, "non definie"
	
	# variables globales
	global VARS
	global CONTS
	
	# obtient les variables et contraintes du PSC
	VARS = PSC.Variables()
	CONTS = PSC.Contraintes()
	
	# initialisation de la grille
	print "|+| Initialisation de la grille"
	grille = Grille()

	# ajout des contraintes liees a la grille
	print "|+| Ajoute les contraintes"
	grille.genereContraintesLignes()
	grille.genereContraintesColonnes()
	grille.genereContraintesSSGrilles()
	
	# consistance des noeuds
	print "|+| Fait la consistance des noeuds"	
	VARS.consistanceDesNoeuds()
	##print VARS

	# consistance des arcs
	print "|+| Fait la consistance des arcs"
	CONTS.consistanceDesArcs()
	##print CONTS
	
	# re-ordonne les noeuds
	PSC.variableOrdering()
		
	# choisit l'algorithme a executer
	if algo=="FC":
		sol=PSC.forwardChecking( 0, False, True )
	else:
		sol=PSC.backtrack( 0, False, True )
	   
	# imprime la grille une fois l'algorithme lance
	print grille