!SDML! 4.1 subStandard 6 4.1. scott s.moss@mmu.ac.uk ?Centre for Policy Modelling, Manchester Metropolitan Universityv0 l lists 8 4.1~17 bruce b.edmonds@mmu.ac.uk ?Centre for Policy Modelling, Manchester Metropolitan Universityv .v0 trees 11 4.1: v ~17 v O negonet 23 4.1%* bruce bruce@cfpm.orgv]&w : vtQ 3.4c 3.5 3.6 4.0 4.1 urlAndRedirectingUrl" http" haltInConsequents@ occurrences@ transcripts! errorInAntecedents@ web subStandard 6 Agent numerical safeMultiply Predicate 6 UniversalAgent randomNormalPrimitive lowerCasePrimitive signOf safeInverse randomInteger safeDivide CompositeAgent Number inst backward is ?res 1 / (0.001 + ?num) safeInverse ?res ?num top-level GroundTerm Rand randomNumber ?rn ?term\ is ?ri ?from + (truncated ?rn * (?upTo - ?from + 1)) #randomInteger ?ri ?from ?upTo ?term " 2 args randomInteger ?ri 1 ?upTo ?term randomInteger ?ri ?upTo ?term % top - level String, primitive "to convert string to lower case quickly" clause first unifyWith: (GPCodeHolder lowerCase: ((clause at: 2) unbindUsing: bindings)) bindings: bindings continuation: continuation. ^Unify the first argument with the product of the remaining arguments.
The remaining arguments can be any combination of matrices and numbers (as long as the number of columns in a preceeding matrix equals the number of rows in the following one). The result is a number if all the remaining arguments are numbers; otherwise the result is a matrix. and is ?max (max (absoluteValue ?arg1) (absoluteValue ?arg2))\ (if greater ?max 1.0e100\ is ?result 1.0e100\ is ?result ?arg1 * ?arg2) safeMultiply ?result ?arg1 ?arg2 0 ! - "comment stating purpose of method" clause first unifyWith: (GPCodeHolder nextNormalRandom) bindings: bindings continuation: continuation5 HUnify the first argument with the absolute value of the second argument. Tif greater ?arg 0\ = ?result 1\ (if less ?arg 0\ = ?result -1\ = ?result 0) signOf ?result ?arg 7 ^Unify the first argument with the product of the remaining arguments.
The remaining arguments can be any combination of matrices and numbers (as long as the number of columns in a preceeding matrix equals the number of rows in the following one). The result is a number if all the remaining arguments are numbers; otherwise the result is a matrix. and absoluteValue ?aarg1 ?arg1\ absoluteValue ?aarg2 ?arg2\ (if thereExists (or greater ?aarg1 1.0e100\ less ?aarg2 1.0e-100)\ is ?result 1.0e100 * (signOf ?arg1) * (signOf ?arg2)\ is ?result ?arg1 / ?arg2) safeDivide ?result ?arg1 ?arg2 < : 1 3.6$- bruce b.edmonds@mmu.ac.uk ?Centre for Policy Modelling, Manchester Metropolitan Universityu" : 2 4.1+;CDEv- : 3G,3CDEvd+ : 4G-CDEv帹 : 5 4.1 "7CDEun B replace Predicate lists 8 UniversalAgent listOf lastOf first binarySearchPrimitive binarySearch third withoutDuplicates appendedList replaceInList second notEmpty cummulateList flattened lists fitness Agent List inst}The first list is the second list appended to the third list.
This can be used to join lists together or split them apart. backward true appendedList [] [] bottom Gand appendedList ?restList ?rest\ appended ?list ?firstList ?restList 'appendedList ?list [?firstList | ?rest] " recurse Term true ,third ?third [?first ?second ?third | ?rest] * top-level ) /and length ?list ?len\ index ?list ?len ?item lastOf ?item ?list 0. GroundList5 true withoutDuplicates [] [] 6# =and withoutDuplicates ?rest ?rawRest\ includes ?rest ?first +withoutDuplicates ?rest [?first | ?rawRest] 9 recurse - dup Kand withoutDuplicates ?rest ?rawRest\ notInferred includes ?rest ?first 6withoutDuplicates [?first | ?rest] [?first | ?rawRest] 9 recurse - no dup GroundTerm5C5 :mappedList ?resulltList ?list [?item ?replacement] replace 3replaceInList ?resulltList ?list ?item ?replacement D top ) true 'second ?second [?first ?second | ?rest] J. 55 and isKindOf ?first List\ notInferred isKindOf ?first String\ flattened ?flattenedFirst ?first\ flattened ?flattenedRest ?rest\ appended ?list ?flattenedFirst ?flattenedRest flattened ?list [?first | ?rest] O first is list jand (or notInferred isKindOf ?first List\ isKindOf ?first String)\ flattened ?flattenedRest ?rest 4flattened [?first | ?flattenedRest] [?first | ?rest] R first not list true flattened [] [] R empty ) true first ?first [?first | ?rest] ]. Numberbb true cummulateList [] [] ?cumm c# Fand is ?newCumm ?first + ?cumm\ cummulateList ?restOp ?rest ?newCumm 9cummulateList [?newCumm | ?restOp] [?first | ?rest] ?cumm f' cummulateList ?res ?list 0 cummulateList ?res ?list f. bbbbinarySearchPrimitive ?position ?number ?sortedListOfNumbers
The first argument is unified with its position in the second (a list). primitive "unify the first argument with the maximum depth of tree" clause first unifyWith: (GPCodeHolder findPositionIn: ((clause at: 3) unbindUsing: bindings) of: ((clause at: 2) unbindUsing: bindings)) bindings: bindings continuation: continuationo true notEmpty [?something | ?rest] qH }The first list is the second list appended to the third list.
This can be used to join lists together or split them apart. true appendedList [] [] u# Gand appendedList ?restList ?rest\ appended ?list ?firstList ?restList 'appendedList ?list [?firstList | ?rest] x' b and greater ?length 0\ includes ?sourceList ?item\ is ?lengthMinus ?length - 1\ listOf ?restList ?lengthMinus ?sourceList\ = ?list [?item | ?restList] listOf ?list ?length ?sourceList }' true listOf [] 0 ?sourceList # bbbb5 >and length ?list ?top\ index ?list ?top ?biggest\ max ?max ?biggest ?number\ = ?list [?smallest | ?rest]\ min ?min ?number ?smallest\ appended ?searchListMax ?list [?max]\ appended ?searchList [?min] ?searchListMax\ is ?upper ?top + 1\ binarySearch ?posPlus ?number 1 ?upper ?searchList\ is ?pos ?posPlus - 1 binarySearch ?pos ?number ?list!initiate binary search for number topLevel >and is ?lowerPlus ?lower + 1\ less ?lowerPlus ?upper\ is ?middle (truncated (?lower + ?upper) / 2)\ index ?list ?middle ?value\ (or (and notInferred less ?number ?value\ binarySearch ?pos ?number ?middle ?upper ?list)\ (and less ?number ?value\ binarySearch ?pos ?number ?lower ?middle ?list)) -binarySearch ?pos ?number ?lower ?upper ?list recursive step is ?upper ?lower + 1 /binarySearch ?upper ?number ?lower ?upper ?list bottom step CCCC 5if = ?old ?match\ = ?new ?replacement\ = ?new ?old %replace ?new ?old ?match ?replacement H : 1 3.1b4- bruce b.edmonds@mmu.ac.uk ?Centre for Policy Modelling, Manchester Metropolitan Universityv : 2 3.1b46(v> : 3 3.4a"&v2 : 4 3.4a#53vE~ : 5 4.1-*v : 6 4.1 "9t+ : 7 4.1. scott s.moss@mmu.ac.uk ?Centre for Policy Modelling, Manchester Metropolitan Universityv'f trees 11 Agent labelOf Predicate UniversalAgent allLabels isSubTreeOf maxDepth mappedLeaves includesLeaf isTree subTreeOf modifyBranch nodeListPrimitive isLeaf branches leafOf nodeOf hasLeaf noBranches mappedLabels randomTree maxDepthPrimitive subTree graft randomNodeChoice branch fixedRandomCrossover tree hasBranches allLeaves mappedLeafLabels leafListPrimitive fixedRandomNodeChoice label crossover allLeafLabels fixedRandomTree nodeList inst GroundList NumbernoBranches ?num ?tree backward length ?branches ?num $noBranches ?num [?label | ?branches] 3 top-level 0/0/0/03graft ?resultTree ?originalTree ?posList ?graftTree2 and branch ?branch ?firstPos ?originalTree\ graft ?resultSubTree ?branch ?restPosList ?graftTree\ modifyBranch ?resultTree ?originalTree ?firstPos ?resultSubTree Egraft ?resultTree ?originalTree [?firstPos | ?restPosList] ?graftTree 97 true ,graft ?graftTree ?originalTree [] ?graftTree 9 bottom /0hasBranches ?tree2 % true 1hasBranches [?label ?firstBranch | ?restBranches] C7 0/00/0/0/0jcrossover ?firstChildTree ?secondChildTree ?firstPosList ?secondPosList ?firstParentTree ?secondParentTree2 + and subTree ?firstGraft ?firstParentTree ?firstPosList\ subTree ?secondGraft ?secondParentTree ?secondPosList\ graft ?firstChildTree ?firstParentTree ?firstPosList ?secondGraft\ graft ?secondChildTree ?secondParentTree ?secondPosList ?firstGraft jcrossover ?firstChildTree ?secondChildTree ?firstPosList ?secondPosList ?firstParentTree ?secondParentTree H7 / GroundTerm0/0*fixedRandomNodeChoice ?posList ?tree ?term2 ) 6fixedRandomChoice ?posList ?pl ?term nodeOf ?pl ?tree *fixedRandomNodeChoice ?posList ?tree ?term N7 0/0"nodeList ?listOfNodePosLists ?tree2 . 8sortedList ?list ?nodePosList nodeOf ?nodePosList ?tree nodeList ?list ?tree S7 M/0label ?label ?list2 * true label ?label [?label | ?rest] X7 /00allLabels ?labelList ?tree2 true allLabels [?label] [?label] ] leaf and = ?branches [?something | ?rest]\ mappedList ?resultList ?branches allLabels\ randomList ?subLeafList ?lb true (and includes ?resultList ?list\ includes ?list ?lb)\ appended ?labelList [?label] ?subLeafList )allLabels ?labelList [?label | ?branches] ` recusive /M/MsubTreeOf ?subTree ?tree2 Mand includes [?firstBranch | ?branches] ?branch\ subTreeOf ?subTree ?branch 4subTreeOf ?subTree [?label ?firstBranch | ?branches] g recurse true subTreeOf [?label] [?label] ja 0/1/0/0/MgrandomTree ?tree ?maxDepth ?nodeList ?terminalList ?term
(?nodeList = pairs of [label noOfBranches])2 - dand
greater ?depth 0\
fixedRandomChoice [?label ?noBranches] ?node ?term
includes ?nodeList ?node\
is ?newDepth ?depth - 1\
sortedList ?pairList ?pair
(and
inInterval ?branchNo 1 ?noBranches\
fixedRandomTree ?branch ?newDepth ?nodeList ?terminalList [?branchNo | ?term]\
= ?pair [?branchNo ?branch])\
mappedList ?branches ?pairList second IfixedRandomTree [?label | ?branches] ?depth ?nodeList ?terminalList ?term p7 >fixedRandomChoice ?label ?lb ?term
includes ?terminalList ?lb 8fixedRandomTree [?label] 0 ?nodeList ?terminalList ?term sA /M/MsubTreeOf ?subTree ?tree2 and
notInferred
= ?subTree [?label ?firstBranch | ?branches]\
includes [?firstBranch | ?branches] ?branch\
isSubTreeOf ?subTree ?branch 6isSubTreeOf ?subTree [?label ?firstBranch | ?branches] wk true isSubTreeOf ?tree ?tree za 0/0>the first argument is unified with a list of nodes in the tree
primitive
"unify the first argument with a list of leaves in argument 2"
clause first
unifyWith: (GPCodeHolder nodeList: (clause at: 2))
bindings: bindings
continuation: continuation /00leafOf ?leaf ?tree2 6and
includes ?branches ?branch\
leafOf ?leaf ?branch !leafOf ?leaf [?label | ?branches] 7 true leafOf [?label] [?label] a /0Mbranches ?branchList ?tree2 true +branches ?branchList [?label | ?branchList] 7 /00/0/