Skip to content

Commit

Permalink
moved util functions to utils.py, moved probability learners from lea…
Browse files Browse the repository at this point in the history
…rning.py to probabilistic_learning.py with tests, fixed typos and fixed imports in .ipynb files (aimacode#1120)

* changed queue to set in AC3

Changed queue to set in AC3 (as in the pseudocode of the original algorithm) to reduce the number of consistency-check due to the redundancy of the same arcs in queue. For example, on the harder1 configuration of the Sudoku CSP the number consistency-check has been reduced from 40464 to 12562!

* re-added test commented by mistake

* added the mentioned AC4 algorithm for constraint propagation

AC3 algorithm has non-optimal worst case time-complexity O(cd^3 ), while AC4 algorithm runs in O(cd^2) worst case time

* added doctest in Sudoku for AC4 and and the possibility of choosing the constant propagation algorithm in mac inference

* removed useless doctest for AC4 in Sudoku because AC4's tests are already present in test_csp.py

* added map coloring SAT problems

* fixed typo errors and removed unnecessary brackets

* reformulated the map coloring problem

* Revert "reformulated the map coloring problem"

This reverts commit 20ab0e5.

* Revert "fixed typo errors and removed unnecessary brackets"

This reverts commit f743146.

* Revert "added map coloring SAT problems"

This reverts commit 9e0fa55.

* Revert "removed useless doctest for AC4 in Sudoku because AC4's tests are already present in test_csp.py"

This reverts commit b3cd24c.

* Revert "added doctest in Sudoku for AC4 and and the possibility of choosing the constant propagation algorithm in mac inference"

This reverts commit 6986247.

* Revert "added the mentioned AC4 algorithm for constraint propagation"

This reverts commit 03551fb.

* added map coloring SAT problem

* fixed build error

* Revert "added map coloring SAT problem"

This reverts commit 93af259.

* Revert "fixed build error"

This reverts commit 6641c2c.

* added map coloring SAT problem

* removed redundant parentheses

* added Viterbi algorithm

* added monkey & bananas planning problem

* simplified condition in search.py

* added tests for monkey & bananas planning problem

* removed monkey & bananas planning problem

* Revert "removed monkey & bananas planning problem"

This reverts commit 9d37ae0.

* Revert "added tests for monkey & bananas planning problem"

This reverts commit 24041e9.

* Revert "simplified condition in search.py"

This reverts commit 6d229ce.

* Revert "added monkey & bananas planning problem"

This reverts commit c74933a.

* defined the PlanningProblem as a specialization of a search.Problem & fixed typo errors

* fixed doctest in logic.py

* fixed doctest for cascade_distribution

* added ForwardPlanner and tests

* added __lt__ implementation for Expr

* added more tests

* renamed forward planner

* Revert "renamed forward planner"

This reverts commit c4139e5.

* renamed forward planner class & added doc

* added backward planner and tests

* fixed mdp4e.py doctests

* removed ignore_delete_lists_heuristic flag

* fixed heuristic for forward and backward planners

* added SATPlan and tests

* fixed ignore delete lists heuristic in forward and backward planners

* fixed backward planner and added tests

* updated doc

* added nary csp definition and examples

* added CSPlan and tests

* fixed CSPlan

* added book's cryptarithmetic puzzle example

* fixed typo errors in test_csp

* fixed aimacode#1111

* added sortedcontainers to yml and doc to CSPlan

* added tests for n-ary csp

* fixed utils.extend

* updated test_probability.py

* converted static methods to functions

* added AC3b and AC4 with heuristic and tests

* added conflict-driven clause learning sat solver

* added tests for cdcl and heuristics

* fixed probability.py

* fixed import

* fixed kakuro

* added Martelli and Montanari rule-based unification algorithm

* removed duplicate standardize_variables

* renamed variables known as built-in functions

* fixed typos in learning.py

* renamed some files and fixed typos

* fixed typos

* fixed typos

* fixed tests

* removed unify_mm

* remove unnecessary brackets

* fixed tests

* moved utility functions to utils.py

* fixed typos

* moved utils function to utils.py, separated probability learning classes from learning.py, fixed typos and fixed imports in .ipynb files

* added missing learners

* fixed Travis build

* fixed typos

* fixed typos

* fixed typos

* fixed typos

* fixed typos in agents files

* fixed imports in agent files
  • Loading branch information
dmeoli authored and antmarakis committed Oct 7, 2019
1 parent c910cca commit 283fa41
Show file tree
Hide file tree
Showing 24 changed files with 1,400 additions and 1,419 deletions.
14 changes: 6 additions & 8 deletions agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ def run(self, steps=1000):

def list_things_at(self, location, tclass=Thing):
"""Return all things exactly at a given location."""
return [thing for thing in self.things
if thing.location == location and isinstance(thing, tclass)]
return [thing for thing in self.things if thing.location == location and isinstance(thing, tclass)]

def some_things_at(self, location, tclass=Thing):
"""Return true if at least one of the things at location
Expand Down Expand Up @@ -993,9 +992,8 @@ def is_done(self):
else:
print("Death by {} [-1000].".format(explorer[0].killed_by))
else:
print("Explorer climbed out {}."
.format(
"with Gold [+1000]!" if Gold() not in self.things else "without Gold [+0]"))
print("Explorer climbed out {}.".format("with Gold [+1000]!"
if Gold() not in self.things else "without Gold [+0]"))
return True

# TODO: Arrow needs to be implemented
Expand All @@ -1012,9 +1010,9 @@ def compare_agents(EnvFactory, AgentFactories, n=10, steps=1000):
>>> environment = TrivialVacuumEnvironment
>>> agents = [ModelBasedVacuumAgent, ReflexVacuumAgent]
>>> result = compare_agents(environment, agents)
>>> performance_ModelBasedVacummAgent = result[0][1]
>>> performance_ReflexVacummAgent = result[1][1]
>>> performance_ReflexVacummAgent <= performance_ModelBasedVacummAgent
>>> performance_ModelBasedVacuumAgent = result[0][1]
>>> performance_ReflexVacuumAgent = result[1][1]
>>> performance_ReflexVacuumAgent <= performance_ModelBasedVacuumAgent
True
"""
envs = [EnvFactory() for i in range(n)]
Expand Down
6 changes: 3 additions & 3 deletions agents4e.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,9 @@ def compare_agents(EnvFactory, AgentFactories, n=10, steps=1000):
>>> environment = TrivialVacuumEnvironment
>>> agents = [ModelBasedVacuumAgent, ReflexVacuumAgent]
>>> result = compare_agents(environment, agents)
>>> performance_ModelBasedVacummAgent = result[0][1]
>>> performance_ReflexVacummAgent = result[1][1]
>>> performance_ReflexVacummAgent <= performance_ModelBasedVacummAgent
>>> performance_ModelBasedVacuumAgent = result[0][1]
>>> performance_ReflexVacuumAgent = result[1][1]
>>> performance_ReflexVacuumAgent <= performance_ModelBasedVacuumAgent
True
"""
envs = [EnvFactory() for i in range(n)]
Expand Down
13 changes: 11 additions & 2 deletions csp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"outputs": [],
"source": [
"from csp import *\n",
"from notebook import psource, pseudocode, plot_NQueens\n",
"from notebook import psource, plot_NQueens\n",
"%matplotlib inline\n",
"\n",
"# Hide warnings in the matplotlib sections\n",
Expand Down Expand Up @@ -3068,8 +3068,17 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
}
}
},
"nbformat": 4,
"nbformat_minor": 1
}
}
Loading

0 comments on commit 283fa41

Please sign in to comment.