Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Uwe Köckemann
aiddl-pub
Commits
275dee48
Commit
275dee48
authored
Sep 17, 2020
by
Uwe Köckemann
Browse files
Linear algebra, regression, test cases, planning+resources example, csp solver, ...
parent
923b1fd5
Changes
216
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
596 additions
and
226 deletions
+596
-226
README.org
README.org
+2
-2
common/README.org
common/README.org
+43
-0
common/aiddl/common.aiddl
common/aiddl/common.aiddl
+23
-7
common/aiddl/learning/decision-tree.aiddl
common/aiddl/learning/decision-tree.aiddl
+12
-2
common/aiddl/learning/linear-regression.aiddl
common/aiddl/learning/linear-regression.aiddl
+11
-0
common/aiddl/learning/supervised.aiddl
common/aiddl/learning/supervised.aiddl
+58
-16
common/aiddl/math/graph/graph.aiddl
common/aiddl/math/graph/graph.aiddl
+91
-83
common/aiddl/planning/state-variable/data.aiddl
common/aiddl/planning/state-variable/data.aiddl
+29
-18
common/aiddl/planning/state-variable/hierarchical-task-network.aiddl
...l/planning/state-variable/hierarchical-task-network.aiddl
+0
-40
common/aiddl/planning/state-variable/signature.aiddl
common/aiddl/planning/state-variable/signature.aiddl
+0
-4
common/aiddl/planning/state-variable/solver/forward-search-planner.aiddl
...anning/state-variable/solver/forward-search-planner.aiddl
+8
-11
common/aiddl/planning/state-variable/state-variable.aiddl
common/aiddl/planning/state-variable/state-variable.aiddl
+41
-15
common/aiddl/planning/state-variable/task-network.aiddl
common/aiddl/planning/state-variable/task-network.aiddl
+66
-0
common/aiddl/reasoning/constraint/csp-solver.aiddl
common/aiddl/reasoning/constraint/csp-solver.aiddl
+37
-0
common/aiddl/reasoning/constraint/csp.aiddl
common/aiddl/reasoning/constraint/csp.aiddl
+122
-0
common/aiddl/reasoning/logic/prolog.aiddl
common/aiddl/reasoning/logic/prolog.aiddl
+3
-3
common/java/build.gradle
common/java/build.gradle
+15
-3
common/java/gradle/wrapper/gradle-wrapper.jar
common/java/gradle/wrapper/gradle-wrapper.jar
+0
-0
common/java/gradle/wrapper/gradle-wrapper.properties
common/java/gradle/wrapper/gradle-wrapper.properties
+2
-2
common/java/gradlew
common/java/gradlew
+33
-20
No files found.
README.org
View file @
275dee48
...
...
@@ -5,6 +5,8 @@ AI problems, data and how AI methods are connected in order to solve
problems. This allows to create complex integrated AI systems by combining
robust and well-studied components.
You can find the most recent version under [[http:www.aiddl.org][aiddl.org]].
* Overview
#+CAPTION: Overview of AIDDL components and interactions.
...
...
@@ -240,8 +242,6 @@ readability we assume name spaces ~eval.aiddl~ and ~type.aiddl~ are used):
(<= #self 10)))
#+END_EXAMPLE
* Support
Contact Uwe Köckemann (uwe.kockemann_at_oru.se) in case of questions,
suggestions, feature requests, bug reports.
...
...
common/README.org
View file @
275dee48
...
...
@@ -3,3 +3,46 @@
The AIDDL Common Library contains type definitions, implementations and test
cases for many common AI algorithms. These implementations can be used as
building blocks for fast prototyping of integrated AI systems.
* AIDDL
Types, interfaces, and functions written in AIDDL.
** Math
*** Graphs
| URI | Description | Example(s) |
|------------------------+-----------------------------------+-------------------------|
| org.aiddl.common.graph | | |
|------------------------+-----------------------------------+-------------------------|
| Node | A node in a graph | v1, (at a b) |
| UndirectedEdge | An undirected edge | {v1 v2} |
| DirectedEdge | A directed edge | (v1 v2) |
| Graph | Undirected Graph | (V:{v1 v2} E:{{v1 v2}}) |
| DiGraph | Directed Graph | (V:{v1 v2} E:{(v1 v2)}) |
| WeightMap | Map from Edge to weight | {(v1 v2):3 (v1 v3):2} |
| Distance Map | Map from Node to distance | {v1:0 v2:3 v3:2} |
| Predecessor Map | Map from Node to predecessor node | {v1:NIL v2:v1 v3:v1} |
** Automated Planning
*** State-Variable
** Machine Learning
*** Supervised
**** Decision Tree
* Java
Functions implemented as a Java library.
** Math
*** Graphs
**** Bellman Ford
- Implements :: org.aiddl.common.math.graph.single-source-shortest-path
- Input :: (Graph, Weight Map, Node)
- Output :: (Node-Distance Map, Node-Predecessor Map)
** Machine Learning
*** Decision Tree Learner
*** Decision Tree Classifier
** Automated Planning
*** State-Variable
common/aiddl/common.aiddl
View file @
275dee48
(#mod self org.aiddl.common)
(#nms EVAL
"eval
.aiddl
"
)
(#nms EVAL
org
.aiddl
.eval
)
(#def Map
(and
...
...
@@ -11,7 +11,7 @@
(#def MapGen
(match (?KT ?VT) #self
^
(lambda ?M ($MapOf (?KT ?VT ?M)))))
(lambda ?M ($MapOf (?KT ?VT ?M)))))
(#def MapOf
(match (?KeyType ?ValueType ?Map) #self
...
...
@@ -24,16 +24,21 @@
)))))
(#def SetGen
^(lambda ?Set
($SetOf #self ?Set) ))
(lambda ?Set
(and
(type ?Set ^set)
(forall ?e ?Set (type ?e #self)))))
(#def (SetOf ?Type ?Set)
(and
(type ?Set ^set)
(forall ?e ?Set (type ?e ?Type))))
(#def ListGen
^(lambda ?List
(ListOf ?List #self) ))
(lambda ?List
(and
(type ?List ^list)
(forall ?e ?List (type ?e #self)))))
(#def (ListOf ?Type)
(and
...
...
@@ -49,7 +54,18 @@
)))
(#def KeyValuedType
^
(lambda ?x
(lambda ?x
(forall ?k:?t #self
(call ?t (get-key ?k ?x))) ))
(#def TypedTuple
(lambda ?x
(forall ?i (domain {min:0 inc:1 max:(- (size #self) 1)})
(type (get-idx ?i ?x) (get-idx ?i #self))
)))
(#def MapFunctionGen
(lambda ?k
(get-key ?k #self default:NIL)))
\ No newline at end of file
common/aiddl/learning/decision-tree.aiddl
View file @
275dee48
(#mod self org.aiddl.common.learning.decision-tree)
(#mod self org.aiddl.common.learning.
supervised.
decision-tree)
(#nms EVAL org.aiddl.eval)
(#nms EVAL org.aiddl.eval-ht)
(#req SL org.aiddl.common.learning.supervised)
(#def Comparator (in #self {= < > >= <=}))
...
...
@@ -21,3 +23,11 @@
(type #self #list)
(forall ?e #self (type ?e Decision))
)))
(#interface
decision-tree-learner
(
uri:org.aiddl.common.learning.supervised.decision-tree.learner
input:Problem@SL
output:$DecisionTree
))
\ No newline at end of file
common/aiddl/learning/linear-regression.aiddl
0 → 100644
View file @
275dee48
(#mod self org.aiddl.common.learning.supervised.linear-regression)
(#req LA org.aiddl.common.math.linear-algebra)
(#req SL org.aiddl.common.learning.supervised)
(#interface
linear-regression-learner
(
uri:org.aiddl.common.learning.supervised.linear-regression.learner
input:^RegressionProblem@SL
output:^Vector@LA
\ No newline at end of file
common/aiddl/learning/supervised.aiddl
View file @
275dee48
...
...
@@ -3,29 +3,62 @@
(#nms EVAL org.aiddl.eval)
(#req T org.aiddl.common.domain)
(#req FoL org.aiddl.common.reasoning.logic.first-order)
(#req LA org.aiddl.common.math.linear-algebra)
(#def WildcardDomain
(= #self *))
(#def Attribute
(and
(type #self #tuple)
(signature #self [term {Domain@T $WildcardDomain}])))
(match (?Name ?Type) #self
(and
(type ?Name ^term)
(type ?Type ^fun-ref) )))
(#def Attributes
(and
(type #self list)
(type #self
^
list)
(forall ?e #self
(type ?e $Attribute))))
(type ?e
^
$Attribute))))
(#def DataPoint (and (type #self list)))
(#def Class
(or
(type #self ^symbolic)
(type #self ^Atom@FoL) ))
(#def DataPoints
(#def DataPoint (and (type #self ^list)))
(#def RegressionProblem
(and
(type #self {list set})
(forall ?e #self
(type ?e $DataPoint))))
(type #self ^tuple)
(match (attributes : ?Attributes label : ?Label data : ?Data) #self
(and
(type ?Attributes ^$Attributes)
(exists (?Label _) ?Attributes true)
(forall ?Datapoint ?Data
(and
(= (size ?Datapoint) (size ?Attributes))
(zip (?Att ?Val) [?Attributes ?Datapoint]
(match (?Var ?Domain) ?Att
(and
(type ?Val ?Domain)
(type ?Val ^numerical) )))))))))
(#def ClassificationProblem
(and
(type #self ^tuple)
(match (attributes : ?Attributes label : ?Label data : ?Data) #self
(and
(type ?Attributes ^$Attributes)
(exists (?Label _) ?Attributes true)
(forall ?Datapoint ?Data
(and
(= (size ?Datapoint) (size ?Attributes))
(zip (?Att ?Val) [?Attributes ?Datapoint]
(match (?Var ?Domain) ?Att
(and
(type ?Val ?Domain)
(type ?Val ^$Class) )))))))))
(#def Problem
(and
...
...
@@ -33,17 +66,13 @@
(match (attributes : ?Attributes label : ?Label data : ?Data) #self
(and
(type ?Attributes $Attributes)
(type ?Data $DataPoints)
(exists (?Label _) ?Attributes true)
(forall ?Datapoint ?Data
(and
(= (size ?Datapoint) (size ?Attributes))
(zip (?Att ?Val) [?Attributes ?Datapoint]
(match (?Var ?Domain) ?Att
(or
(= ?Domain *)
(in ?Val ?Domain)
)
(type ?Val ?Domain)
)
)
)
...
...
@@ -58,4 +87,17 @@
(type ?M Matrix@LA)
(= (size ?A) (size ?M))
(= (size ?A) (size (first ?M)))
)))
\ No newline at end of file
)))
(#interface classification-function
(
uri:org.aiddl.common.learning.supervised.classification-function
input:^$DataPoint
output:$Class))
(#interface regression-function
(
uri:org.aiddl.common.learning.supervised.regression-function
input:^$DataPoint
output:^numerical))
\ No newline at end of file
common/aiddl/math/graph/graph.aiddl
View file @
275dee48
...
...
@@ -16,90 +16,87 @@
(type #self ^$UndirectedEdge)
(type #self ^$DirectedEdge) ))
(#def Label
(type #self ^term))
(#def UndirectedEdge
(and
(type #self {^tuple ^list ^set})
(type (get-key e #self) ^set)
(= (size (get-key e #self)) 2)
(forall ?e (get-key e #self)
(type ?e ^$Node) )))
(type #self ^set)
(= (size #self) 2)
(forall ?e #self
(type ?e ^$Node) )))
(#def DirectedEdge
(and
(type #self {^tuple ^list ^set})
(exists e:?e #self
(and
(type ?e ^tuple)
(signature ?e [^$Node ^$Node])
(= (size ?e) 2) ))))
(type #self ^tuple)
(signature #self [^$Node ^$Node])
))
(#def
LabeledEdge
(#def
Graph
(and
(type #self ^$Edge)
(exists label:?L #self
(type ?L ^$Label) )))
(type #self ^tuple)
(let [?V:(get-key V #self) ?E:(get-key E #self)]
(and
(forall ?v ?V (type ?v ^$Node))
(forall ?e ?E
(and
(type ?e ^$UndirectedEdge)
(contains-all ?V ?e) ))))))
(#def
WeightedEdge
(#def
DiGraph
(and
(type #self ^$Edge)
(exists w:?w #self
(type ?w ^numerical) )))
(type #self ^tuple)
(let [?V:(get-key V #self) ?E:(get-key E #self)]
(and
(forall ?v ?V (type ?v ^$Node))
(forall ?e ?E
(and
(type ?e ^$DirectedEdge)
(contains ?V (get-idx 0 ?e))
(contains ?V (get-idx 1 ?e)) ))))))
(#def Graph (type (^$Node ^$Edge #self) ^$TypedGraph))
(#def (TypedGraph ?NodeType)
(lambda ?G
(type (?NodeType ?G) ^$TypedGraphFun)))
(#def TypedGraph
(match (?NodeType
?EdgeType
?G) #self
(#def TypedGraph
Fun
(match (?NodeType ?G) #self
(and
(type ?G ^tuple)
(match (V:?V E:?E) ?G
(and
(type ?V {^set ^list})
(forall ?v ?V (call ?NodeType ?v)) ;; (type ?v ?NodeType))
(forall ?e ?E
(and
(call ?EdgeType ?e) ;; (type ?e ?EdgeType)
(cond
(type ?e ^$UndirectedEdge) :
(contains-all ?V (get-key e ?e))
(type ?e ^$DirectedEdge) :
(and
(contains ?V (get-idx 0 (get-key e ?e)))
(contains ?V (get-idx 1 (get-key e ?e))) )))))))))
(#def Simple
(type (get-key V #self) ^set))
(#def Multi
(type (get-key V #self) ^list))
(#def Directed
(forall ?e (get-key E #self)
(type ?e ^$DirectedEdge) ))
(#def Undirected
(forall ?e (get-key E #self)
(type ?e ^$UndirectedEdge) ))
(#def Weighted
(forall ?e (get-key E #self)
(type ?e ^$WeightedEdge) ))
(#def Connected
(forall ?v1 (get-key V #self)
(forall ?v2 (get-key V #self)
(or
(= ?v1 ?v2)
(exists ?e (get-key E #self)
(= (get-key e ?e) {?v1 ?v2}) )))))
(type ?G ^tuple)
(let [?V:(get-key V #self) ?E:(get-key E #self)]
(and
(forall ?v ?V (type ?v ?NodeType))
(forall ?e ?E
(and
(type ?e ^$UndirectedEdge)
(contains-all ?V ?e) )))))))
(#def (TypedDiGraph ?NodeType)
(lambda ?G
(type (?NodeType ?G) ^$TypedDiGraphFun)))
(#def TypedDiGraphFun
(match (?NodeType ?G) #self
(and
(type ?G ^tuple)
(let [?V:(get-key V #self) ?E:(get-key E #self)]
(and
(forall ?v ?V (type ?v ?NodeType))
(forall ?e ?E
(and
(type ?e ^$DirectedEdge)
(contains-all ?V ?e) )))))))
(#def Path
(and
(type #self ^list)
(forall ?n #self (type ?n ^$Node))))
(#def WeightMap
(and
(type #self ^collection)
(forall ?k:?v #self
(and
(type ?k ^$Edge)
(type ?v ^numerical) ))))
(#def DistanceMap
(and
(type #self ^collection)
...
...
@@ -116,33 +113,44 @@
(type ?k ^$Node)
(type ?v ^$Node) ))))
(#interface transpose (
uri : org.aiddl.common.math.graph.transpose
input : ^$Graph
output : ^$Graph
))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Interfaces
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(#interface
bellman-ford
(
uri : org.aiddl.common.math.graph.
bellman-ford
input : (
KeyValuedType@C [graph:^$Graph start:^$Node target:
^$Node])
output : (KeyValuedType@C [
path:^$Path
distance:^$DistanceMap predecessor:^$PredecessorMap])
(#interface
single-source-shortest-path
(
uri : org.aiddl.common.math.graph.
single-source-shortest-path
input : (
TypedTuple@C [^$DiGraph {^fun-ref ^$WeightMap}
^$Node])
output : (KeyValuedType@C [distance:^$DistanceMap predecessor:^$PredecessorMap])
))
(#interface depth-first-search (
uri : org.aiddl.common.mat
c
h.graph.depth-first-search
input :
$
Graph
uri : org.aiddl.common.math.graph.depth-first-search
input :
^$Di
Graph
output : (KeyValuedType@C [
pi:
^
(MapGen@C ^$Node ^$Node)
distances:
^
(MapGen ^$Node ^numerical)
finish-times:
^
(MapGen@C ^$Node ^numerical)
components:
^
(SetGen@C
^
(SetGen@C ^$Node)) ]
pi:(MapGen@C ^$Node ^$Node)
distances:(MapGen
@C
^$Node ^numerical)
finish-times:(MapGen@C ^$Node ^numerical)
components:(SetGen@C (SetGen@C ^$Node)) ]
)
))
(#interface strongly-connected-components (
uri : org.aiddl.common.math.graph.scc-computer
input : ^$Graph
output : ^(SetGen@C ^(SetGen@C ^$Node))
input : ^$DiGraph
output : (SetGen@C (SetGen@C ^$Node))
))
(#interface transpose (
uri : org.aiddl.common.math.graph.transpose
input : ^$DiGraph
output : ^$DiGraph
))
(#interface path-extractor (
uri : org.aiddl.common.math.graph.path-extractor
input : ^$PredecessorMap
output : ^$Path
))
\ No newline at end of file
common/aiddl/planning/state-variable/data.aiddl
View file @
275dee48
...
...
@@ -2,30 +2,31 @@
(#nms E org.aiddl.eval)
(#req G org.aiddl.common.math.graph)
(#req P org.aiddl.common.planning.state-variable)
(#req FL org.aiddl.common.reasoning.logic.first-order)
;; (#def RelaxedPlanningGraph
;; (and
;; (type #self list)
;; (forall ?idx (domain {min:0 max:(- (size #self) 1)})
;; (let [?L:(get-idx ?idx #self)]
;; (and
;; (type ?L set)
;; (if (= (modulo ?idx 2) 0)
;; (forall ?e ?L
;; (or
;; (type ?e Atom@FL)
;; (type ?e StateVariableAssignment@P)))
;; (forall ?e ?L
;; (type ?e Operator@P) )))))))
(#def DomainTransitionEdge
(and
(type #self ^DirectedEdge@G)
(type (get-key label #label) ^StateVariableAssignments) ))
(#def DomainTransitionGraphs
(and
(type #self ^set)
(forall (?x:?dtg) #self
(and
(type ?x {^Atom@FL ^symbolic})
(type ?dtg (TypedDiGraph@G {^Atom@FL ^symbolic}))
(let [?L:(get-key labels ?dtg)]
(type ?L (MapGen@C {^Atom@FL ^symbolic} ^$DomainTransitionEdge))
)))))
(#def RelaxedPlanningGraph
(and
(type #self ^list)
(let
[?O:(reduce
(lambda (?c ?x) (union {(get-idx ?x #self) ?c}))
[?O:(reduce (lambda (?c ?x) (union {(get-idx ?x #self) ?c}))
(filter (lambda ?x (= (modulo ?x 2) 1)) (domain {min:0 max:(- (size #self) 1)}))
initial-value:{})
?P:(reduce (lambda (?c ?x) (union {(get-idx ?x #self) ?c}))
...
...
@@ -36,8 +37,18 @@
(type ?e ^StateVariableAssignment@P))
(forall ?e ?O
(type ?e ^Operator@P) )))))
(#interface rpg-creator (
(#interface causal-graph-creator (
uri : (sym-concat $self causal-graph-creator)
input : ^Operators@P
output : (TypedDiGraph@G {^Atom@FL ^symbolic})) )
(#interface domain-transition-graph-creator (
uri : (sym-concat $self domain-transition-graph-creator)
input : ^Operators@P
output : ^$DomainTransitionGraphs ))
(#interface relaxed-planning-graph-creator (
uri : (sym-concat $self rpg-creator)
input : ^Problem@P
output : ^$RelaxedPlanningGraph
...
...
common/aiddl/planning/state-variable/hierarchical-task-network.aiddl
deleted
100644 → 0
View file @
923b1fd5
(#mod self org.aiddl.common.planning.hierarchical-task-network)
(#req C org.aiddl.common)
(#req G org.aiddl.common.math.graph)
(#req FOL org.aiddl.common.reasoning.logic.first-order)
(#req SVP org.aiddl.common.state-variable)
(#def Task (type #self Atom@FOL))
(#def TotallyOrderedTaskNetwork
(type #self (List $Task)@C))
(#def DigraphTaskNetwork
(type #self (Graph $Task DirectedEdge@G)@G))
(#def TaskNetwork
(or
(type #self $TotallyOrderedTaskNetwork)
(type #self $DigraphTaskNetwork)
))
(#def SimpleTaskNetworkMethod
(and
(type #self #tuple)
(let [
?N : (get-key name #self)
?T : (get-key task #self)
?P : (get-key preconditions #self)
?S : (get-key subtasks #self) ]
(and
(type ?N Atom@FL)
(type ?T $Task)
(type ?P $StateVariableAssignments)
(type ?S $TaskNetwork)
))))
(#def HtnMethod NIL)
(#def Constraints NIL)
\ No newline at end of file
common/aiddl/planning/state-variable/signature.aiddl
deleted
100644 → 0
View file @
923b1fd5
(#mod self org.aiddl.common.planning.state-variable.signature)
(#nms EVAL org.aiddl.eval)
common/aiddl/planning/state-variable/solver/forward-search-planner.aiddl
View file @
275dee48
...
...
@@ -15,22 +15,22 @@
( name : expand
module : ?Module
class : org.aiddl.common.planning.state_variable.Expand
config : [ verbose :
3
] ) expand )
config : [ verbose :
0
] ) expand )
(call #load-java-fun
( name : get-ground-operators
module : ?Module
class : org.aiddl.common.planning.state_variable.GroundOperatorCreator
config : [ verbose :
3
] ) get-ground-operators )
config : [ verbose :
0
] ) get-ground-operators )
(call #load-java-fun
( name : create-cg
module : ?Module
class : org.aiddl.common.planning.state_variable.data.CausalGraphCreator
config : [ verbose :
3
] ) create-cg )
config : [ verbose :
0
] ) create-cg )
(call #load-java-fun
( name : create-dtgs
module : ?Module
class : org.aiddl.common.planning.state_variable.data.DomainTransitionGraphCreator
config : [ verbose :
3
] ) create-dtgs )
config : [ verbose :
0
] ) create-dtgs )
(call #load-java-fun
( name : h_cg
module : ?Module
...
...
@@ -39,8 +39,8 @@
(call #load-java-fun
( name : h_ff
module : ?Module
class : org.aiddl.common.planning.state_variable.heuristic.FastForward
config : [ verbose:
3
] ) compute-h_ff )
class : org.aiddl.common.planning.state_variable.heuristic.FastForward
Heuristic