create a new problem starting with a old one

imports


In [18]:
import lib.operations as operations
from lib.schemas import *
from lib.subjectRepresentations import *
from lib.textRepresentations import *
from lib.paths import *
from lib.dataManager import *
from lib.optionsFactory import *

create the problem1


In [19]:
schema1=Schema("PoissonEF","PoissonEI",operations.addition,"PoissonGAIN","change")
schema2=Schema("ViandeEF","ViandeEI",operations.addition,"ViandeGAIN","change")
struct=ProblemStructure()
struct.addSchema(schema1)
struct.addSchema(schema2)
struct.addBridgingSchemas(schema1,schema2)
struct.updateObjectSet()

text=Text()
text.addTextInformation(TextInformation(Representation(Quantity("PoissonGAIN","P1"),'Au supermarché, le kilo de poisson a augmenté de 5 euros cette année')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonEF","T1"),'Un kilo de poisson coute maintenant 12 euros.')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonEIminusViandeEI","dEI"),'Au début de l\'année, le kilo de viande coutait le même prix que le kilo de poisson.')))
text.addTextInformation(TextInformation(Representation(Quantity("PoissonGAINminusViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros de moins que le kilo de poisson')))
text.setGoal(TextGoal(Goal('ViandeEF','Combien coute le kilo de viande maintenant?')))

text.getTextInformation(0).addAlternativeRepresentation(Representation(Quantity("PoissonEI","P1"),'Au supermarché, le kilo de poisson était de 5 euros'))
text.getTextInformation(0).addAlternativeRepresentation(Representation(Quantity("PoissonEF","P1"),'Au supermarché, le kilo de poisson coute 5 euros'))
text.getTextInformation(1).addAlternativeRepresentation(Representation(Quantity("PoissonEI","T1"),'Un kilo de poisson était de 12 euros.'))
text.getTextInformation(2).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","dEI"),'Au la fin de l\'année, le kilo de viande coute le même prix que le kilo de poisson.'))
text.getTextInformation(2).addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","dEI"),'Le kilo de viande a augmenté du même prix que le kilo de poisson.'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","-d"),'Le kilo de viande a diminué de 3 euros'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","-d"),'Le kilo de viande a augmenté de 3 euros de plus que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","d"),'Le kilo de viande vaut 3 euros de moins que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","-d"),'Le kilo de viande vaut 3 euros de plus que le kilo de poisson'))
text.getTextInformation(3).addAlternativeRepresentation(Representation(Quantity("ViandeEF","d"),'Le kilo coute 3 euros à la fin'))
probleme1=Problem(struct,text)

Deep copy of problem1


In [20]:
problem2=copy.deepcopy(probleme1)
  • The third text information differs, we create a new one

In [21]:
info3_prime=TextInformation(Representation(Quantity("PoissonEFminusViandeEF","d"),'Le kilo de viande vaut 3 euros de moins que le kilo de poisson'))

In [22]:
info3_prime.addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros'))
info3_prime.addAlternativeRepresentation(Representation(Quantity("ViandeGAIN","-d"),'Le kilo de viande a diminué de 3 euros'))
info3_prime.addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","-d"),'Le kilo de viande a augmenté de 3 euros de plus que le kilo de poisson'))
info3_prime.addAlternativeRepresentation(Representation(Quantity("PoissonGAINminusViandeGAIN","d"),'Le kilo de viande a augmenté de 3 euros de moins que le kilo de poisson'))
info3_prime.addAlternativeRepresentation(Representation(Quantity("PoissonEFminusViandeEF","-d"),'Le kilo de viande vaut 3 euros de plus que le kilo de poisson'))
info3_prime.addAlternativeRepresentation(Representation(Quantity("ViandeEF","d"),'Le kilo coute 3 euros à la fin'))

problem2.text.textInformations[3]=info3_prime
  • The goal is not the same, we change it

In [23]:
problem2.text.setGoal(TextGoal(Goal('ViandeGAIN','De combien le kilo de viande a t-il augmenté ?')))

Last steps : set initial values,and name it


In [24]:
problem2.setInitialValues({"P1":5,"T1":12,"dEI":0,"d":3,"-d":-3})
problem2.name="Tc4p"

In [25]:
upD=Updater(problem2) 
upD.startAsUnderstood() 
c1=IntervalConstraint(['EF','EI'],operations.superiorOrEqualTo0) 
c2=BehavioralConstraint(breakTheOldOne=True)
constraints=[c1,c2]
autoSolver=Solver(upD,constraints)
l=[autoSolver.SOLVER]
autoSolver.generalSequentialSolver(listOfActions=l)
autoSolver.TreePaths.scanTree()
print(autoSolver.TreePaths.treeOutput)


 12 - 5 = 7  (PoissonEI)
	 7 - 0 = 7  (ViandeEI)
		 12 - 3 = 9  (ViandeEF)
			 9 - 7 = 2  (ViandeGAIN)
				(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
			 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 12 - 3 = 9  (ViandeEF)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
	 12 - 3 = 9  (ViandeEF)
		 7 - 0 = 7  (ViandeEI)
			 9 - 7 = 2  (ViandeGAIN)
				(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
			 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
	 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
		 7 - 0 = 7  (ViandeEI)
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 12 - 3 = 9  (ViandeEF)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 5 - 3 = 2  (ViandeGAIN)
			P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 12 - 3 = 9  (ViandeEF)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
 12 - 3 = 9  (ViandeEF)
	 12 - 5 = 7  (PoissonEI)
		 7 - 0 = 7  (ViandeEI)
			 9 - 7 = 2  (ViandeGAIN)
				(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
			 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
	 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
		 12 - 5 = 7  (PoissonEI)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 5 - 3 = 2  (ViandeGAIN)
			P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
 3 - 0 = 3  (PoissonGAINminusViandeGAIN)
	 12 - 5 = 7  (PoissonEI)
		 7 - 0 = 7  (ViandeEI)
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 12 - 3 = 9  (ViandeEF)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 5 - 3 = 2  (ViandeGAIN)
			P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 12 - 3 = 9  (ViandeEF)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
	 5 - 3 = 2  (ViandeGAIN)
		P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
	 12 - 3 = 9  (ViandeEF)
		 12 - 5 = 7  (PoissonEI)
			 7 - 0 = 7  (ViandeEI)
				 9 - 7 = 2  (ViandeGAIN)
					(T1-d)-(T1-P1) : interpretation -> (PoissonEF-PoissonEFminusViandeEF)-((PoissonEF-PoissonGAIN)-PoissonEIminusViandeEI)=ViandeGAIN
				 5 - 3 = 2  (ViandeGAIN)
					P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
			 5 - 3 = 2  (ViandeGAIN)
				P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN
		 5 - 3 = 2  (ViandeGAIN)
			P1-d : interpretation -> PoissonGAIN-(PoissonEFminusViandeEF-PoissonEIminusViandeEI)=ViandeGAIN