summaryrefslogtreecommitdiff
path: root/modeling
diff options
context:
space:
mode:
Diffstat (limited to 'modeling')
-rw-r--r--modeling/prod_addition.py309
-rw-r--r--modeling/prod_comp.py119
-rw-r--r--modeling/prod_multi.py156
-rw-r--r--modeling/prod_numbers.py38
-rw-r--r--modeling/todo.org2
5 files changed, 354 insertions, 270 deletions
diff --git a/modeling/prod_addition.py b/modeling/prod_addition.py
index b96820c..a56fc73 100644
--- a/modeling/prod_addition.py
+++ b/modeling/prod_addition.py
@@ -14,10 +14,11 @@ def addition(Model):
arg1 =num1
arg2 =num2
ones_ans None
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
- ones_ans busy
+retrieval>
isa math_op
op add
@@ -46,14 +47,15 @@ def addition(Model):
=g>
isa math_goal
op done
- +imaginal>
- isa math_op
- op add
- arg1 =num1
- arg2 =num2
result =result
+ +imaginal>
+ isa math_op
+ op add
+ arg1 =num1
+ arg2 =num2
+ result =result
~retrieval>
- """
+ """,
)
prods.append(add_retrieve_success)
@@ -64,66 +66,27 @@ def addition(Model):
=g>
isa math_goal
op add
- arg1 =num1
- arg2 =num2
+ ones1 =num1
+ ones2 =num2
+ ones_carry ~busy
+ tens_carry ~busy
+ tens_ans ~busy
+ hundreds_ans ~busy
?retrieval>
state error
==>
- ~retrieval>
- +retrieval>
- isa number
- number =num1
- ~retrieval>
- +retrieval>
- isa number
- number =num2
- """
- )
- prods.append(add_retrieve_failure)
-
- add_expand_arg1 = Model.productionstring(
- name="number_expand_arg1",
- string="""
=g>
isa math_goal
+ ones_ans busy
+ +retrieval>
+ isa math_op
op add
- arg1 =num
- =retrieval>
- isa number
- number =num
- ones =one
- tens =ten
- hundreds =hun
- ==>
- =g>
- ones1 =one
- tens1 =ten
- hundreds1 =hun
- """
- )
- prods.append(add_expand_arg1)
+ arg1 =num1
+ arg2 =num2
- add_expand_arg2 = Model.productionstring(
- name="number_expand_arg2",
- string="""
- =g>
- isa math_goal
- op add
- arg2 =num
- =retrieval>
- isa number
- number =num
- ones =one
- tens =ten
- hundreds =hun
- ==>
- =g>
- ones2 =one
- tens2 =ten
- hundreds2 =hun
- """
+ """,
)
- prods.append(add_expand_arg2)
+ prods.append(add_retrieve_failure)
add_ones = Model.productionstring(
name="add_ones",
@@ -136,6 +99,7 @@ def addition(Model):
ones2 =num2
=retrieval>
isa math_op
+ op add
arg1 =num1
arg2 =num2
result =result
@@ -143,7 +107,7 @@ def addition(Model):
=g>
isa math_goal
ones_ans =result
- carry busy
+ ones_carry busy
+retrieval>
isa math_op
op add
@@ -161,7 +125,7 @@ def addition(Model):
op add
tens1 =num1
tens2 =num2
- carry busy
+ ones_carry busy
ones_ans =ones
=retrieval>
isa math_op
@@ -173,9 +137,10 @@ def addition(Model):
=g>
isa math_goal
op add
- carry 1
+ ones_carry 1
tens_ans busy
ones_ans =remainder
+ ~retrieval>
+retrieval>
isa math_op
op add
@@ -194,13 +159,14 @@ def addition(Model):
tens1 =num1
tens2 =num2
ones_ans =ones
- carry busy
+ ones_carry busy
+ tens_ans None
?retrieval>
state error
==>
=g>
isa math_goal
- carry None
+ ones_carry None
tens_ans busy
~retrieval>
+retrieval>
@@ -211,31 +177,33 @@ def addition(Model):
)
prods.append(no_carry_ones)
- add_tens_done = Model.productionstring(
- name="add_tens_done",
+ add_tens = Model.productionstring(
+ name="add_tens",
string="""
=g>
isa math_goal
op add
tens_ans busy
- carry None
+ tens1 =num1
+ tens2 =num2
=retrieval>
isa math_op
op add
+ arg1 =num1
+ arg2 =num2
result =sum
==>
=g>
isa math_goal
tens_ans =sum
- carry busy
+ tens_carry busy
+retrieval>
isa math_op
op add
arg1 10
result =sum
- """,
- )
- prods.append(add_tens_done)
+ """,)
+ prods.append(add_tens)
add_tens_carry = Model.productionstring(
name="add_tens_carry",
@@ -243,30 +211,48 @@ def addition(Model):
=g>
isa math_goal
op add
- tens_ans busy
+ tens_ans =ten_ans
tens1 =num1
tens2 =num2
- carry 1
- =retrieval>
- isa math_op
- op add
- result =sum
- arg1 =num1
- arg2 =num2
+ ones_carry 1
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
- carry None
- ~retrieval>
+retrieval>
isa math_op
op add
arg1 1
- arg2 =sum
+ arg2 =ten_ans
""",
)
prods.append(add_tens_carry)
+ add_tens_carry_done = Model.productionstring(
+ name="add_tens_carry_done",
+ string="""
+ =g>
+ isa math_goal
+ op add
+ tens_ans =ten_ans
+ tens1 =num1
+ tens2 =num2
+ ones_carry 1
+ =retrieval>
+ isa math_op
+ op add
+ arg1 1
+ arg2 =ten_ans
+ result =result
+ ==>
+ =g>
+ isa math_goal
+ tens_ans =result
+ ones_carry None
+ """,
+ )
+ prods.append(add_tens_carry_done)
process_carry_tens = Model.productionstring(
name="process_carry_tens",
@@ -274,9 +260,7 @@ def addition(Model):
=g>
isa math_goal
op add
- hundreds1 =num1
- hundreds2 =num2
- carry busy
+ tens_carry busy
tens_ans =tens
=retrieval>
isa math_op
@@ -288,14 +272,9 @@ def addition(Model):
=g>
isa math_goal
op add
- carry 1
- hundreds_ans busy
+ tens_carry 1
tens_ans =remainder
- +retrieval>
- isa math_op
- op add
- arg1 =num1
- arg2 =num2
+ ~retrieval>
""",
)
prods.append(process_carry_tens)
@@ -306,34 +285,53 @@ def addition(Model):
=g>
isa math_goal
op add
- hundreds1 =num1
- hundreds2 =num2
tens_ans =tens
- carry busy
+ tens_carry busy
?retrieval>
state error
==>
=g>
isa math_goal
- carry None
- hundreds_ans busy
+ tens_carry None
~retrieval>
+ """,
+ )
+ prods.append(no_carry_tens)
+
+ add_hundreds_start = Model.productionstring(
+ name="add_hundreds_start",
+ string="""
+ =g>
+ isa math_goal
+ op add
+ ones_carry None
+ tens_ans ~None
+ hundreds1 =hun1
+ hundreds2 =hun2
+ ?retrieval>
+ state free
+ ==>
+ =g>
+ isa math_goal
+ hundreds_ans busy
+retrieval>
isa math_op
- arg1 =num1
- arg2 =num2
+ op add
+ arg1 =hun1
+ arg2 =hun2
""",
)
- prods.append(no_carry_tens)
+ prods.append(add_hundreds_start)
- add_hundreds_done = Model.productionstring(
- name="add_hundreds_done",
+ add_hundreds = Model.productionstring(
+ name="add_hundreds",
string="""
=g>
isa math_goal
op add
hundreds_ans busy
- carry None
+ tens_carry None
+ ones_carry None
=retrieval>
isa math_op
op add
@@ -341,11 +339,12 @@ def addition(Model):
==>
=g>
isa math_goal
- op add_result
+ op add_done
hundreds_ans =sum
+ ~retrieval>
""",
)
- prods.append(add_hundreds_done)
+ prods.append(add_hundreds)
add_hundreds_carry = Model.productionstring(
name="add_hundreds_carry",
@@ -356,7 +355,8 @@ def addition(Model):
hundreds_ans busy
hundreds1 =num1
hundreds2 =num2
- carry 1
+ tens_carry 1
+ ones_carry None
=retrieval>
isa math_op
op add
@@ -366,7 +366,7 @@ def addition(Model):
==>
=g>
isa math_goal
- carry None
+ tens_carry None
~retrieval>
+retrieval>
isa math_op
@@ -377,58 +377,58 @@ def addition(Model):
)
prods.append(add_hundreds_carry)
- add_result_contract = Model.productionstring(
- name="add_result_contract",
- string="""
- =g>
- isa math_goal
- op add_result
- ones_ans =one
- tens_ans =ten
- hundreds_ans =hun
- ==>
- ~retrieval>
- +retrieval>
- isa number
- ones =one
- tens =ten
- hundreds =hun
- """
- )
- prods.append(add_result_contract)
+ # add_result_contract = Model.productionstring(
+ # name="add_result_contract",
+ # string="""
+ # =g>
+ # isa math_goal
+ # op add_result
+ # ones_ans =one
+ # tens_ans =ten
+ # hundreds_ans =hun
+ # ==>
+ # ~retrieval>
+ # +retrieval>
+ # isa number
+ # ones =one
+ # tens =ten
+ # hundreds =hun
+ # """
+ # )
+ # prods.append(add_result_contract)
- add_contract_done = Model.productionstring(
- name="add_contract_done",
- string="""
- =g>
- isa math_goal
- op add_result
- arg1 =arg1
- arg2 =arg2
- ones_ans =one
- tens_ans =ten
- hundreds_ans =hun
- =retrieval>
- isa number
- number =result
- ones =one
- tens =ten
- hundreds =hun
- ==>
- =g>
- isa math_goal
- op add
- result =result
- """
- )
- prods.append(add_contract_done)
+ # add_contract_done = Model.productionstring(
+ # name="add_contract_done",
+ # string="""
+ # =g>
+ # isa math_goal
+ # op add_result
+ # arg1 =arg1
+ # arg2 =arg2
+ # ones_ans =one
+ # tens_ans =ten
+ # hundreds_ans =hun
+ # =retrieval>
+ # isa number
+ # number =result
+ # ones =one
+ # tens =ten
+ # hundreds =hun
+ # ==>
+ # =g>
+ # isa math_goal
+ # op add
+ # result =result
+ # """
+ # )
+ # prods.append(add_contract_done)
add_done = Model.productionstring(
name="add_done",
string="""
=g>
isa math_goal
- op add
+ op add_done
arg1 =arg1
arg2 =arg2
result ~None
@@ -443,7 +443,8 @@ def addition(Model):
=g>
isa math_goal
op done
- """
- )
+ ~retrieval>
+ """,
+ )
prods.append(add_done)
return prods
diff --git a/modeling/prod_comp.py b/modeling/prod_comp.py
index 5bf30c9..8bf53ce 100644
--- a/modeling/prod_comp.py
+++ b/modeling/prod_comp.py
@@ -4,24 +4,42 @@
def greater_than(Model):
prods = []
- arg1_greater = Model.productionstring(
- name="arg1_greater",
+ greater_done = Model.productionstring(
+ name="greater_done",
string="""
=g>
isa math_goal
- task arg1
- =imaginal>
+ op greater_done
+ result ~None
+ result =result
+ arg1 =arg1
+ arg2 =arg2
+ ==>
+ =g>
+ isa math_goal
+ op done
+ +imaginal>
isa math_op
op greater
+ result =result
+ arg1 =arg1
+ arg2 =arg2
+ """
+ )
+
+ arg1_greater = Model.productionstring(
+ name="arg1_greater",
+ string="""
+ =g>
+ isa math_goal
+ op greater_arg1
hundreds1 =hun1
tens1 =ten1
ones1 =one1
==>
=g>
isa math_goal
- task done
- =imaginal>
- isa math_op
+ op greater_done
hundreds_ans =hun1
tens_ans =ten1
ones_ans =one1
@@ -34,19 +52,14 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task arg2
- =imaginal>
- isa math_op
- op greater
+ op greater_arg2
hundreds2 =hun2
tens2 =ten2
ones2 =one2
==>
=g>
isa math_goal
- task done
- =imaginal>
- isa math_op
+ op greater_done
hundreds_ans =hun2
tens_ans =ten2
ones_ans =one2
@@ -59,17 +72,16 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task calc
- =imaginal>
- isa math_op
op greater
hundreds1 =hun1
hundreds2 ~=hun1
hundreds2 =hun2
+ hundreds_ans None
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
- task comp
+retrieval>
isa math_op
op greater
@@ -84,19 +96,17 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task calc
- =imaginal>
- isa math_op
op greater
hundreds1 =hun1
hundreds2 =hun1
tens1 =ten1
tens2 ~=ten1
tens2 =ten2
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
- task comp
+retrieval>
isa math_op
op greater
@@ -111,9 +121,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task calc
- =imaginal>
- isa math_op
op greater
hundreds1 =hun1
hundreds2 =hun1
@@ -122,10 +129,11 @@ def greater_than(Model):
ones1 =one1
ones2 ~=one1
ones2 =one2
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
- task comp
+retrieval>
isa math_op
op greater
@@ -140,9 +148,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
hundreds1 =hun1
hundreds2 =hun2
@@ -155,7 +160,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg1
+ op greater_arg1
""",
)
prods.append(comp_result_hun_greater_arg1)
@@ -165,9 +170,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
hundreds1 =hun1
hundreds2 =hun2
@@ -180,7 +182,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg2
+ op greater_arg2
""",
)
prods.append(comp_result_hun_greater_arg2)
@@ -190,9 +192,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
tens1 =ten1
tens2 =ten2
@@ -205,7 +204,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg1
+ op greater_arg1
""",
)
prods.append(comp_result_ten_greater_arg1)
@@ -215,9 +214,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
tens1 =ten1
tens2 =ten2
@@ -230,7 +226,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg2
+ op greater_arg2
""",
)
prods.append(comp_result_ten_greater_arg2)
@@ -240,9 +236,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
ones1 =one1
ones2 =one2
@@ -255,7 +248,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg1
+ op greater_arg1
""",
)
prods.append(comp_result_one_greater_arg1)
@@ -265,9 +258,6 @@ def greater_than(Model):
string="""
=g>
isa math_goal
- task comp
- =imaginal>
- isa math_op
op greater
ones1 =one1
ones2 =one2
@@ -280,7 +270,7 @@ def greater_than(Model):
==>
=g>
isa math_goal
- task arg2
+ op greater_arg2
""",
)
prods.append(comp_result_one_greater_arg2)
@@ -291,6 +281,29 @@ def greater_than(Model):
def less_than(Model):
prods = []
+ less_done = Model.productionstring(
+ name="less_done",
+ string="""
+ =g>
+ isa math_goal
+ op less_done
+ result ~None
+ result =result
+ arg1 =arg1
+ arg2 =arg2
+ ==>
+ =g>
+ isa math_goal
+ op done
+ +imaginal>
+ isa math_op
+ op less
+ result =result
+ arg1 =arg1
+ arg2 =arg2
+ """
+ )
+
arg1_less = Model.productionstring(
name="arg1_less",
string="""
@@ -353,6 +366,8 @@ def less_than(Model):
hundreds1 =hun1
hundreds2 ~=hun1
hundreds2 =hun2
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
@@ -380,6 +395,8 @@ def less_than(Model):
tens1 =ten1
tens2 ~=ten1
tens2 =ten2
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
@@ -409,6 +426,8 @@ def less_than(Model):
ones1 =one1
ones2 ~=one1
ones2 =one2
+ ?retrieval>
+ state free
==>
=g>
isa math_goal
diff --git a/modeling/prod_multi.py b/modeling/prod_multi.py
index 4b4e7c5..9009f6b 100644
--- a/modeling/prod_multi.py
+++ b/modeling/prod_multi.py
@@ -16,15 +16,12 @@ def multiplication(Model):
# )
# prods.append(switch_mul)
- start_mul = Model.productionstring(
- name="start_mul",
+ mul_start = Model.productionstring(
+ name="mul_start",
string="""
=g>
isa math_goal
op mul
- =imaginal>
- isa math_op
- op mul
arg1 ~0
arg1 ~1
arg2 ~0
@@ -34,25 +31,14 @@ def multiplication(Model):
ones2 =ones
tens2 =tens
hundreds2 =huns
+ mul_counter None
+ ?retrieval>
+ state free
==>
- !g>
- show terminal
- +g>
+ =g>
isa math_goal
- op add
- task mul
- +imaginal>
- isa math_op
- op add
- arg1 =arg
- ones1 =ones
- tens1 =tens
- hundreds1 =huns
- arg2 =arg
- ones2 =ones
- tens2 =tens
- hundreds2 =huns
- mul_counter =mul
+ mul_counter 1
+ result =arg
+retrieval>
isa math_op
op add
@@ -60,66 +46,128 @@ def multiplication(Model):
arg2 =arg
""",
)
- prods.append(start_mul)
+ prods.append(mul_start)
- count_mul = Model.productionstring(
- name="count_mul",
+ mul_step_success = Model.productionstring(
+ name="mul_step_success",
string="""
=g>
isa math_goal
- op add_done
- task mul
- =imaginal>
+ op mul
+ arg1 =mul
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ mul_counter =mul_counter
+ result =result
+ =retrieval>
isa math_op
op add
- mul_counter =counter
+ arg1 =arg
+ arg2 =result
+ result =sum
==>
=g>
isa math_goal
- op count_done
+ result =sum
+retrieval>
isa math_op
op add
- arg1 1
- result =counter
- """
+ arg1 =mul_counter
+ arg2 1
+ """,
)
+ prods.append(mul_step_success)
- step_mul = Model.productionstring(
- name="step_mul",
+ mul_done = Model.productionstring(
+ name="mul_done",
string="""
=g>
isa math_goal
- op count_done
- task mul
- =imaginal>
+ op mul
+ arg1 =arg1
+ arg2 =arg2
+ mul_counter =mul_counter
+ =retrieval>
isa math_op
op add
- hundreds_ans =hun_ans
- tens_ans =ten_ans
- ones_ans =one_ans
- mul_counter =mul_counter
+ arg1 =mul_counter
+ arg2 1
+ result =arg1
+ ==>
+ =g>
+ isa math_goal
+ op done
+ """
+ )
+
+ mul_continue = Model.productionstring(
+ name="mul_continue",
+ string="""
+ =g>
+ isa math_goal
+ op mul
+ arg1 =arg1
+ arg2 =arg2
+ mul_counter =mul_counter
+ result =result
=retrieval>
isa math_op
op add
- result =mul_counter
- arg2 =new_counter
+ arg1 =mul_counter
+ arg2 1
+ result ~=arg1
+ result =counted
==>
=g>
isa math_goal
- op mul
- task mul
- +imaginal>
+ mul_counter =counted
+ +retrieval>
isa math_op
+ op add
+ arg1 =arg2
+ arg2 =result
+ """
+ )
+
+
+ mul_step_failure = Model.productionstring(
+ name="mul_step_failure",
+ string="""
+ =g>
+ isa math_goal
op mul
- arg1 =new_counter
- ones1 =new_counter
- hundreds2 =hun_ans
- tens2 =ten_ans
- ones2 =one_ans
- mul_counter =new_counter
+ arg1 =mul
+ arg2 =arg
+ ones2 =ones
+ tens2 =tens
+ hundreds2 =huns
+ mul_counter =mul_counter
+ result =result
+ ?retrieval>
+ state error
+ ==>
+ =g>
+ isa math_goal
+ nextop mul
+ op add
+ arg1 =arg2
+ arg2 =result
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ ones1 None
+ +retrieval>
+ isa math_op
+ op add
+ arg1 =mul_counter
+ arg2 1
""",
)
- prods.append(step_mul)
+
return prods
diff --git a/modeling/prod_numbers.py b/modeling/prod_numbers.py
index 8bf1ebb..d0c8466 100644
--- a/modeling/prod_numbers.py
+++ b/modeling/prod_numbers.py
@@ -8,10 +8,14 @@ def number(Model):
string="""
=g>
isa math_goal
- op expand
- expand_slot arg1
arg1 =num
+ ones1 None
+ ?retrieval>
+ state free
==>
+ =g>
+ isa math_goal
+ expand_slot arg1
+retrieval>
isa number
number =num
@@ -24,7 +28,6 @@ def number(Model):
string="""
=g>
isa math_goal
- op expand
expand_slot arg1
arg1 =num
=retrieval>
@@ -36,10 +39,10 @@ def number(Model):
==>
=g>
isa math_goal
- op done
ones1 =one
tens1 =ten
hundreds1 =hun
+ ~retrieval>
"""
)
prods.append(number_expand_arg1_done)
@@ -50,10 +53,14 @@ def number(Model):
string="""
=g>
isa math_goal
- op expand
- expand_slot 2arg
arg2 =num
+ ones2 None
+ ?retrieval>
+ state free
==>
+ =g>
+ isa math_goal
+ expand_slot arg2
+retrieval>
isa number
number =num
@@ -66,7 +73,6 @@ def number(Model):
string="""
=g>
isa math_goal
- op expand
expand_slot arg2
arg2 =num
=retrieval>
@@ -78,10 +84,10 @@ def number(Model):
==>
=g>
isa math_goal
- op done
ones2 =one
tens2 =ten
hundreds2 =hun
+ ~retrieval>
"""
)
prods.append(number_expand_arg2_done)
@@ -91,12 +97,20 @@ def number(Model):
string="""
=g>
isa math_goal
- op contract
- expand_slot result
+ result None
+ ones_ans ~None
+ tens_ans ~None
+ hundreds_ans ~None
+ hundreds_ans ~busy
ones_ans =ones
tens_ans =tens
hundreds_ans =huns
+ ?retrieval>
+ state free
==>
+ =g>
+ isa math_goal
+ expand_slot result
+retrieval>
isa number
ones =ones
@@ -111,8 +125,8 @@ def number(Model):
string="""
=g>
isa math_goal
- op contract
expand_slot result
+ result None
ones_ans =ones
tens_ans =tens
hundreds_ans =huns
@@ -125,8 +139,8 @@ def number(Model):
==>
=g>
isa math_goal
- op done
result =num
+ ~retrieval>
"""
)
prods.append(number_contract_result_done)
diff --git a/modeling/todo.org b/modeling/todo.org
index c3cfa70..bdb8435 100644
--- a/modeling/todo.org
+++ b/modeling/todo.org
@@ -6,3 +6,5 @@
** Max of 4 numbers
** Min of 4 numbers
** subgoals, i.e. do addition manually if addition fact not in decmem
+* pyactr
+** if the same multiple Productions possible in a row, ACT-R picks different ones while pyactr picks always the same one. Requires more control logic