-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkitchen assistant model.lisp
2747 lines (2407 loc) · 44 KB
/
kitchen assistant model.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; -*- coding: iso-8859-1; mode: Lisp; indent-tabs-mode: nil; -*-
; ===================================================================
; Halbrügge, M., Quade, M. & Engelbrecht, K.-P. (2015). How can
; Cognitive Modeling Benefit from Ontologies? Evidence from the HCI
; Domain. In Bieger, J., Goertzel, B. & Potapov, A. (Eds.) Artificial
; General Intelligence 2015, (pp. 261-271). Berlin: Springer.
; DOI: http://dx.doi.org/10.1007/978-3-319-21365-1_27
; -------------------------------------------------------------------
; Abstract: Cognitive modeling as a method has proven successful at
; reproducing and explaining human intelligent behavior in specific
; laboratory situations, but still struggles to produce more general
; intelligent capabilities. A promising strategy to address this
; weakness is the addition of large semantic resources to cognitive
; architectures. We are investigating the usefulness of this approach
; in the context of human behavior during software use. By adding world
; knowledge from a Wikipedia-based ontology to a model of human sequential
; behavior, we achieve quantitatively and qualitatively better fits
; to human data.The combination of model and ontology yields additional
; insights that cannot be explained by the model or the ontology alone.
; ===================================================================
; HOW TO RUN
; The model depends on the "lean embedded lisp" sub-project of ACT-CV
; http://act-cv.sourceforge.net/
; If you want to use it without ACT-CV, you need to fill the visicon
; and audicon and handle clicks and shouts by yourself.
; ===================================================================
; Copyright (c) 2015 Marc Halbruegge ([email protected])
#|
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License version 2.1 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|#
(defun set-buffer-only (event)
(eq (evt-action event) 'set-buffer-chunk))
; :trace-filter production-firing-only
(defun on-chunk-add (chnk)
(let ((slotnames (chunk-type-slot-names-fct (chunk-chunk-type-fct chnk))))
(if (find 'INFO slotnames)
(let ((slot (chunk-slot-value-fct chnk 'INFO)))
(if slot
(let ((dm (get-module declarative)))
;(if (gethash (hash-chunk-contents slot) (dm-chunk-hash-table dm))
(if (dm-fct (list slot))
(progn
;(format t "CHUNK ADD ~W ~W ~W ~%" chnk slot (get-base-level-fct (list slot)))
(set-base-levels-fct (list (list chnk (max 5 (exp (car (get-base-level-fct (list slot))))))))
;(sdp-fct (list slot :reference-count))
;(sdp-fct (list chnk :reference-count))
)
(progn
(format t "NOT FOUND: ~W ~%" slot)
;(merge-chunk-into-dm (get-module declarative) nil slot t)
;(merge-dm-fct (list (list slot 'isa 'chunk)))
(add-chunk-into-dm dm slot)
(set-base-levels-fct (list (list slot 5)(list chnk 5)))
)
)
)
)
)
(set-base-levels-fct (list (list chnk 5))))
)
;(format t "INFO-SLOT ~W~%" (chunk-slot-value-fct chnk 'INFO))
;(sdp-fct (list chnk :reference-count))
)
(clear-all)
(define-model masp-cooking
; :egs utility noise
; :iu initial utility (user defined productions)
; :nu initial utility (learned productions)
; :epl production compilation
; :esc decl mem activation
; :er random chunk if several match
; :bll [.5] base level learning -> time dependent activation decay, higher value means faster decay
; :blc [0.0] base level activation -> constant to be added to the activation computation for every chunk
; :mas [2] spreading activation, bigger means more added activation is possible
; :mp [1] partial matching, bigger means similarity is more important
; :ans activation noise
; :rt [0] retrieval threshold -> min activation
; :nsji allow/warn negative values in the fan calculation?
; :act activation trace
; :cursor-noise [nil] mouse cursor noise
(sgp :v nil :trace-filter production-firing-only :trace-detail medium :show-focus nil
:iu 0 :egs .5 :ul t
:epl nil
:imaginal-activation 1.0
:aural-activation 1.0
:mp nil
:mas 6
:esc t
:bll .1 :blc .75
:er t :ans nil :nsji nil :act nil
:chunk-add-hook on-chunk-add
:cursor-noise nil)
; allow parametrization before declarative mem is being filled
(eval (read-from-string (EvalToString "(PARENT-SGP)")))
(chunk-type recipe main prev info action order state worldmark)
(chunk-type meal main s1 s2 s3 s4) ; put some info about the task into the imaginal buffer
(chunk-type mealslot name)
(chunk-type number)
(chunk-type countorder n1 n2)
(add-dm
(init isa chunk)
(start isa chunk)
(try-retrieve isa chunk)
(retrieve-loc isa chunk)
(find isa chunk)
(attending isa chunk)
(encoding isa chunk)
(find-next isa chunk)
(prepare-mouse isa chunk)
(wait-click isa chunk)
(retrieve-next isa chunk)
(tstimag1 isa chunk)
(tstimag2 isa chunk)
(tstimag3 isa chunk)
(tstimag4 isa chunk)
(RE-RETRIEVE isa chunk)
(check-world-start isa chunk)
(CHECK-WORLD-SEARCH isa chunk)
(STOPPING isa chunk)
(RETRIEVE-ORDER isa chunk)
(CHECK-WORLD-TRY isa chunk)
(CHECK-WORLD-IMAG isa chunk)
(SEARCH-WORLD-IMAG isa chunk)
(s1 isa mealslot name s1)(s2 isa mealslot name s2)(s3 isa mealslot name s3)(s4 isa mealslot name s4)
(one isa number)
(two isa number)
(three isa number)
(four isa number)
(five isa number)
(six isa number)
(seven isa number)
(eight isa number)
(nine isa number)
(ten isa number)
(eleven isa number)
(twelve isa number)
(thirteen isa number)
(fourteen isa number)
(fifteen isa number)
(nilone isa countorder n2 one)
(onetwo isa countorder n1 one n2 two)
(twothree isa countorder n1 two n2 three)
(threefour isa countorder n1 three n2 four)
(fourfive isa countorder n1 four n2 five)
(fivesix isa countorder n1 five n2 six)
(sixseven isa countorder n1 six n2 seven)
(seveneight isa countorder n1 seven n2 eight)
(eightnine isa countorder n1 eight n2 nine)
(nineten isa countorder n1 nine n2 ten)
(teneleven isa countorder n1 ten n2 eleven)
(eleventwelve isa countorder n1 eleven n2 twelve)
(twelvethirteen isa countorder n1 twelve n2 thirteen)
(thirfourteen isa countorder n1 thirteen n2 fourteen)
(fourfivteen isa countorder n1 fourteen n2 fifteen)
(GO isa chunk)
(goal isa recipe state init)
(push isa chunk)(on isa chunk)(off isa chunk)
(end-of-trial isa chunk)(ask-experimenter isa chunk)
)
(sdp :reference-count 5)
; set-similarities: 0 -> maximum similarity; -1 -> maximum difference
(defun simset100 (l)
(if (cadr l)
(progn (set-similarities-fct (list (list (car l)(cadr l) -1)))
(simset100 (cdr l)))))
(defun simset050 (l)
(if (cadr l)
(progn (set-similarities-fct (list (list (car l)(cadr l) -.5)))
(simset050 (cdr l)))))
(defun simset025 (l)
(if (cadr l)
(progn (set-similarities-fct (list (list (car l)(cadr l) -.25)))
(simset025 (cdr l)))))
(defun simset (l v)
(if (cadr l)
(progn (set-similarities-fct (list (list (car l)(cadr l) v)))
(simset (cdr l) v))))
(defun simset2ndorder (l)
(if (caddr l)
(progn (set-similarities-fct (list (list (car l)(caddr l) -.75)))
(simset2ndorder (cdr l)))))
(let ((nums '(one two three four five six seven eight nine ten eleven twelve thirteen fourteen))
(orders '(nilone onetwo twothree threefour fourfive fivesix sixseven seveneight eightnine nineten teneleven eleventwelve twelvethirteen thirfourteen fourfivteen))
;(entities '(push on off end-of-trial ask-experimenter s1 s2 s3 s4))
)
(progn
(sdp-fct (list nums :reference-count 20000))
(sdp-fct (list orders :reference-count 10000))
;(sdp-fct (list entities :reference-count 20000))
;(simset nums)
;(simset orders)
))
(eval (read-from-string (EvalToString "(PARENT-SDP)")))
(p start-trial
=goal>
isa recipe
state start
main =meal
=imaginal>
isa meal
==>
;+imaginal> =meal
=imaginal> ;keep it in!
=goal>
state find ; find it without using decl mem
;!eval! (dm)
;!eval! (pprint-chunks-fct (list =imaginal))
)
(p find-actual-object
=goal>
isa recipe
state find
info =val
==>
+visual-location>
isa visual-location
value =val
=goal>
state attending
)
(p attend-object
=goal>
isa recipe
state attending
; bind it to be able to move the attention
=visual-location>
isa visual-location
?visual>
state free
==>
+visual>
isa move-attention
screen-pos =visual-location
=goal>
state encoding
)
#|
; give up - todo: re-retrieve and re-start (or scan the gui)
(p find-object-failure-giveup
=goal>
isa recipe
state attending
info =val
?visual-location>
state error
;!bind! =str (format nil "OOPS_~W" =val)
==>
+vocal>
isa speak
string "OOPS1"
=goal> init ; overwrite to avoid strengthening
-goal>
-imaginal>
)
|#
(p find-object-failure-first
=goal>
isa recipe
state attending
prev nil
?visual-location>
state error
==>
=goal>
state check-world-start
worldmark nil
#|
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS0"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
|#
)
; don't use order for now (breaks for "Habe ich")
(p find-object-failure-retry
=goal>
isa recipe
state attending
info =curstep
prev =prevstep
main =trialname
?visual-location>
state error
==>
+retrieval>
isa recipe
info =prevstep
main =trialname
=goal>
state re-retrieve
;!eval! (print-visicon)
;!output! (re-retrieve =prevstep cur =curstep)
)
; go for a knowledge in the world strategy
(p find-object-failure-try-world
=goal>
isa recipe
state attending
info =curstep
prev =prevstep
main =trialname
?visual-location>
state error
==>
=goal>
state check-world-start
worldmark nil
)
(p next-step-re-retrieve
=goal>
isa recipe
main =rec
prev =val
state re-retrieve
=retrieval>
isa recipe
main =rec
prev =prev
info =val
action =a
order =o
; experimenter is not talking to me
?aural-location>
state free
buffer empty
==>
; try =goal instead of +goal to avoid strengthening
=goal>
main =rec
prev =prev
info =val
action =a
order =o
state start
;!output! (retry goal =val)
)
; could not re-retrieve correctly
#|
(p next-step-re-retrieve-err
=goal>
isa recipe
main =rec
prev =prev
state re-retrieve
=retrieval>
isa recipe
main =rec
- info =prev
info =errprev
; experimenter is not talking to me
?aural-location>
state free
buffer empty
==>
+vocal>
isa speak
string "OOPS5"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
;!output! (re-retrieve error =prev =errprev)
)
|#
(p next-step-re-retrieve-err-try-world
=goal>
isa recipe
main =rec
info =curstep
prev =prev
state re-retrieve
=retrieval>
isa recipe
main =rec
- info =prev
info =errprev
; experimenter is not talking to me
?aural-location>
state free
buffer empty
==>
=goal>
state check-world-start
worldmark nil
)
; could not re-retrieve correctly
(p next-step-re-retrieve-err2
=goal>
isa recipe
main =rec
prev =prev
state re-retrieve
=retrieval>
isa recipe
- main =rec
info =prev
; experimenter is not talking to me
?aural-location>
state free
buffer empty
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS6"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
)
; could not re-retrieve correctly
(p next-step-re-retrieve-err3
=goal>
isa recipe
main =rec
prev =prev
state re-retrieve
=retrieval>
isa recipe
- main =rec
- info =prev
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS7"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
)
; experimenter *is* talking to me
(p next-step-stop-it
=goal>
isa recipe
=aural-location>
isa audio-event
?aural>
state free
==>
+aural>
isa sound
event =aural-location
=goal>
state stopping
;!eval! (print-audicon)
)
; experimenter *is* talking to me
(p next-step-stop-it2
=goal>
isa recipe
state stopping
=aural>
isa sound
kind word
content "STOP"
?vocal>
state free
==>
+vocal>
isa speak
string "STOPPED"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
;!eval! (print-audicon)
)
(p next-step-re-retrieve2
=goal>
isa recipe
main =rec
info =prev
state re-retrieve
=retrieval>
isa recipe
main =rec
prev nil
info =val
action =a
order =o
==>
=goal>
;isa recipe
main =rec
prev nil
info =val
action =a
order =o
state start
!output! (retry goal =val)
)
; give up - todo: re-retrieve and re-start (or scan the gui)
(p find-object-final-giveup
=goal>
isa recipe
state re-retrieve
?retrieval>
state error
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS4"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
)
; give up - todo: re-retrieve and re-start
; not reached currently
(p encode-object-failure
=goal>
isa recipe
state encoding
?visual>
state error
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS2"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
)
; give up - todo: re-retrieve and re-start
; not reached currently
(p encode-search-failure
=goal>
isa recipe
state encoding
info =val
=visual>
isa text
- value =val
?vocal>
state free
==>
+vocal>
isa speak
string "OOPS3"
=goal> init ; overwrite to avoid strengthening
-goal>
=imaginal> init
-imaginal>
)
(p encode-obj-need-on
=goal>
isa recipe
state encoding
action on
info =val
=visual>
isa text
value =val
screen-pos =pos
color black-white
?manual>
state free
==>
=goal>
state prepare-mouse
+manual>
isa move-cursor
loc =pos
)
(p encode-obj-already-on
=goal>
isa recipe
state encoding
action on
order =order
=visual>
isa text
value =val
- color black-white
==>
+retrieval>
isa countorder
n1 =order
:recently-retrieved nil
=goal>
state retrieve-order
)
(p encode-obj-need-off
=goal>
isa recipe
state encoding
action off
info =val
=visual>
isa text
value =val
screen-pos =pos
- color black-white
?manual>
state free
==>
=goal>
state prepare-mouse
+manual>
isa move-cursor
loc =pos
)
(p encode-obj-already-off
=goal>
isa recipe
state encoding
action off
order =order
=visual>
isa text
value =val
color black-white
==>
+retrieval>
isa countorder
n1 =order
:recently-retrieved nil
=goal>
state retrieve-order
)
; Todo: don't use the order
(p encode-obj-push
=goal>
isa recipe
state encoding
action push
info =val
=visual>
isa text
value =val
screen-pos =pos
?manual>
state free
==>
=goal>
state prepare-mouse
+manual>
isa move-cursor
loc =pos
;!output! (push =val)
)
(p click-text
=goal>
isa recipe
state prepare-mouse
?manual>
state free
==>
=goal>
state tstimag1
+manual>
isa click-mouse
)
(p test-imaginal-1
=goal>
isa recipe
state tstimag1
=imaginal>
isa meal
s1 nil
==>
=imaginal>
=goal>
state tstimag2
)
(p test-imaginal-2
=goal>
isa recipe
state tstimag2
=imaginal>
isa meal
s2 nil
==>
=imaginal>
=goal>
state tstimag3
)
(p test-imaginal-3
=goal>
isa recipe
state tstimag3
=imaginal>
isa meal
s3 nil
==>
=imaginal>
=goal>
state tstimag4
)
(p test-imaginal-4
=goal>
isa recipe
state tstimag4
=imaginal>
isa meal
s4 nil
==>
=imaginal>
=goal>
state wait-click
)
(p test-imaginal-1-mismatch
=goal>
isa recipe
info =info
state tstimag1
=imaginal>
isa meal
- s1 =info
s1 =imag
==>
=imaginal>
=goal>
state tstimag2
;!output! (IMAG =imag)
)
(p test-imaginal-2-mismatch
=goal>
isa recipe
info =info
state tstimag2
=imaginal>
isa meal
- s2 =info
s2 =imag
==>
=imaginal>
=goal>
state tstimag3
;!output! (IMAG =imag)
)
(p test-imaginal-3-mismatch
=goal>
isa recipe
info =info
state tstimag3
=imaginal>
isa meal
- s3 =info
s3 =imag
==>
=imaginal>
=goal>
state tstimag4
;!output! (IMAG =imag)
)
(p test-imaginal-4-mismatch
=goal>
isa recipe
info =info
state tstimag4
=imaginal>
isa meal
- s4 =info
s4 =imag
==>
=imaginal>
=goal>
state wait-click
;!output! (IMAG =imag)
)
(p test-imaginal-1-match
=goal>
isa recipe
info =info
state tstimag1
=imaginal>
isa meal
s1 =info
==>
=imaginal>
s1 nil
=goal>
state wait-click
)
(p test-imaginal-2-match
=goal>
isa recipe
info =info
state tstimag2
=imaginal>
isa meal
s2 =info
==>
=imaginal>
s2 nil
=goal>
state wait-click
)
(p test-imaginal-3-match
=goal>
isa recipe
info =info
state tstimag3
=imaginal>
isa meal
s3 =info
==>
=imaginal>
s3 nil
=goal>
state wait-click
)
(p test-imaginal-4-match
=goal>
isa recipe
info =info
state tstimag4
=imaginal>
isa meal
s4 =info
==>
=imaginal>
s4 nil
=goal>
state wait-click
)
(p after-click-mouse
=goal>
isa recipe
state wait-click
order =order
?manual>
state free
==>
+retrieval>
isa countorder
n1 =order
:recently-retrieved nil
=goal>
state retrieve-order
)
#|
; don't use the order -> will create errors
(p after-click-mouse-2
=goal>
isa recipe
state wait-click
main =rec
info =step
?manual>
state free
==>
+retrieval>
isa recipe
main =rec
prev =step
:recently-retrieved nil
=goal>
state retrieve-next
)
|#
(p retrieved-order
=goal>
isa recipe
state retrieve-order
main =rec
info =step
=retrieval>
isa countorder
n2 =order
==>
+retrieval>
isa recipe
main =rec
prev =step
- info =step
order =order
:recently-retrieved nil
=goal>