├── aima-core ├── lib │ └── junit │ │ └── junit-4.7.jar ├── src │ ├── main │ │ ├── java │ │ │ └── aima │ │ │ │ └── core │ │ │ │ ├── learning │ │ │ │ ├── data │ │ │ │ │ └── DataResource.java │ │ │ │ ├── framework │ │ │ │ │ ├── Attribute.java │ │ │ │ │ ├── Learner.java │ │ │ │ │ ├── AttributeSpecification.java │ │ │ │ │ ├── StringAttribute.java │ │ │ │ │ ├── NumericAttribute.java │ │ │ │ │ └── NumericAttributeSpecification.java │ │ │ │ ├── neural │ │ │ │ │ ├── ActivationFunction.java │ │ │ │ │ ├── PureLinearActivationFunction.java │ │ │ │ │ ├── NNTrainingScheme.java │ │ │ │ │ ├── HardLimitActivationFunction.java │ │ │ │ │ ├── FunctionApproximator.java │ │ │ │ │ ├── LogSigActivationFunction.java │ │ │ │ │ ├── RabbitEyeDataSet.java │ │ │ │ │ ├── Numerizer.java │ │ │ │ │ ├── IrisNNDataSet.java │ │ │ │ │ └── NNConfig.java │ │ │ │ ├── learners │ │ │ │ │ ├── StumpLearner.java │ │ │ │ │ └── MajorityLearner.java │ │ │ │ ├── knowledge │ │ │ │ │ └── Hypothesis.java │ │ │ │ └── inductive │ │ │ │ │ ├── DLTestFactory.java │ │ │ │ │ └── ConstantDecisonTree.java │ │ │ │ ├── logic │ │ │ │ ├── common │ │ │ │ │ ├── Visitor.java │ │ │ │ │ ├── ParseTreeNode.java │ │ │ │ │ ├── LogicTokenTypes.java │ │ │ │ │ └── Token.java │ │ │ │ ├── propositional │ │ │ │ │ ├── parsing │ │ │ │ │ │ ├── ast │ │ │ │ │ │ │ ├── AtomicSentence.java │ │ │ │ │ │ │ ├── ComplexSentence.java │ │ │ │ │ │ │ ├── Sentence.java │ │ │ │ │ │ │ ├── SymbolComparator.java │ │ │ │ │ │ │ ├── FalseSentence.java │ │ │ │ │ │ │ ├── TrueSentence.java │ │ │ │ │ │ │ ├── Symbol.java │ │ │ │ │ │ │ └── UnarySentence.java │ │ │ │ │ │ └── PLVisitor.java │ │ │ │ │ ├── algorithms │ │ │ │ │ │ └── LogicUtils.java │ │ │ │ │ └── visitors │ │ │ │ │ │ ├── SymbolCollector.java │ │ │ │ │ │ └── NegativeSymbolCollector.java │ │ │ │ └── fol │ │ │ │ │ ├── parsing │ │ │ │ │ └── ast │ │ │ │ │ │ ├── Sentence.java │ │ │ │ │ │ ├── Term.java │ │ │ │ │ │ ├── AtomicSentence.java │ │ │ │ │ │ └── FOLNode.java │ │ │ │ │ ├── StandardizeApartIndexical.java │ │ │ │ │ ├── inference │ │ │ │ │ ├── otter │ │ │ │ │ │ ├── ClauseSimplifier.java │ │ │ │ │ │ ├── ClauseFilter.java │ │ │ │ │ │ ├── defaultimpl │ │ │ │ │ │ │ └── DefaultClauseFilter.java │ │ │ │ │ │ └── LightestClauseHeuristic.java │ │ │ │ │ ├── trace │ │ │ │ │ │ ├── FOLModelEliminationTracer.java │ │ │ │ │ │ └── FOLTFMResolutionTracer.java │ │ │ │ │ ├── proof │ │ │ │ │ │ ├── ProofStep.java │ │ │ │ │ │ ├── AbstractProofStep.java │ │ │ │ │ │ ├── ProofStepGoal.java │ │ │ │ │ │ ├── ProofStepPremise.java │ │ │ │ │ │ ├── Proof.java │ │ │ │ │ │ ├── ProofStepRenaming.java │ │ │ │ │ │ ├── ProofStepFoChAlreadyAFact.java │ │ │ │ │ │ ├── ProofStepChainDropped.java │ │ │ │ │ │ └── ProofStepClauseClausifySentence.java │ │ │ │ │ └── InferenceProcedure.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── FOLDomainListener.java │ │ │ │ │ ├── FOLDomainEvent.java │ │ │ │ │ ├── FOLDomainAnswerLiteralAddedEvent.java │ │ │ │ │ ├── FOLDomainSkolemConstantAddedEvent.java │ │ │ │ │ └── FOLDomainSkolemFunctionAddedEvent.java │ │ │ │ │ ├── Quantifiers.java │ │ │ │ │ ├── Connectors.java │ │ │ │ │ └── kb │ │ │ │ │ └── data │ │ │ │ │ ├── ReducedLiteral.java │ │ │ │ │ └── CNF.java │ │ │ │ ├── probability │ │ │ │ ├── Randomizer.java │ │ │ │ ├── JavaRandomizer.java │ │ │ │ ├── decision │ │ │ │ │ ├── MDPPerception.java │ │ │ │ │ ├── MDPFactory.java │ │ │ │ │ ├── MDPSource.java │ │ │ │ │ ├── MDPPolicy.java │ │ │ │ │ ├── MDPRewardFunction.java │ │ │ │ │ └── MDPUtilityFunction.java │ │ │ │ ├── EnumerateJointAsk.java │ │ │ │ ├── reasoning │ │ │ │ │ ├── Particle.java │ │ │ │ │ ├── HMMAgent.java │ │ │ │ │ ├── HmmConstants.java │ │ │ │ │ └── SensorModel.java │ │ │ │ └── Query.java │ │ │ │ ├── environment │ │ │ │ ├── xyenv │ │ │ │ │ └── Wall.java │ │ │ │ ├── nqueens │ │ │ │ │ ├── NQueensGoalTest.java │ │ │ │ │ └── AttackingPairsHeuristic.java │ │ │ │ ├── eightpuzzle │ │ │ │ │ └── EightPuzzleGoalTest.java │ │ │ │ ├── map │ │ │ │ │ ├── MoveToAction.java │ │ │ │ │ ├── StraightLineDistanceHeuristicFunction.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── AdaptableHeuristicFunction.java │ │ │ │ │ ├── DynAttributeNames.java │ │ │ │ │ └── Map.java │ │ │ │ ├── cellworld │ │ │ │ │ ├── Cell.java │ │ │ │ │ └── CellWorldPosition.java │ │ │ │ └── vacuum │ │ │ │ │ └── VacuumEnvPercept.java │ │ │ │ ├── agent │ │ │ │ ├── EnvironmentState.java │ │ │ │ ├── EnvironmentObject.java │ │ │ │ ├── Percept.java │ │ │ │ ├── impl │ │ │ │ │ ├── NoOpAction.java │ │ │ │ │ ├── DynamicState.java │ │ │ │ │ ├── DynamicEnvironmentState.java │ │ │ │ │ ├── aprog │ │ │ │ │ │ └── simplerule │ │ │ │ │ │ │ ├── Condition.java │ │ │ │ │ │ │ ├── NOTCondition.java │ │ │ │ │ │ │ ├── EQUALCondition.java │ │ │ │ │ │ │ ├── ANDCondition.java │ │ │ │ │ │ │ └── ORCondition.java │ │ │ │ │ ├── DynamicAction.java │ │ │ │ │ ├── SimpleEnvironmentView.java │ │ │ │ │ ├── DynamicPercept.java │ │ │ │ │ └── AbstractAgent.java │ │ │ │ ├── EnvironmentViewNotifier.java │ │ │ │ ├── Model.java │ │ │ │ ├── Action.java │ │ │ │ ├── State.java │ │ │ │ ├── AgentProgram.java │ │ │ │ └── Agent.java │ │ │ │ ├── search │ │ │ │ ├── framework │ │ │ │ │ ├── Search.java │ │ │ │ │ ├── GoalTest.java │ │ │ │ │ ├── DefaultStepCostFunction.java │ │ │ │ │ ├── BidirectionalProblem.java │ │ │ │ │ ├── EvaluationFunction.java │ │ │ │ │ ├── DefaultGoalTest.java │ │ │ │ │ ├── HeuristicFunction.java │ │ │ │ │ ├── PathCostFunction.java │ │ │ │ │ ├── CutOffIndicatorAction.java │ │ │ │ │ ├── PrioritySearch.java │ │ │ │ │ ├── PerceptToStateFunction.java │ │ │ │ │ ├── ActionsFunction.java │ │ │ │ │ ├── ResultFunction.java │ │ │ │ │ ├── StepCostFunction.java │ │ │ │ │ ├── Metrics.java │ │ │ │ │ └── TreeSearch.java │ │ │ │ ├── csp │ │ │ │ │ ├── CSPStateListener.java │ │ │ │ │ ├── Variable.java │ │ │ │ │ ├── Constraint.java │ │ │ │ │ └── NotEqualConstraint.java │ │ │ │ ├── adversarial │ │ │ │ │ ├── GameAgent.java │ │ │ │ │ └── AlphaBeta.java │ │ │ │ ├── local │ │ │ │ │ ├── FitnessFunction.java │ │ │ │ │ └── Scheduler.java │ │ │ │ ├── informed │ │ │ │ │ ├── GreedyBestFirstSearch.java │ │ │ │ │ ├── GreedyBestFirstEvaluationFunction.java │ │ │ │ │ ├── AStarSearch.java │ │ │ │ │ └── AStarEvaluationFunction.java │ │ │ │ └── uninformed │ │ │ │ │ └── DepthFirstSearch.java │ │ │ │ └── util │ │ │ │ ├── Converter.java │ │ │ │ ├── CancelableThread.java │ │ │ │ ├── ArrayIterator.java │ │ │ │ ├── datastructure │ │ │ │ ├── Point2D.java │ │ │ │ ├── Pair.java │ │ │ │ ├── Triplet.java │ │ │ │ └── FIFOQueue.java │ │ │ │ └── FrequencyCounter.java │ │ └── resource │ │ │ └── aima │ │ │ └── core │ │ │ └── learning │ │ │ └── data │ │ │ ├── rabbiteyes.txt │ │ │ ├── orings.csv │ │ │ ├── restaurant.csv │ │ │ └── rabbiteyes.csv │ └── test │ │ └── java │ │ └── aima │ │ └── test │ │ └── core │ │ └── unit │ │ ├── agent │ │ ├── impl │ │ │ ├── MockAgent.java │ │ │ ├── DynamicPerceptTest.java │ │ │ └── PerceptSequenceTest.java │ │ └── AgentTestSuite.java │ │ ├── logic │ │ ├── LogicTestSuite.java │ │ ├── propositional │ │ │ ├── parsing │ │ │ │ └── ListTest.java │ │ │ └── algorithms │ │ │ │ └── PLFCEntailsTest.java │ │ └── fol │ │ │ └── PredicateCollectorTest.java │ │ ├── learning │ │ ├── framework │ │ │ └── MockDataSetSpecification.java │ │ └── inductive │ │ │ └── MockDLTestFactory.java │ │ ├── probability │ │ ├── MockRandomizer.java │ │ ├── ProbabilityTestSuite.java │ │ └── reasoning │ │ │ └── RandomVariableTest.java │ │ ├── util │ │ ├── UtilTestSuite.java │ │ └── datastructure │ │ │ └── XYLocationTest.java │ │ ├── AllAIMAUnitTestSuite.java │ │ ├── search │ │ ├── local │ │ │ └── SimulatedAnnealingSearchTest.java │ │ └── framework │ │ │ └── NodeTest.java │ │ └── environment │ │ ├── vacuum │ │ └── EnvironmentViewActionTracker.java │ │ └── eightpuzzle │ │ └── MisplacedTileHeuristicFunctionTest.java ├── .project ├── .classpath ├── build.properties └── LICENSE.txt ├── aima-all ├── release │ ├── images │ │ ├── aima3e.jpg │ │ ├── favicon.ico │ │ ├── osm_logo.jpg │ │ ├── aima3ebig.jpg │ │ ├── aima_logo.png │ │ ├── nqueensapp.png │ │ ├── vacuumapp.png │ │ ├── aimademoapps.png │ │ ├── mininaviapp.png │ │ ├── tictactoeapp.png │ │ ├── eightpuzzleapp.png │ │ ├── mapcoloringapp.png │ │ ├── osmviewerplusapp.png │ │ ├── routefindingagentapp.png │ │ └── osmsearchdemoagentapp.png │ ├── jars │ │ ├── aima-core.jar │ │ ├── aima-gui.jar │ │ ├── aimax-osm.jar │ │ └── commons-compress-1.1.jar │ ├── wiki │ │ ├── ant_build.png │ │ ├── eclipse_setup.png │ │ ├── eclipse_views.png │ │ ├── eclipse_new_other.png │ │ ├── eclipse_run_junit.png │ │ ├── eclipse_file_import.png │ │ ├── eclipse_installed_jre.png │ │ ├── eclipse_new_other_svn.png │ │ ├── eclipse_import_existing.png │ │ ├── eclipse_import_projects.png │ │ ├── eclipse_select_new_project.png │ │ ├── eclipse_svn_create_location.png │ │ └── eclipse_references_workspace.png │ ├── aima-gui-VacuumApp.jnlp │ ├── aima-gui-EightPuzzleApp.jnlp │ ├── aima-gui-TicTacToeApp.jnlp │ ├── aima-gui-NQueensApp.jnlp │ ├── aima-gui-MapColoringApp.jnlp │ ├── aima-gui-RouteFindingAgentApp.jnlp │ ├── aimax-osm-OsmSearchDemoAgentApp.jnlp │ ├── aimax-osm-MiniNaviApp.jnlp │ ├── aimax-osm-OSMAndAIMADemoApp.jnlp │ └── aimax-osm-OsmViewerPlusApp.jnlp ├── .classpath ├── .project └── build.properties ├── aimax-osm ├── lib │ ├── commons-compress-1.1.jar │ └── NOTICE.txt ├── src │ └── main │ │ └── java │ │ └── aimax │ │ └── osm │ │ ├── data │ │ ├── MapEventListener.java │ │ ├── MapWayFilter.java │ │ ├── impl │ │ │ ├── package-info.java │ │ │ └── DefaultWayRef.java │ │ ├── DataResource.java │ │ ├── entities │ │ │ ├── package-info.java │ │ │ ├── WayRef.java │ │ │ ├── EntityViewInfo.java │ │ │ ├── Track.java │ │ │ └── MapNode.java │ │ ├── WayNodeProvider.java │ │ ├── package-info.java │ │ ├── EntityVisitor.java │ │ └── MapEvent.java │ │ ├── routing │ │ ├── package-info.java │ │ ├── agent │ │ │ ├── package-info.java │ │ │ └── PointLatLon.java │ │ ├── OsmDistanceStepCostFunction.java │ │ ├── OsmResultFunction.java │ │ └── OsmSldHeuristicFunction.java │ │ ├── applications │ │ ├── package-info.java │ │ ├── OsmAimaDemoApp.java │ │ └── OsmViewerApp.java │ │ ├── gps │ │ ├── GpsPositionListener.java │ │ ├── GpsFix.java │ │ ├── package-info.java │ │ └── NmeaFileReader.java │ │ ├── viewer │ │ ├── MapViewEventListener.java │ │ ├── MapViewEvent.java │ │ └── package-info.java │ │ ├── reader │ │ ├── TagListener.java │ │ └── package-info.java │ │ └── writer │ │ └── MapWriter.java ├── .project ├── .classpath ├── LICENSE.txt └── build.properties ├── aima-gui ├── src │ └── main │ │ └── java │ │ └── aima │ │ └── gui │ │ ├── applications │ │ ├── search │ │ │ └── map │ │ │ │ └── package-info.java │ │ └── vacuum │ │ │ └── VacuumFrame.java │ │ ├── framework │ │ ├── MessageLogger.java │ │ ├── package-info.java │ │ └── PopupShower.java │ │ └── demo │ │ ├── logic │ │ ├── DPLLDemo.java │ │ └── PLResolutionDemo.java │ │ ├── search │ │ └── GenerateRandomEightPuzzleBoard.java │ │ └── agent │ │ └── TrivialVacuumDemo.java ├── .classpath ├── .project ├── build.properties └── LICENSE.txt ├── .project └── .classpath /aima-core/lib/junit/junit-4.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-core/lib/junit/junit-4.7.jar -------------------------------------------------------------------------------- /aima-all/release/images/aima3e.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/aima3e.jpg -------------------------------------------------------------------------------- /aima-all/release/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/favicon.ico -------------------------------------------------------------------------------- /aima-all/release/images/osm_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/osm_logo.jpg -------------------------------------------------------------------------------- /aima-all/release/jars/aima-core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/jars/aima-core.jar -------------------------------------------------------------------------------- /aima-all/release/jars/aima-gui.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/jars/aima-gui.jar -------------------------------------------------------------------------------- /aima-all/release/jars/aimax-osm.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/jars/aimax-osm.jar -------------------------------------------------------------------------------- /aima-all/release/wiki/ant_build.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/ant_build.png -------------------------------------------------------------------------------- /aima-all/release/images/aima3ebig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/aima3ebig.jpg -------------------------------------------------------------------------------- /aima-all/release/images/aima_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/aima_logo.png -------------------------------------------------------------------------------- /aima-all/release/images/nqueensapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/nqueensapp.png -------------------------------------------------------------------------------- /aima-all/release/images/vacuumapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/vacuumapp.png -------------------------------------------------------------------------------- /aimax-osm/lib/commons-compress-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aimax-osm/lib/commons-compress-1.1.jar -------------------------------------------------------------------------------- /aima-all/release/images/aimademoapps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/aimademoapps.png -------------------------------------------------------------------------------- /aima-all/release/images/mininaviapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/mininaviapp.png -------------------------------------------------------------------------------- /aima-all/release/images/tictactoeapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/tictactoeapp.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_setup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_setup.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_views.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_views.png -------------------------------------------------------------------------------- /aima-all/release/images/eightpuzzleapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/eightpuzzleapp.png -------------------------------------------------------------------------------- /aima-all/release/images/mapcoloringapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/mapcoloringapp.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_new_other.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_new_other.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_run_junit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_run_junit.png -------------------------------------------------------------------------------- /aima-all/release/images/osmviewerplusapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/osmviewerplusapp.png -------------------------------------------------------------------------------- /aima-all/release/jars/commons-compress-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/jars/commons-compress-1.1.jar -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_file_import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_file_import.png -------------------------------------------------------------------------------- /aima-all/release/images/routefindingagentapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/routefindingagentapp.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_installed_jre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_installed_jre.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_new_other_svn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_new_other_svn.png -------------------------------------------------------------------------------- /aima-all/release/images/osmsearchdemoagentapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/images/osmsearchdemoagentapp.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_import_existing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_import_existing.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_import_projects.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_import_projects.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_select_new_project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_select_new_project.png -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_svn_create_location.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_svn_create_location.png -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/data/DataResource.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.data; 2 | 3 | public class DataResource { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /aima-all/release/wiki/eclipse_references_workspace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnufs/aima-java/HEAD/aima-all/release/wiki/eclipse_references_workspace.png -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/common/Visitor.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.common; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface Visitor { 8 | 9 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/common/ParseTreeNode.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.common; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface ParseTreeNode { 8 | 9 | } -------------------------------------------------------------------------------- /aima-core/src/main/resource/aima/core/learning/data/rabbiteyes.txt: -------------------------------------------------------------------------------- 1 | parameter 1 = age in days 2 | parameter 2 = weights of eyelenses in milligrams 3 | 4 | source = Neural Networks A Comprehensive Foundation - Simon Haykin -------------------------------------------------------------------------------- /aimax-osm/lib/NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons Compress 2 | Copyright 2002-2010 The Apache Software Foundation 3 | 4 | This product includes software developed by 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/Randomizer.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface Randomizer { 8 | public double nextDouble(); 9 | } 10 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/applications/search/map/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains useful components for building graphical map agent 3 | * applications and one example application. 4 | */ 5 | package aima.gui.applications.search.map; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/AtomicSentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public abstract class AtomicSentence extends Sentence { 8 | 9 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/ComplexSentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public abstract class ComplexSentence extends Sentence { 8 | 9 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/xyenv/Wall.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.xyenv; 2 | 3 | import aima.core.agent.EnvironmentObject; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class Wall implements EnvironmentObject { 10 | 11 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/parsing/ast/Sentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.parsing.ast; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * @author Ciaran O'Reilly 6 | */ 7 | public interface Sentence extends FOLNode { 8 | Sentence copy(); 9 | } 10 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/MapEventListener.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | /** 4 | * Allows to listen to map changes. 5 | * @author Ruediger Lunde 6 | */ 7 | public interface MapEventListener { 8 | void eventHappened(MapEvent event); 9 | } 10 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/StandardizeApartIndexical.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public interface StandardizeApartIndexical { 8 | String getPrefix(); 9 | 10 | int getNextIndex(); 11 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/Attribute.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface Attribute { 8 | public String valueAsString(); 9 | 10 | public String name(); 11 | } 12 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/framework/MessageLogger.java: -------------------------------------------------------------------------------- 1 | package aima.gui.framework; 2 | 3 | /** 4 | * Simple interface for message logging. 5 | * 6 | * @author Ruediger Lunde 7 | */ 8 | public interface MessageLogger { 9 | public void log(String message); 10 | } 11 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/EnvironmentState.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * An interface used to indicate a possible state of an Environment. 5 | */ 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | */ 10 | public interface EnvironmentState { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains useful helper classes for applications which apply 3 | * search algorithms from the aima-core library to solve route finding 4 | * problems based on Open Street Map data. 5 | */ 6 | package aimax.osm.routing; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/ActivationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface ActivationFunction { 8 | double activation(double parameter); 9 | 10 | double deriv(double parameter); 11 | } 12 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/Learner.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface Learner { 8 | void train(DataSet ds); 9 | 10 | String predict(Example e); 11 | 12 | int[] test(DataSet ds); 13 | } 14 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/applications/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Contains useful applications including two stand-alone OSM viewers 3 | * and several demonstrations which combine OSM data with search algorithms 4 | * and agent concepts from the aima-core library. 5 | */ 6 | package aimax.osm.applications; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/otter/ClauseSimplifier.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.otter; 2 | 3 | import aima.core.logic.fol.kb.data.Clause; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public interface ClauseSimplifier { 10 | Clause simplify(Clause c); 11 | } 12 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/parsing/ast/Term.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.parsing.ast; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * @author Ciaran O'Reilly 8 | */ 9 | public interface Term extends FOLNode { 10 | List getArgs(); 11 | 12 | Term copy(); 13 | } 14 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/gps/GpsPositionListener.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.gps; 2 | 3 | /** 4 | * Interface which allows locators to inform interested listeners about 5 | * new gps fixes. 6 | * @author Ruediger Lunde 7 | */ 8 | public interface GpsPositionListener { 9 | void positionUpdated(GpsFix pos); 10 | } 11 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/trace/FOLModelEliminationTracer.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.trace; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public interface FOLModelEliminationTracer { 8 | void reset(); 9 | 10 | void increment(int depth, int noFarParents); 11 | } 12 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/EnvironmentObject.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * An interface used to indicate any object that can belong within an Environment. 5 | */ 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * @author Ciaran O'Reilly 10 | */ 11 | public interface EnvironmentObject { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/parsing/ast/AtomicSentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.parsing.ast; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public interface AtomicSentence extends Sentence { 10 | List getArgs(); 11 | 12 | AtomicSentence copy(); 13 | } 14 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/MapWayFilter.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | import aimax.osm.data.entities.MapWay; 4 | 5 | /** 6 | * Decides, whether a map way is accepted or not by checking its id. 7 | * @author Ruediger Lunde 8 | */ 9 | public interface MapWayFilter { 10 | public boolean isAccepted(MapWay way); 11 | } 12 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/viewer/MapViewEventListener.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.viewer; 2 | 3 | /** 4 | * Observer interface which should be implemented by clients interested in 5 | * map view events. 6 | * @author Ruediger Lunde 7 | */ 8 | public interface MapViewEventListener { 9 | void eventHappened(MapViewEvent event); 10 | } 11 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains implementations for all needed domain objects 3 | * and containers. The {@link aimax.osm.data.impl.DefaultMap} class 4 | * keeps the complete map in the RAM. So the maximum map size is limited by the 5 | * available memory size. 6 | */ 7 | package aimax.osm.data.impl; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/Search.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.agent.Action; 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * 10 | */ 11 | public interface Search { 12 | List search(Problem p) throws Exception; 13 | 14 | Metrics getMetrics(); 15 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/otter/ClauseFilter.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.otter; 2 | 3 | import java.util.Set; 4 | 5 | import aima.core.logic.fol.kb.data.Clause; 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | * 10 | */ 11 | public interface ClauseFilter { 12 | Set filter(Set clauses); 13 | } 14 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/AttributeSpecification.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface AttributeSpecification { 8 | 9 | boolean isValid(String string); 10 | 11 | String getAttributeName(); 12 | 13 | Attribute createAttribute(String rawValue); 14 | } 15 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/JavaRandomizer.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class JavaRandomizer implements Randomizer { 10 | static Random r = new Random(); 11 | 12 | public double nextDouble() { 13 | return r.nextDouble(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/Percept.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): pg 34.
5 | * We use the term percept to refer the agent's perceptual inputs at any given instant. 6 | */ 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * @author Ciaran O'Reilly 11 | */ 12 | public interface Percept { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/agent/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains a basis for building map agent applications based 3 | * on OSM data. It provides basic implementations of frame, environment view, 4 | * controller, and also a map adapter which provides access to OSM data using 5 | * the simple aima-core Map interface. 6 | */ 7 | package aimax.osm.routing.agent; -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/DataResource.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | import java.io.InputStream; 4 | 5 | /** 6 | * Provides a stream with OSM map data describing the city of Ulm. 7 | * @author Ruediger Lunde 8 | */ 9 | public class DataResource { 10 | public static InputStream getULMFileResource() { 11 | return DataResource.class.getResourceAsStream("ulm.osm"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aima-all/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/PureLinearActivationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class PureLinearActivationFunction implements ActivationFunction { 8 | 9 | public double activation(double parameter) { 10 | return parameter; 11 | } 12 | 13 | public double deriv(double parameter) { 14 | 15 | return 1; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/GoalTest.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): page 67. 5 | * 6 | * The goal test, which determines whether a given state is a goal state. 7 | */ 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public interface GoalTest { 14 | boolean isGoalState(Object state); 15 | } -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/entities/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package defines the domain objects. The interfaces of nodes and 3 | * ways are chosen very close to the corresponding objects within the Open 4 | * Street Map data format. Only minor administrative attributes are ignored. 5 | * Relations are currently not supported. 6 | * 7 | * @author Ruediger Lunde 8 | */ 9 | package aimax.osm.data.entities; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/NoOpAction.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | public class NoOpAction extends DynamicAction { 4 | 5 | public static final NoOpAction NO_OP = new NoOpAction(); 6 | 7 | // 8 | // START-Action 9 | public boolean isNoOp() { 10 | return true; 11 | } 12 | 13 | // END-Action 14 | // 15 | 16 | private NoOpAction() { 17 | super("NoOp"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/DynamicState.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.State; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | */ 8 | public class DynamicState extends ObjectWithDynamicAttributes implements State { 9 | public DynamicState() { 10 | 11 | } 12 | 13 | @Override 14 | public String describeType() { 15 | return State.class.getSimpleName(); 16 | } 17 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/DefaultStepCostFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import aima.core.agent.Action; 4 | 5 | /** 6 | * Returns one for every action. 7 | * 8 | * @author Ravi Mohan 9 | */ 10 | public class DefaultStepCostFunction implements StepCostFunction { 11 | 12 | public double c(Object stateFrom, Action action, Object stateTo) { 13 | return 1; 14 | } 15 | } -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/agent/impl/MockAgent.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.agent.impl; 2 | 3 | import aima.core.agent.AgentProgram; 4 | import aima.core.agent.impl.AbstractAgent; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class MockAgent extends AbstractAgent { 11 | public MockAgent() { 12 | } 13 | 14 | public MockAgent(AgentProgram agent) { 15 | super(agent); 16 | } 17 | } -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aima-java 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/Sentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import aima.core.logic.common.ParseTreeNode; 4 | import aima.core.logic.propositional.parsing.PLVisitor; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public abstract class Sentence implements ParseTreeNode { 11 | 12 | public abstract Object accept(PLVisitor plv, Object arg); 13 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/domain/FOLDomainListener.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.domain; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public interface FOLDomainListener { 8 | void skolemConstantAdded(FOLDomainSkolemConstantAddedEvent event); 9 | 10 | void skolemFunctionAdded(FOLDomainSkolemFunctionAddedEvent event); 11 | 12 | void answerLiteralNameAdded(FOLDomainAnswerLiteralAddedEvent event); 13 | } 14 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStep.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public interface ProofStep { 10 | int getStepNumber(); 11 | 12 | void setStepNumber(int step); 13 | 14 | List getPredecessorSteps(); 15 | 16 | String getProof(); 17 | 18 | String getJustification(); 19 | } 20 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/NNTrainingScheme.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import aima.core.util.math.Vector; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public interface NNTrainingScheme { 10 | Vector processInput(FeedForwardNeuralNetwork network, Vector input); 11 | 12 | void processError(FeedForwardNeuralNetwork network, Vector error); 13 | 14 | void setNeuralNetwork(FunctionApproximator ffnn); 15 | } 16 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/BidirectionalProblem.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * An interface describing a problem that can be tackled from both directions 5 | * at once (i.e InitialState<->Goal). 6 | */ 7 | 8 | /** 9 | * @author Ciaran O'Reilly 10 | * 11 | */ 12 | public interface BidirectionalProblem { 13 | Problem getOriginalProblem(); 14 | 15 | Problem getReverseProblem(); 16 | } 17 | -------------------------------------------------------------------------------- /aima-all/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aima-all 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /aima-core/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aima-core 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/logic/LogicTestSuite.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.logic; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | import aima.test.core.unit.logic.fol.FOLTestSuite; 7 | import aima.test.core.unit.logic.propositional.PropositionalTestSuite; 8 | 9 | @RunWith(Suite.class) 10 | @Suite.SuiteClasses( { FOLTestSuite.class, PropositionalTestSuite.class }) 11 | public class LogicTestSuite { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/EnvironmentViewNotifier.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public interface EnvironmentViewNotifier { 8 | /** 9 | * A simple notification message, to be forwarded to an Environment's 10 | * registered EnvironmentViews. 11 | * 12 | * @param msg 13 | * the message to be forwarded to the EnvironmentViews. 14 | */ 15 | void notifyViews(String msg); 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/HardLimitActivationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class HardLimitActivationFunction implements ActivationFunction { 8 | 9 | public double activation(double parameter) { 10 | 11 | if (parameter < 0.0) { 12 | return 0.0; 13 | } else { 14 | return 1.0; 15 | } 16 | } 17 | 18 | public double deriv(double parameter) { 19 | return 0.0; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/EvaluationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): page 92. 5 | * 6 | * The evaluation function is construed as a cost estimate, so the node with the lowest evaluation 7 | * is expanded first. 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public interface EvaluationFunction { 15 | double f(Node n); 16 | } 17 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/reader/TagListener.java: -------------------------------------------------------------------------------- 1 | // License: GPL. Copyright 2007-2008 by Brett Henderson and other contributors. 2 | // Modified by Ruediger Lunde, 2009 3 | package aimax.osm.reader; 4 | 5 | /** 6 | * Provides the definition of a class receiving tags. 7 | */ 8 | public interface TagListener { 9 | 10 | /** 11 | * Processes the tag. 12 | * 13 | * @param tag 14 | * The tag. 15 | */ 16 | void processTag(Tag tag); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/nqueens/NQueensGoalTest.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.nqueens; 2 | 3 | import aima.core.search.framework.GoalTest; 4 | 5 | /** 6 | * @author R. Lunde 7 | */ 8 | public class NQueensGoalTest implements GoalTest { 9 | 10 | public boolean isGoalState(Object state) { 11 | NQueensBoard board = (NQueensBoard) state; 12 | return board.getNumberOfQueensOnBoard() == board.getSize() 13 | && board.getNumberOfAttackingPairs() == 0; 14 | } 15 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/domain/FOLDomainEvent.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.domain; 2 | 3 | import java.util.EventObject; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public abstract class FOLDomainEvent extends EventObject { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | public FOLDomainEvent(Object source) { 14 | super(source); 15 | } 16 | 17 | public abstract void notifyListener(FOLDomainListener listener); 18 | } 19 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/SymbolComparator.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import java.util.Comparator; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class SymbolComparator implements Comparator { 10 | 11 | public int compare(Object symbol1, Object symbol2) { 12 | Symbol one = (Symbol) symbol1; 13 | Symbol two = (Symbol) symbol2; 14 | return one.getValue().compareTo(two.getValue()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/FunctionApproximator.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import aima.core.util.math.Vector; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public interface FunctionApproximator { 10 | /* 11 | * accepts input pattern and processe it returning an output value 12 | */ 13 | Vector processInput(Vector input); 14 | 15 | /* 16 | * accept an error and change the parameters to accomodate it 17 | */ 18 | void processError(Vector error); 19 | } 20 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/Quantifiers.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public class Quantifiers { 8 | public static final String FORALL = "FORALL"; 9 | public static final String EXISTS = "EXISTS"; 10 | 11 | public static boolean isFORALL(String quantifier) { 12 | return FORALL.equals(quantifier); 13 | } 14 | 15 | public static boolean isEXISTS(String quantifier) { 16 | return EXISTS.equals(quantifier); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/entities/WayRef.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data.entities; 2 | 3 | /** 4 | * Represents a reference to a way. The node index indicates, 5 | * where the node maintaining the reference occurs in the way definition. 6 | * 7 | * @author Ruediger Lunde 8 | */ 9 | public interface WayRef { 10 | /** Returns the referenced way. */ 11 | public MapWay getWay(); 12 | /** Returns a position within the sequence of nodes describing the way. */ 13 | public short getNodeIdx(); 14 | } 15 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/Model.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): pg 50.
5 | * 6 | * This knowledge about "how the world works" - whether implemented in simple Boolean circuits 7 | * or in complete scientific theories - is called a model of the world. An Agent that uses such a 8 | * model is called a model-based agent. 9 | */ 10 | 11 | /** 12 | * @author Ciaran O'Reilly 13 | */ 14 | public interface Model { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/DynamicEnvironmentState.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.EnvironmentState; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * @author Ciaran O'Reilly 8 | */ 9 | public class DynamicEnvironmentState extends ObjectWithDynamicAttributes 10 | implements EnvironmentState { 11 | public DynamicEnvironmentState() { 12 | 13 | } 14 | 15 | @Override 16 | public String describeType() { 17 | return EnvironmentState.class.getSimpleName(); 18 | } 19 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/csp/CSPStateListener.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.csp; 2 | 3 | /** 4 | * Interface which allows interested clients to register at a solution strategy 5 | * and follow their progress step by step. 6 | * 7 | * @author Ruediger Lunde 8 | */ 9 | public interface CSPStateListener { 10 | /** Informs about changed assignments. */ 11 | void stateChanged(Assignment assignment, CSP csp); 12 | /** Informs about changed domains (inferences). */ 13 | void stateChanged(CSP csp); 14 | } 15 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/FalseSentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import aima.core.logic.propositional.parsing.PLVisitor; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class FalseSentence extends AtomicSentence { 10 | @Override 11 | public String toString() { 12 | return "FALSE"; 13 | } 14 | 15 | @Override 16 | public Object accept(PLVisitor plv, Object arg) { 17 | return plv.visitFalseSentence(this, arg); 18 | } 19 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/TrueSentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import aima.core.logic.propositional.parsing.PLVisitor; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class TrueSentence extends AtomicSentence { 10 | 11 | @Override 12 | public String toString() { 13 | return "TRUE"; 14 | } 15 | 16 | @Override 17 | public Object accept(PLVisitor plv, Object arg) { 18 | return plv.visitTrueSentence(this, arg); 19 | } 20 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/adversarial/GameAgent.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.adversarial; 2 | 3 | import aima.core.agent.impl.AbstractAgent; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class GameAgent extends AbstractAgent { 10 | private Game game; 11 | 12 | public GameAgent(Game g) { 13 | this.game = g; 14 | } 15 | 16 | public void makeMiniMaxMove() { 17 | game.makeMiniMaxMove(); 18 | } 19 | 20 | public void makeAlphaBetaMove() { 21 | game.makeAlphaBetaMove(); 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/DefaultGoalTest.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * Checks whether a given state equals an explicitly specified goal state. 5 | * 6 | * @author Ruediger Lunde 7 | */ 8 | public class DefaultGoalTest implements GoalTest { 9 | private Object goalState; 10 | 11 | public DefaultGoalTest(Object goalState) { 12 | this.goalState = goalState; 13 | } 14 | 15 | public boolean isGoalState(Object state) { 16 | return goalState.equals(state); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/local/FitnessFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.local; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): page 127. 5 | * 6 | * Each state is rated by the objective function, or (in Genetic Algorithm terminology) the fitness function. 7 | * A fitness function should return higher values for better states. 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public interface FitnessFunction { 15 | double getValue(String individual); 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/eightpuzzle/EightPuzzleGoalTest.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.eightpuzzle; 2 | 3 | import aima.core.search.framework.GoalTest; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class EightPuzzleGoalTest implements GoalTest { 10 | EightPuzzleBoard goal = new EightPuzzleBoard(new int[] { 0, 1, 2, 3, 4, 5, 11 | 6, 7, 8 }); 12 | 13 | public boolean isGoalState(Object state) { 14 | EightPuzzleBoard board = (EightPuzzleBoard) state; 15 | return board.equals(goal); 16 | } 17 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/MoveToAction.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.map; 2 | 3 | import aima.core.agent.impl.DynamicAction; 4 | 5 | public class MoveToAction extends DynamicAction { 6 | public static final String ATTRIBUTE_MOVE_TO_LOCATION = "location"; 7 | 8 | public MoveToAction(String location) { 9 | super("moveTo"); 10 | setAttribute(ATTRIBUTE_MOVE_TO_LOCATION, location); 11 | } 12 | 13 | public String getToLocation() { 14 | return (String) getAttribute(ATTRIBUTE_MOVE_TO_LOCATION); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/Converter.java: -------------------------------------------------------------------------------- 1 | package aima.core.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | import java.util.List; 6 | import java.util.Set; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public class Converter { 13 | 14 | public List setToList(Set set) { 15 | List retVal = new ArrayList(set); 16 | return retVal; 17 | } 18 | 19 | public Set listToSet(List l) { 20 | Set retVal = new HashSet(l); 21 | return retVal; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aima-core/src/main/resource/aima/core/learning/data/orings.csv: -------------------------------------------------------------------------------- 1 | 6, 0, 66, 50, 1 2 | 6, 1, 70, 50, 2 3 | 6, 0, 69, 50, 3 4 | 6, 0, 68, 50, 4 5 | 6, 0, 67, 50, 5 6 | 6, 0, 72, 50, 6 7 | 6, 0, 73, 100, 7 8 | 6, 0, 70, 100, 8 9 | 6, 1, 57, 200, 9 10 | 6, 1, 63, 200, 10 11 | 6, 1, 70, 200, 11 12 | 6, 0, 78, 200, 12 13 | 6, 0, 67, 200, 13 14 | 6, 2, 53, 200, 14 15 | 6, 0, 67, 200, 15 16 | 6, 0, 75, 200, 16 17 | 6, 0, 70, 200, 17 18 | 6, 0, 81, 200, 18 19 | 6, 0, 76, 200, 19 20 | 6, 0, 79, 200, 20 21 | 6, 0, 75, 200, 21 22 | 6, 0, 76, 200, 22 23 | 6, 1, 58, 200, 23 24 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/nqueens/AttackingPairsHeuristic.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.nqueens; 2 | 3 | import aima.core.search.framework.HeuristicFunction; 4 | 5 | /** 6 | * Estimates the distance to goal by the number of attacking pairs of queens on 7 | * the board. 8 | * 9 | * @author R. Lunde 10 | */ 11 | public class AttackingPairsHeuristic implements HeuristicFunction { 12 | 13 | public double h(Object state) { 14 | NQueensBoard board = (NQueensBoard) state; 15 | return board.getNumberOfAttackingPairs(); 16 | } 17 | } -------------------------------------------------------------------------------- /aima-core/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/OsmDistanceStepCostFunction.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.routing; 2 | 3 | import aima.core.agent.Action; 4 | import aima.core.search.framework.StepCostFunction; 5 | 6 | /** 7 | * Assumes actions of type OsmMoveAction and gets the 8 | * corresponding travel distance. 9 | * @author Ruediger Lunde 10 | */ 11 | public class OsmDistanceStepCostFunction implements StepCostFunction { 12 | @Override 13 | public double c(Object s, Action a, Object prime) { 14 | return ((OsmMoveAction) a).getTravelDistance(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aima-gui/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/Action.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Describes an Action that can or has been taken by an Agent via one of its Actuators. 5 | */ 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | */ 10 | public interface Action { 11 | 12 | /** 13 | * Indicates whether or not this Action is a 'No Operation'.
14 | * Note: AIMA3e - NoOp, or no operation, is the name of an assembly 15 | * language instruction that does nothing. 16 | * 17 | * @return true if this is a NoOp Action. 18 | */ 19 | boolean isNoOp(); 20 | } 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/parsing/ast/FOLNode.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.parsing.ast; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.logic.common.ParseTreeNode; 6 | import aima.core.logic.fol.parsing.FOLVisitor; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * @author Ciaran O'Reilly 11 | */ 12 | public interface FOLNode extends ParseTreeNode { 13 | String getSymbolicName(); 14 | 15 | boolean isCompound(); 16 | 17 | List getArgs(); 18 | 19 | Object accept(FOLVisitor v, Object arg); 20 | 21 | FOLNode copy(); 22 | } 23 | -------------------------------------------------------------------------------- /aima-gui/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aima-gui 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jem.workbench.JavaEMFNature 16 | org.eclipse.jdt.core.javanature 17 | org.eclipse.jem.beaninfo.BeanInfoNature 18 | 19 | 20 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/framework/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package provides useful base classes for building graphical agent 3 | * applications. The design is inspired by the model-view-controller pattern. 4 | * An Environment serves as model, the AgentAppFrame 5 | * together with its embedded AgentAppEnvironmentView as view, 6 | * and the AgentAppController as controller. 7 | * The SimpleAgentApp application demonstrates, how this parts 8 | * can be plugged together. 9 | */ 10 | package aima.gui.framework; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/LogSigActivationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class LogSigActivationFunction implements ActivationFunction { 8 | 9 | public double activation(double parameter) { 10 | 11 | return 1.0 / (1.0 + Math.pow(Math.E, (-1.0 * parameter))); 12 | } 13 | 14 | public double deriv(double parameter) { 15 | // parameter = induced field 16 | // e == activation 17 | double e = 1.0 / (1.0 + Math.pow(Math.E, (-1.0 * parameter))); 18 | return e * (1.0 - e); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aimax-osm/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | aimax-osm 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jem.workbench.JavaEMFNature 16 | org.eclipse.jdt.core.javanature 17 | org.eclipse.jem.beaninfo.BeanInfoNature 18 | 19 | 20 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/HeuristicFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): page 92. 5 | * 6 | * a heuristic function, denoted h(n):
7 | * h(n) = estimated cost of the cheapest path from the state at node n to a goal state.
8 | * 9 | * Notice that h(n) takes a node as input, but, unlike g(n) it depends only on the state at that node. 10 | */ 11 | 12 | /** 13 | * @author Ravi Mohan 14 | * 15 | */ 16 | public interface HeuristicFunction { 17 | double h(Object state); 18 | } -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/entities/EntityViewInfo.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data.entities; 2 | 3 | /** 4 | * Entity view informations are attached to map entities and describe 5 | * how the entity shall be drawn. This interface hides presentation layer 6 | * aspects from the application layer. For data organization on application 7 | * layer, only the minimal visible scale is relevant. 8 | * @author Ruediger Lunde 9 | */ 10 | public interface EntityViewInfo { 11 | /** Defines, at which abstraction level the entity is still relevant. */ 12 | public float getMinVisibleScale(); 13 | } 14 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/State.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): pg 50.
5 | * 6 | * The most effective way to handle partial observability is for the agent to keep track of the 7 | * part of the world it can't see now. That is, the agent should maintain some sort of internal 8 | * state that depends on the percept history and thereby reflects at least some of the unobserved 9 | * aspects of the current state. 10 | */ 11 | 12 | /** 13 | * @author Ciaran O'Reilly 14 | */ 15 | public interface State { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/InferenceProcedure.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference; 2 | 3 | import aima.core.logic.fol.kb.FOLKnowledgeBase; 4 | import aima.core.logic.fol.parsing.ast.Sentence; 5 | 6 | /** 7 | * @author Ciaran O'Reilly 8 | * 9 | */ 10 | public interface InferenceProcedure { 11 | /** 12 | * 13 | * @param kb 14 | * the knowledge base against which the query is to be made. 15 | * @param aQuery 16 | * to be answered. 17 | * @return an InferenceResult. 18 | */ 19 | InferenceResult ask(FOLKnowledgeBase kb, Sentence aQuery); 20 | } 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/StringAttribute.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class StringAttribute implements Attribute { 8 | private StringAttributeSpecification spec; 9 | 10 | private String value; 11 | 12 | public StringAttribute(String value, StringAttributeSpecification spec) { 13 | this.spec = spec; 14 | this.value = value; 15 | } 16 | 17 | public String valueAsString() { 18 | return value.trim(); 19 | } 20 | 21 | public String name() { 22 | return spec.getAttributeName().trim(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/OsmResultFunction.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.routing; 2 | 3 | import aima.core.agent.Action; 4 | import aima.core.search.framework.ResultFunction; 5 | 6 | /** 7 | * Returns the end node of the movement if an OsmMoveAction 8 | * is provided, otherwise returns the unchanged state. 9 | * @author Ruediger Lunde 10 | */ 11 | public class OsmResultFunction implements ResultFunction { 12 | @Override 13 | public Object result(Object s, Action a) { 14 | if (a instanceof OsmMoveAction) 15 | return ((OsmMoveAction) a).getTo(); 16 | else 17 | return s; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/PathCostFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): page 78. 5 | * 6 | */ 7 | 8 | /** 9 | * @author Ciaran O'Reilly 10 | * 11 | */ 12 | public class PathCostFunction { 13 | public PathCostFunction() { 14 | } 15 | 16 | /** 17 | * 18 | * @param n 19 | * @return the cost, traditionally denoted by g(n), of the path from the 20 | * initial state to the node, as indicated by the parent pointers. 21 | */ 22 | public double g(Node n) { 23 | return n.getPathCost(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/learning/framework/MockDataSetSpecification.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.learning.framework; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import aima.core.learning.framework.DataSetSpecification; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public class MockDataSetSpecification extends DataSetSpecification { 13 | 14 | public MockDataSetSpecification(String targetAttributeName) { 15 | setTarget(targetAttributeName); 16 | } 17 | 18 | @Override 19 | public List getAttributeNames() { 20 | return new ArrayList(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/entities/Track.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data.entities; 2 | 3 | import java.util.List; 4 | 5 | import aimax.osm.data.Position; 6 | 7 | /** 8 | * Represents a track. A track is not really part of a map, but essential 9 | * for displaying route planning results and agent movements. Therefore, 10 | * it has been added here. 11 | * @author Ruediger Lunde 12 | */ 13 | public interface Track extends MapEntity { 14 | 15 | public List getNodes(); 16 | 17 | public MapNode getLastNode(); 18 | 19 | public void addNode(MapNode node); 20 | 21 | public void addNode(Position pos); 22 | } 23 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/learners/StumpLearner.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.learners; 2 | 3 | import aima.core.learning.framework.DataSet; 4 | import aima.core.learning.inductive.DecisionTree; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class StumpLearner extends DecisionTreeLearner { 11 | 12 | public StumpLearner(DecisionTree sl, String unable_to_classify) { 13 | super(sl, unable_to_classify); 14 | } 15 | 16 | @Override 17 | public void train(DataSet ds) { 18 | // System.out.println("Stump learner training"); 19 | // do nothing the stump is not inferred from the dataset 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/RabbitEyeDataSet.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class RabbitEyeDataSet extends NNDataSet { 10 | 11 | @Override 12 | public void setTargetColumns() { 13 | // assumed that data from file has been pre processed 14 | // TODO this should be 15 | // somewhere else,in the 16 | // super class. 17 | // Type != class Aargh! I want more 18 | // powerful type systems 19 | targetColumnNumbers = new ArrayList(); 20 | 21 | targetColumnNumbers.add(1); // using zero based indexing 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/otter/defaultimpl/DefaultClauseFilter.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.otter.defaultimpl; 2 | 3 | import java.util.Set; 4 | 5 | import aima.core.logic.fol.inference.otter.ClauseFilter; 6 | import aima.core.logic.fol.kb.data.Clause; 7 | 8 | /** 9 | * @author Ciaran O'Reilly 10 | * 11 | */ 12 | public class DefaultClauseFilter implements ClauseFilter { 13 | public DefaultClauseFilter() { 14 | 15 | } 16 | 17 | // 18 | // START-ClauseFilter 19 | public Set filter(Set clauses) { 20 | return clauses; 21 | } 22 | 23 | // END-ClauseFilter 24 | // 25 | } 26 | -------------------------------------------------------------------------------- /aima-all/build.properties: -------------------------------------------------------------------------------- 1 | # AIMA-ALL 2 | # DO NOT MODIFY THIS FILE DIRECTLY -- use build.properties.local 3 | # 4 | # To use different values for properties in this file: 5 | # a) Create a build.properties.local in the same directory as build.xml 6 | # or 7 | # b) Use -Dproperty=value arguments 8 | 9 | # VERSION 10 | aima-all.version=1.4.1-Minor-Fixes 11 | # DIRECTORY LOCATIONS 12 | path.to.aima-core.project=../aima-core 13 | path.to.aima-gui.project=../aima-gui 14 | path.to.aimax-osm.project=../aimax-osm 15 | # TEMP DIRECTORIES FOR RELEASING 16 | aima-all.dir.build=${aima-all.basedir}/build 17 | aima-all.dir.build.release=${aima-all.dir.build}/release -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/probability/MockRandomizer.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.probability; 2 | 3 | import aima.core.probability.Randomizer; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class MockRandomizer implements Randomizer { 10 | 11 | private double[] values; 12 | 13 | private int index; 14 | 15 | public MockRandomizer(double[] values) { 16 | this.values = values; 17 | this.index = 0; 18 | } 19 | 20 | public double nextDouble() { 21 | if (index == values.length) { 22 | index = 0; 23 | } 24 | 25 | double value = values[index]; 26 | index++; 27 | return value; 28 | } 29 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPPerception.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class MDPPerception { 8 | 9 | private STATE_TYPE state; 10 | 11 | private double reward; 12 | 13 | public MDPPerception(STATE_TYPE state, double reward) { 14 | this.state = state; 15 | this.reward = reward; 16 | } 17 | 18 | public double getReward() { 19 | return reward; 20 | } 21 | 22 | public STATE_TYPE getState() { 23 | return state; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "[ " + state.toString() + " , " + reward + " ] "; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/agent/AgentTestSuite.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.agent; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | import aima.test.core.unit.agent.impl.DynamicPerceptTest; 7 | import aima.test.core.unit.agent.impl.PerceptSequenceTest; 8 | import aima.test.core.unit.agent.impl.aprog.TableDrivenAgentProgramTest; 9 | import aima.test.core.unit.agent.impl.aprog.simplerule.RuleTest; 10 | 11 | @RunWith(Suite.class) 12 | @Suite.SuiteClasses( { RuleTest.class, TableDrivenAgentProgramTest.class, 13 | DynamicPerceptTest.class, PerceptSequenceTest.class }) 14 | public class AgentTestSuite { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/CancelableThread.java: -------------------------------------------------------------------------------- 1 | package aima.core.util; 2 | 3 | /** 4 | * Implements a thread with an additional flag indicating cancellation. 5 | * 6 | * @author R. Lunde 7 | * 8 | */ 9 | public class CancelableThread extends Thread { 10 | 11 | public static boolean currIsCanceled() { 12 | if (Thread.currentThread() instanceof CancelableThread) 13 | return ((CancelableThread) Thread.currentThread()).isCanceled; 14 | return false; 15 | } 16 | 17 | private boolean isCanceled; 18 | 19 | public boolean isCanceled() { 20 | return isCanceled; 21 | } 22 | 23 | public void cancel() { 24 | isCanceled = true; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPFactory.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | import aima.core.environment.cellworld.CellWorld; 4 | import aima.core.environment.cellworld.CellWorldPosition; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class MDPFactory { 11 | 12 | public static MDP createFourByThreeMDP() { 13 | 14 | CellWorld cw = new CellWorld(3, 4, 0.4); 15 | cw = new CellWorld(3, 4, -0.04); 16 | 17 | cw.markBlocked(2, 2); 18 | 19 | cw.setTerminalState(2, 4); 20 | cw.setReward(2, 4, -1); 21 | 22 | cw.setTerminalState(3, 4); 23 | cw.setReward(3, 4, 1); 24 | return cw.asMdp(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/ArrayIterator.java: -------------------------------------------------------------------------------- 1 | package aima.core.util; 2 | 3 | import java.util.Iterator; 4 | 5 | /** 6 | * Iterates efficiently through an array. 7 | * 8 | * @author Ruediger Lunde 9 | */ 10 | public class ArrayIterator implements Iterator { 11 | 12 | T[] values; 13 | int counter; 14 | 15 | public ArrayIterator(T[] values) { 16 | this.values = values; 17 | counter = 0; 18 | } 19 | 20 | public boolean hasNext() { 21 | return counter < values.length; 22 | } 23 | 24 | public T next() { 25 | return values[counter++]; 26 | } 27 | 28 | public void remove() { 29 | throw new UnsupportedOperationException(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/WayNodeProvider.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | import java.util.List; 4 | 5 | import aimax.osm.data.entities.MapNode; 6 | import aimax.osm.data.entities.MapWay; 7 | 8 | /** 9 | * Provides different abstractions of a way for rendering. 10 | * @author Ruediger Lunde 11 | */ 12 | public interface WayNodeProvider { 13 | /** 14 | * Returns a list of nodes describing the specified way which 15 | * is suitable for the specified scale. Number of nodes will 16 | * typically decrease with decreasing scale 17 | * (e.g. 1/10 000 -> 80 nodes; 1/100 000 -> 10 nodes). 18 | */ 19 | public List getWayNodes(MapWay way, float scale); 20 | } 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/local/Scheduler.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.local; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Scheduler { 8 | 9 | private final int k, limit; 10 | 11 | private final double lam; 12 | 13 | public Scheduler(int k, double lam, int limit) { 14 | this.k = k; 15 | this.lam = lam; 16 | this.limit = limit; 17 | } 18 | 19 | public Scheduler() { 20 | this.k = 20; 21 | this.lam = 0.045; 22 | this.limit = 100; 23 | } 24 | 25 | public double getTemp(int t) { 26 | if (t < limit) { 27 | double res = k * Math.exp((-1) * lam * t); 28 | return res; 29 | } else { 30 | return 0.0; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/NumericAttribute.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class NumericAttribute implements Attribute { 8 | double value; 9 | 10 | private NumericAttributeSpecification spec; 11 | 12 | public NumericAttribute(double rawvalue, NumericAttributeSpecification spec) { 13 | this.value = rawvalue; 14 | this.spec = spec; 15 | } 16 | 17 | public String valueAsString() { 18 | return Double.toString(value); 19 | } 20 | 21 | public String name() { 22 | return spec.getAttributeName().trim(); 23 | } 24 | 25 | public double valueAsDouble() { 26 | return value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/learning/inductive/MockDLTestFactory.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.learning.inductive; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.learning.framework.DataSet; 6 | import aima.core.learning.inductive.DLTest; 7 | import aima.core.learning.inductive.DLTestFactory; 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public class MockDLTestFactory extends DLTestFactory { 14 | 15 | private List tests; 16 | 17 | public MockDLTestFactory(List tests) { 18 | this.tests = tests; 19 | } 20 | 21 | @Override 22 | public List createDLTestsWithAttributeCount(DataSet ds, int i) { 23 | return tests; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package together with its sub-packages contains the application layer 3 | * classes of the OSM viewer. 4 | * The most important interface is OsmMap. It defines a 5 | * container for all map information and serves as model for the viewer. The 6 | * provided operations focus on read access. To create and modify 7 | * OSM maps, a builder interface called MapBuilder is provided. 8 | * 9 | *

For the container as well as for the contained map data objects an example 10 | * implementation is provided in the impl sub-package.

11 | * 12 | * @author Ruediger Lunde 13 | */ 14 | package aimax.osm.data; -------------------------------------------------------------------------------- /aima-core/src/main/resource/aima/core/learning/data/restaurant.csv: -------------------------------------------------------------------------------- 1 | Yes No No Yes Some $$$ No Yes French 0-10 Yes 2 | Yes No No Yes Full $ No No Thai 30-60 No 3 | No Yes No No Some $ No No Burger 0-10 Yes 4 | Yes No Yes Yes Full $ Yes No Thai 10-30 Yes 5 | Yes No Yes No Full $$$ No Yes French >60 No 6 | No Yes No Yes Some $$ Yes Yes Italian 0-10 Yes 7 | No Yes No No None $ Yes No Burger 0-10 No 8 | No No No Yes Some $$ Yes Yes Thai 0-10 Yes 9 | No Yes Yes No Full $ Yes No Burger >60 No 10 | Yes Yes Yes Yes Full $$$ No Yes Italian 10-30 No 11 | No No No No None $ No No Thai 0-10 No 12 | Yes Yes Yes Yes Full $ No No Burger 30-60 Yes 13 | -------------------------------------------------------------------------------- /aima-gui/build.properties: -------------------------------------------------------------------------------- 1 | # AIMA-GUI 2 | # DO NOT MODIFY THIS FILE DIRECTLY -- use build.properties.local 3 | # 4 | # To use different values for properties in this file: 5 | # a) Create a build.properties.local in the same directory as build.xml 6 | # or 7 | # b) Use -Dproperty=value arguments 8 | 9 | # VERSION 10 | aima-gui.version=1.0.3 11 | # DIRECTORY LOCATIONS 12 | path.to.aima-core.project=../aima-core 13 | aima-gui.dir.src=${aima-gui.basedir}/src 14 | # TEMP DIRECTORIES FOR BUILDING and RELEASING 15 | aima-gui.dir.build=${aima-gui.basedir}/build 16 | aima-gui.dir.build.bin=${aima-gui.dir.build}/bin 17 | aima-gui.dir.build.doc=${aima-gui.dir.build}/doc 18 | aima-gui.dir.build.release=${aima-gui.dir.build}/release -------------------------------------------------------------------------------- /aimax-osm/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/viewer/MapViewEvent.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.viewer; 2 | 3 | /** 4 | * Allows map views to inform interested listeners about user interactions 5 | * such as zooming or marker setting. 6 | * @author Ruediger Lunde 7 | * 8 | */ 9 | public class MapViewEvent { 10 | MapViewPane source; 11 | Type type; 12 | public MapViewEvent(MapViewPane source, Type type) { 13 | this.source = source; 14 | this.type = type; 15 | } 16 | 17 | public MapViewPane getSource() { 18 | return source; 19 | } 20 | 21 | public Type getType() { 22 | return type; 23 | } 24 | 25 | public enum Type { 26 | ADJUST, ZOOM, MAP_NEW, MARKER_ADDED, TRK_PT_ADDED, TMP_NODES_REMOVED 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aimax-osm/LICENSE.txt: -------------------------------------------------------------------------------- 1 | OSM library extension for AIMA-JAVA. 2 | 3 | Copyright (C) 2009-2011 Ruediger Lunde 4 | 5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 6 | 7 | This program 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 General Public License for more details. 8 | 9 | You should have received a copy of the GNU General Public License along with this program; if not, see . 10 | 11 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/Numerizer.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.learning.framework.Example; 6 | import aima.core.util.datastructure.Pair; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public interface Numerizer { 13 | // A Numerizer understands how to convert an example from a particular 14 | // dataset 15 | // into a Pair of lists of doubles .The first represents the input to the 16 | // neural network and the second represents the desired output 17 | // See IrisDataSetNumerizer for a concrete example 18 | Pair, List> numerize(Example e); 19 | 20 | String denumerize(List outputValue); 21 | } 22 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/adversarial/AlphaBeta.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.adversarial; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class AlphaBeta { 8 | private int alpha; 9 | 10 | private int beta; 11 | 12 | public AlphaBeta(int alpha, int beta) { 13 | this.alpha = alpha; 14 | this.beta = beta; 15 | } 16 | 17 | public int alpha() { 18 | return alpha; 19 | } 20 | 21 | public void setAlpha(int alpha) { 22 | this.alpha = alpha; 23 | } 24 | 25 | public int beta() { 26 | return beta; 27 | } 28 | 29 | public void setBeta(int beta) { 30 | this.beta = beta; 31 | } 32 | 33 | public AlphaBeta copy() { 34 | return new AlphaBeta(alpha, beta); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/gps/GpsFix.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.gps; 2 | 3 | import aimax.osm.data.Position; 4 | 5 | /** 6 | * Maintains measurement quality and position informations. 7 | * @author Ruediger Lunde 8 | */ 9 | public class GpsFix extends Position { 10 | private boolean posOk; 11 | 12 | public GpsFix(boolean posOK, float lat, float lon) { 13 | super(lat, lon); 14 | this.posOk = posOK; 15 | } 16 | 17 | public boolean isPosOk() { 18 | return posOk; 19 | } 20 | 21 | public float getLat() { 22 | return lat; 23 | } 24 | 25 | public float getLon() { 26 | return lon; 27 | } 28 | 29 | public String toString() { 30 | return "Lat: " + lat + " Lon: " + lon + (posOk ? "" : " ?"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/aprog/simplerule/Condition.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl.aprog.simplerule; 2 | 3 | import aima.core.agent.impl.ObjectWithDynamicAttributes; 4 | 5 | /** 6 | * Base abstract class for describing conditions. 7 | * 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public abstract class Condition { 15 | public abstract boolean evaluate(ObjectWithDynamicAttributes p); 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | if (o == null || !(o instanceof Condition)) { 20 | return super.equals(o); 21 | } 22 | return (toString().equals(((Condition) o).toString())); 23 | } 24 | 25 | @Override 26 | public int hashCode() { 27 | return toString().hashCode(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/trace/FOLTFMResolutionTracer.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.trace; 2 | 3 | import java.util.Set; 4 | 5 | import aima.core.logic.fol.inference.InferenceResult; 6 | import aima.core.logic.fol.kb.data.Clause; 7 | 8 | /** 9 | * @author Ciaran O'Reilly 10 | * 11 | */ 12 | public interface FOLTFMResolutionTracer { 13 | void stepStartWhile(Set clauses, int totalNoClauses, 14 | int totalNoNewCandidateClauses); 15 | 16 | void stepOuterFor(Clause i); 17 | 18 | void stepInnerFor(Clause i, Clause j); 19 | 20 | void stepResolved(Clause iFactor, Clause jFactor, Set resolvents); 21 | 22 | void stepFinished(Set clauses, InferenceResult result); 23 | } 24 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/EnumerateJointAsk.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability; 2 | 3 | import java.util.Hashtable; 4 | 5 | import aima.core.util.Util; 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * 10 | */ 11 | public class EnumerateJointAsk { 12 | 13 | public static double[] ask(Query q, ProbabilityDistribution pd) { 14 | double[] probDist = new double[2]; 15 | Hashtable h = q.getEvidenceVariables(); 16 | 17 | // true probability 18 | h.put(q.getQueryVariable(), new Boolean(true)); 19 | probDist[0] = pd.probabilityOf(h); 20 | // false probability 21 | h.put(q.getQueryVariable(), new Boolean(false)); 22 | probDist[1] = pd.probabilityOf(h); 23 | return Util.normalize(probDist); 24 | } 25 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/CutOffIndicatorAction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import aima.core.agent.impl.DynamicAction; 4 | 5 | /** 6 | * A NoOp action that indicates a CutOff has occurred in a search. Used 7 | * primarily by DepthLimited and IterativeDeepening search routines. 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | */ 13 | public class CutOffIndicatorAction extends DynamicAction { 14 | public static final CutOffIndicatorAction CUT_OFF = new CutOffIndicatorAction(); 15 | 16 | // 17 | // START-Action 18 | public boolean isNoOp() { 19 | return true; 20 | } 21 | 22 | // END-Action 23 | // 24 | 25 | private CutOffIndicatorAction() { 26 | super("CutOff"); 27 | } 28 | } -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/EntityVisitor.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | import aimax.osm.data.entities.MapNode; 4 | import aimax.osm.data.entities.MapWay; 5 | import aimax.osm.data.entities.Track; 6 | /** 7 | * The visitor pattern is used here, to iterate across sets 8 | * of different kinds of map entities in a flexible manner. 9 | * This interface supports for example the implementation 10 | * of different renderers, which find the right code for a 11 | * given entity instance without class checking in if statements. 12 | * @author Ruediger Lunde 13 | */ 14 | public interface EntityVisitor { 15 | public void visitMapNode(MapNode node); 16 | public void visitMapWay(MapWay way); 17 | public void visitTrack(Track track); 18 | } 19 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/StraightLineDistanceHeuristicFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.map; 2 | 3 | import aima.core.util.datastructure.Point2D; 4 | 5 | /** 6 | * @author Ruediger Lunde 7 | */ 8 | public class StraightLineDistanceHeuristicFunction extends 9 | AdaptableHeuristicFunction { 10 | 11 | public StraightLineDistanceHeuristicFunction(Object goal, Map map) { 12 | this.goal = goal; 13 | this.map = map; 14 | } 15 | 16 | public double h(Object state) { 17 | double result = 0.0; 18 | Point2D pt1 = map.getPosition((String) state); 19 | Point2D pt2 = map.getPosition((String) goal); 20 | if (pt1 != null && pt2 != null) { 21 | result = pt1.distance(pt2); 22 | } 23 | return result; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPSource.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.probability.Randomizer; 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * 10 | */ 11 | public interface MDPSource { 12 | MDP asMdp(); 13 | 14 | STATE_TYPE getInitialState(); 15 | 16 | MDPTransitionModel getTransitionModel(); 17 | 18 | MDPRewardFunction getRewardFunction(); 19 | 20 | List getNonFinalStates(); 21 | 22 | List getFinalStates(); 23 | 24 | MDPPerception execute(STATE_TYPE state, ACTION_TYPE action, 25 | Randomizer r); 26 | 27 | List getAllActions(); 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/util/UtilTestSuite.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.util; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | import aima.test.core.unit.util.datastructure.FIFOQueueTest; 7 | import aima.test.core.unit.util.datastructure.LIFOQueueTest; 8 | import aima.test.core.unit.util.datastructure.TableTest; 9 | import aima.test.core.unit.util.datastructure.XYLocationTest; 10 | import aima.test.core.unit.util.math.MixedRadixNumberTest; 11 | 12 | @RunWith(Suite.class) 13 | @Suite.SuiteClasses( { FIFOQueueTest.class, LIFOQueueTest.class, 14 | TableTest.class, XYLocationTest.class, MixedRadixNumberTest.class, 15 | SetOpsTest.class, UtilTest.class }) 16 | public class UtilTestSuite { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/reasoning/Particle.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.reasoning; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Particle { 8 | 9 | private String state; 10 | 11 | private double weight; 12 | 13 | public Particle(String state, double weight) { 14 | this.state = state; 15 | this.weight = weight; 16 | } 17 | 18 | public Particle(String state) { 19 | this(state, 0); 20 | } 21 | 22 | public boolean hasState(String aState) { 23 | return state.equals(aState); 24 | } 25 | 26 | public String getState() { 27 | return state; 28 | } 29 | 30 | public double getWeight() { 31 | return weight; 32 | } 33 | 34 | public void setWeight(double particleWeight) { 35 | weight = particleWeight; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/PrioritySearch.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import java.util.Comparator; 4 | import java.util.List; 5 | 6 | import aima.core.agent.Action; 7 | import aima.core.util.datastructure.PriorityQueue; 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public abstract class PrioritySearch implements Search { 14 | protected QueueSearch search; 15 | 16 | public List search(Problem p) throws Exception { 17 | return search.search(p, new PriorityQueue(5, getComparator())); 18 | } 19 | 20 | public Metrics getMetrics() { 21 | return search.getMetrics(); 22 | } 23 | 24 | // 25 | // PROTECTED METHODS 26 | // 27 | protected abstract Comparator getComparator(); 28 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/cellworld/Cell.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.cellworld; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Cell { 8 | private int x_co_ord, y_co_ord; 9 | 10 | private double reward; 11 | 12 | public Cell(int i, int j, double reward) { 13 | this.x_co_ord = i; 14 | this.y_co_ord = j; 15 | this.reward = reward; 16 | } 17 | 18 | public int getY() { 19 | return y_co_ord; 20 | } 21 | 22 | public int getX() { 23 | return x_co_ord; 24 | } 25 | 26 | public double getReward() { 27 | return reward; 28 | } 29 | 30 | public void setReward(double reward) { 31 | this.reward = reward; 32 | } 33 | 34 | public CellWorldPosition position() { 35 | return new CellWorldPosition(getX(), getY()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/AbstractProofStep.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public abstract class AbstractProofStep implements ProofStep { 10 | private int step = 0; 11 | 12 | public AbstractProofStep() { 13 | 14 | } 15 | 16 | // 17 | // START-ProofStep 18 | public int getStepNumber() { 19 | return step; 20 | } 21 | 22 | public void setStepNumber(int step) { 23 | this.step = step; 24 | } 25 | 26 | public abstract List getPredecessorSteps(); 27 | 28 | public abstract String getProof(); 29 | 30 | public abstract String getJustification(); 31 | 32 | // END-ProofStep 33 | // 34 | } 35 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/csp/Variable.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.csp; 2 | 3 | /** 4 | * A variable is a distinguishable object with a name. 5 | * 6 | * @author Ruediger Lunde 7 | */ 8 | public class Variable { 9 | private String name; 10 | 11 | public Variable(String name) { 12 | this.name = name; 13 | } 14 | 15 | public String getName() { 16 | return name; 17 | } 18 | 19 | public String toString() { 20 | return name; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object obj) { 25 | if (obj instanceof Variable) { 26 | return this.name.equals(((Variable)obj).name); 27 | } 28 | return super.equals(obj); 29 | } 30 | 31 | @Override 32 | public int hashCode() { 33 | return name.hashCode(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/util/datastructure/XYLocationTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.util.datastructure; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import aima.core.util.datastructure.XYLocation; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public class XYLocationTest { 13 | 14 | @Test 15 | public void testXYLocationAtributeSettingOnConstruction() { 16 | XYLocation loc = new XYLocation(3, 4); 17 | Assert.assertEquals(3, loc.getXCoOrdinate()); 18 | Assert.assertEquals(4, loc.getYCoOrdinate()); 19 | } 20 | 21 | @Test 22 | public void testEquality() { 23 | XYLocation loc1 = new XYLocation(3, 4); 24 | XYLocation loc2 = new XYLocation(3, 4); 25 | Assert.assertEquals(loc1, loc2); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aimax-osm/build.properties: -------------------------------------------------------------------------------- 1 | # AIMAX-OSM 2 | # DO NOT MODIFY THIS FILE DIRECTLY -- use build.properties.local 3 | # 4 | # To use different values for properties in this file: 5 | # a) Create a build.properties.local in the same directory as build.xml 6 | # or 7 | # b) Use -Dproperty=value arguments 8 | 9 | # VERSION 10 | aimax-osm.version=2.0.1 11 | # DIRECTORY LOCATIONS 12 | path.to.aima-gui.project=../aima-gui 13 | aimax-osm.dir.src=${aimax-osm.basedir}/src 14 | # TEMP DIRECTORIES FOR BUILDING and RELEASING 15 | aimax-osm.dir.lib=${aimax-osm.basedir}/lib 16 | aimax-osm.dir.build=${aimax-osm.basedir}/build 17 | aimax-osm.dir.build.bin=${aimax-osm.dir.build}/bin 18 | aimax-osm.dir.build.doc=${aimax-osm.dir.build}/doc 19 | aimax-osm.dir.build.release=${aimax-osm.dir.build}/release -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/reader/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains a simple reader for XML files using the 3 | * OSM syntax. To use it, just take a look at classes OsmReader, 4 | * FilteringOsmReader, and Bz2OsmReader. 5 | * The architecture relies on the application of the state 6 | * design pattern (GoF). All element processors can be viewed as states 7 | * in this sense. 8 | *

The SAX-parser is a strongly simplified version of the Osmosis OSM 9 | * file parser, written by Brett Henderson. Many parts of the code remained 10 | * almost unchanged. Some refactoring was done to reduce the number of 11 | * classes needed and to improve speed by focusing on the relevant 12 | * data. 13 | */ 14 | package aimax.osm.reader; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/domain/FOLDomainAnswerLiteralAddedEvent.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.domain; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public class FOLDomainAnswerLiteralAddedEvent extends FOLDomainEvent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private String answerLiteralName; 12 | 13 | public FOLDomainAnswerLiteralAddedEvent(Object source, 14 | String answerLiteralName) { 15 | super(source); 16 | 17 | this.answerLiteralName = answerLiteralName; 18 | } 19 | 20 | public String getAnswerLiteralNameName() { 21 | return answerLiteralName; 22 | } 23 | 24 | @Override 25 | public void notifyListener(FOLDomainListener listener) { 26 | listener.answerLiteralNameAdded(this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/PerceptToStateFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import aima.core.agent.Percept; 4 | 5 | /** 6 | * This interface is to define how to Map a Percept to a State representation 7 | * for a problem solver within a specific environment. This arises in the 8 | * description of the Online Search algorithms from Chapter 4. 9 | */ 10 | 11 | /** 12 | * @author Ciaran O'Reilly 13 | * 14 | */ 15 | public interface PerceptToStateFunction { 16 | 17 | /** 18 | * Get the problem state associated with a Percept. 19 | * 20 | * @param p 21 | * the percept to be transformed to a problem state. 22 | * @return a problem state derived from the Percept p. 23 | */ 24 | Object getState(Percept p); 25 | } 26 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/aprog/simplerule/NOTCondition.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl.aprog.simplerule; 2 | 3 | import aima.core.agent.impl.ObjectWithDynamicAttributes; 4 | 5 | /** 6 | * Implementation of a NOT condition. 7 | * 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public class NOTCondition extends Condition { 15 | private Condition con; 16 | 17 | public NOTCondition(Condition aCon) { 18 | assert (null != aCon); 19 | 20 | con = aCon; 21 | } 22 | 23 | @Override 24 | public boolean evaluate(ObjectWithDynamicAttributes p) { 25 | return (!con.evaluate(p)); 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | StringBuilder sb = new StringBuilder(); 31 | 32 | return sb.append("![").append(con).append("]").toString(); 33 | } 34 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/IrisNNDataSet.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class IrisNNDataSet extends NNDataSet { 10 | 11 | @Override 12 | public void setTargetColumns() { 13 | // assumed that data from file has been pre processed 14 | // TODO this should be 15 | // somewhere else,in the 16 | // super class. 17 | // Type != class Aargh! I want more 18 | // powerful type systems 19 | targetColumnNumbers = new ArrayList(); 20 | int size = nds.get(0).size(); 21 | targetColumnNumbers.add(size - 1); // last column 22 | targetColumnNumbers.add(size - 2); // last but one column 23 | targetColumnNumbers.add(size - 3); // and the one before that 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/domain/FOLDomainSkolemConstantAddedEvent.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.domain; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public class FOLDomainSkolemConstantAddedEvent extends FOLDomainEvent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private String skolemConstantName; 12 | 13 | public FOLDomainSkolemConstantAddedEvent(Object source, 14 | String skolemConstantName) { 15 | super(source); 16 | 17 | this.skolemConstantName = skolemConstantName; 18 | } 19 | 20 | public String getSkolemConstantName() { 21 | return skolemConstantName; 22 | } 23 | 24 | @Override 25 | public void notifyListener(FOLDomainListener listener) { 26 | listener.skolemConstantAdded(this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/domain/FOLDomainSkolemFunctionAddedEvent.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.domain; 2 | 3 | /** 4 | * @author Ciaran O'Reilly 5 | * 6 | */ 7 | public class FOLDomainSkolemFunctionAddedEvent extends FOLDomainEvent { 8 | 9 | private static final long serialVersionUID = 1L; 10 | 11 | private String skolemFunctionName; 12 | 13 | public FOLDomainSkolemFunctionAddedEvent(Object source, 14 | String skolemFunctionName) { 15 | super(source); 16 | 17 | this.skolemFunctionName = skolemFunctionName; 18 | } 19 | 20 | public String getSkolemConstantName() { 21 | return skolemFunctionName; 22 | } 23 | 24 | @Override 25 | public void notifyListener(FOLDomainListener listener) { 26 | listener.skolemFunctionAdded(this); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/DynamicAction.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.Action; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | */ 8 | public class DynamicAction extends ObjectWithDynamicAttributes implements 9 | Action { 10 | public static final String ATTRIBUTE_NAME = "name"; 11 | 12 | // 13 | 14 | public DynamicAction(String name) { 15 | this.setAttribute(ATTRIBUTE_NAME, name); 16 | } 17 | 18 | public String getName() { 19 | return (String) getAttribute(ATTRIBUTE_NAME); 20 | } 21 | 22 | // 23 | // START-Action 24 | public boolean isNoOp() { 25 | return false; 26 | } 27 | 28 | // END-Action 29 | // 30 | 31 | @Override 32 | public String describeType() { 33 | return Action.class.getSimpleName(); 34 | } 35 | } -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/demo/logic/DPLLDemo.java: -------------------------------------------------------------------------------- 1 | package aima.gui.demo.logic; 2 | 3 | import aima.core.logic.propositional.algorithms.DPLL; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class DPLLDemo { 10 | private static DPLL dpll = new DPLL(); 11 | 12 | public static void main(String[] args) { 13 | displayDPLLSatisfiableStatus("( A AND B )"); 14 | displayDPLLSatisfiableStatus("( A AND (NOT A) )"); 15 | // displayDPLLSatisfiableStatus("((A OR (NOT A)) AND (A OR B))"); 16 | } 17 | 18 | public static void displayDPLLSatisfiableStatus(String query) { 19 | if (dpll.dpllSatisfiable(query)) { 20 | System.out.println(query + " is (DPLL) satisfiable"); 21 | } else { 22 | System.out.println(query + " is NOT (DPLL) satisfiable"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/impl/DefaultWayRef.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data.impl; 2 | 3 | import aimax.osm.data.entities.MapWay; 4 | import aimax.osm.data.entities.WayRef; 5 | 6 | /** 7 | * Represents a reference to a way. The node index indicates, 8 | * where the node maintaining the reference occurs in the way definition. 9 | * @author Ruediger Lunde 10 | */ 11 | public class DefaultWayRef implements WayRef { 12 | private MapWay way; 13 | private short nodeIdx; 14 | 15 | public DefaultWayRef(MapWay way, short nodeIdx) { 16 | this.way = way; 17 | this.nodeIdx = nodeIdx; 18 | } 19 | /** {@inheritDoc} */ 20 | @Override 21 | public MapWay getWay() { return way; } 22 | /** {@inheritDoc} */ 23 | @Override 24 | public short getNodeIdx() { return nodeIdx; } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/agent/PointLatLon.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.routing.agent; 2 | 3 | import aima.core.util.datastructure.Point2D; 4 | import aimax.osm.data.Position; 5 | 6 | /** 7 | * Special Point2D implementation which provides correct 8 | * distance values in kilometer for geographical positions (x=lon and y=lat). 9 | * @author Ruediger Lunde 10 | */ 11 | public class PointLatLon extends Point2D { 12 | public PointLatLon(double lat, double lon) { 13 | super(lon, lat); 14 | } 15 | 16 | public double getLat() { return getY(); } 17 | 18 | public double getLon() { return getX(); } 19 | 20 | public double distance(Point2D pt) { 21 | return Position.getDistKM((float) getY(), (float) getX(), 22 | (float) pt.getY(), (float) pt.getX()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/knowledge/Hypothesis.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.knowledge; 2 | 3 | import aima.core.logic.fol.parsing.ast.Sentence; 4 | 5 | /** 6 | * @author Ciaran O'Reilly 7 | * 8 | */ 9 | public class Hypothesis { 10 | private Sentence hypothesis = null; 11 | 12 | public Hypothesis(Sentence hypothesis) { 13 | this.hypothesis = hypothesis; 14 | } 15 | 16 | /** 17 | *

18 | 	 * FORALL v (Classification(v) <=> ((Description1(v) AND Description2(v, Constant1))
19 | 	 *                                 OR
20 | 	 *                                  (Description1(v) AND Description3(v))
21 | 	 *                                 )
22 | 	 *          )
23 | 	 * 
24 | */ 25 | public Sentence getHypothesis() { 26 | return hypothesis; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/reasoning/HMMAgent.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.reasoning; 2 | 3 | import aima.core.probability.RandomVariable; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class HMMAgent { 10 | private HiddenMarkovModel hmm; 11 | 12 | private RandomVariable belief; 13 | 14 | public HMMAgent(HiddenMarkovModel hmm) { 15 | this.hmm = hmm; 16 | this.belief = hmm.prior().duplicate(); 17 | } 18 | 19 | public RandomVariable belief() { 20 | return belief; 21 | } 22 | 23 | public void act(String action) { 24 | belief = hmm.predict(belief, action); 25 | } 26 | 27 | public void waitWithoutActing() { 28 | act(HmmConstants.DO_NOTHING); 29 | } 30 | 31 | public void perceive(String perception) { 32 | belief = hmm.perceptionUpdate(belief, perception); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/common/LogicTokenTypes.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.common; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public interface LogicTokenTypes { 8 | static final int SYMBOL = 1; 9 | 10 | static final int LPAREN = 2; 11 | 12 | static final int RPAREN = 3; 13 | 14 | static final int COMMA = 4; 15 | 16 | static final int CONNECTOR = 5; 17 | 18 | static final int QUANTIFIER = 6; 19 | 20 | static final int PREDICATE = 7; 21 | 22 | static final int FUNCTION = 8; 23 | 24 | static final int VARIABLE = 9; 25 | 26 | static final int CONSTANT = 10; 27 | 28 | static final int TRUE = 11; 29 | 30 | static final int FALSE = 12; 31 | 32 | static final int EQUALS = 13; 33 | 34 | static final int WHITESPACE = 1000; 35 | 36 | static final int EOI = 9999; 37 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/reasoning/HmmConstants.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.reasoning; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class HmmConstants { 8 | public static final String PUSH_DOOR = "push"; 9 | 10 | public static final String DO_NOTHING = "do_nothing"; 11 | 12 | public static final String DOOR_CLOSED = "closed"; 13 | 14 | public static final String DOOR_OPEN = "open"; 15 | 16 | public static final String SEE_DOOR_CLOSED = "see_closed"; 17 | 18 | public static final String SEE_DOOR_OPEN = "see_open"; 19 | 20 | public static final String RAINING = "rain"; 21 | 22 | public static final String NOT_RAINING = "no_rain"; 23 | 24 | public static final String SEE_UMBRELLA = "carries_umbrella"; 25 | 26 | public static final String SEE_NO_UMBRELLA = "does_not_carry_umbrella"; 27 | } 28 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/ActionsFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import java.util.Set; 4 | 5 | import aima.core.agent.Action; 6 | 7 | /** 8 | * Artificial Intelligence A Modern Approach (3rd Edition): page 67. 9 | * 10 | * Given a particular state s, ACTIONS(s) returns the set of actions that can be 11 | * executed in s. We say that each of these actions is applicable in s. 12 | */ 13 | 14 | /** 15 | * @author Ciaran O'Reilly 16 | * 17 | */ 18 | public interface ActionsFunction { 19 | /** 20 | * Given a particular state s, returns the set of actions that can be 21 | * executed in s. 22 | * 23 | * @param s 24 | * a particular state. 25 | * @return the set of actions that can be executed in s. 26 | */ 27 | Set actions(Object s); 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPPolicy.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Set; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class MDPPolicy { 11 | Hashtable stateToAction; 12 | 13 | public MDPPolicy() { 14 | stateToAction = new Hashtable(); 15 | } 16 | 17 | public ACTION_TYPE getAction(STATE_TYPE state) { 18 | return stateToAction.get(state); 19 | } 20 | 21 | public void setAction(STATE_TYPE state, ACTION_TYPE action) { 22 | stateToAction.put(state, action); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return stateToAction.toString(); 28 | } 29 | 30 | public Set states() { 31 | 32 | return stateToAction.keySet(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/informed/GreedyBestFirstSearch.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.informed; 2 | 3 | import aima.core.search.framework.HeuristicFunction; 4 | import aima.core.search.framework.QueueSearch; 5 | 6 | /** 7 | * Artificial Intelligence A Modern Approach (3rd Edition): page 92. 8 | * 9 | * Greedy best-first search tries to expand the node that is closest to the goal, 10 | * on the grounds that this is likely to lead to a solution quickly. Thus, it evaluates 11 | * nodes by using just the heuristic function; that is, f(n) = h(n) 12 | */ 13 | 14 | /** 15 | * @author Ravi Mohan 16 | * 17 | */ 18 | public class GreedyBestFirstSearch extends BestFirstSearch { 19 | 20 | public GreedyBestFirstSearch(QueueSearch search, HeuristicFunction hf) { 21 | super(search, new GreedyBestFirstEvaluationFunction(hf)); 22 | } 23 | } -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/writer/MapWriter.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.writer; 2 | 3 | import java.io.File; 4 | import java.io.OutputStreamWriter; 5 | 6 | import aimax.osm.data.BoundingBox; 7 | import aimax.osm.data.OsmMap; 8 | 9 | /** 10 | * Common interface for writing maps to file. 11 | * 12 | * @author Ruediger Lunde 13 | */ 14 | public interface MapWriter { 15 | /** Writes a map to file. */ 16 | public void writeMap(File file, OsmMap map, BoundingBox bb); 17 | 18 | /** Writes a map to an output stream writer. */ 19 | public void writeMap(OutputStreamWriter writer, OsmMap map, 20 | BoundingBox bb); 21 | 22 | /** Describes the supported file formats. */ 23 | public String[] fileFormatDescriptions(); 24 | 25 | /** Contains the file extensions of all supported formats. */ 26 | public String[] fileFormatExtensions(); 27 | } 28 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/routing/OsmSldHeuristicFunction.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.routing; 2 | 3 | import aima.core.search.framework.HeuristicFunction; 4 | import aimax.osm.data.Position; 5 | import aimax.osm.data.entities.MapNode; 6 | 7 | /** 8 | * Implements the straight-line-distance heuristic. 9 | * @author Ruediger Lunde 10 | */ 11 | public class OsmSldHeuristicFunction implements HeuristicFunction { 12 | MapNode goalState; 13 | 14 | public OsmSldHeuristicFunction(MapNode goalState) { 15 | this.goalState = goalState; 16 | } 17 | 18 | /** 19 | * Assumes a MapNode as state and returns the 20 | * straight-line-distance to the goal in KM. 21 | */ 22 | @Override 23 | public double h(Object s) { 24 | MapNode currState = (MapNode) s; 25 | return (new Position(currState)).getDistKM(goalState); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/AllAIMAUnitTestSuite.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | import aima.test.core.unit.agent.AgentTestSuite; 7 | import aima.test.core.unit.environment.EnvironmentTestSuite; 8 | import aima.test.core.unit.learning.LearningTestSuite; 9 | import aima.test.core.unit.logic.LogicTestSuite; 10 | import aima.test.core.unit.probability.ProbabilityTestSuite; 11 | import aima.test.core.unit.search.SearchTestSuite; 12 | import aima.test.core.unit.util.UtilTestSuite; 13 | 14 | @RunWith(Suite.class) 15 | @Suite.SuiteClasses( { AgentTestSuite.class, EnvironmentTestSuite.class, 16 | LearningTestSuite.class, LogicTestSuite.class, 17 | ProbabilityTestSuite.class, SearchTestSuite.class, UtilTestSuite.class }) 18 | public class AllAIMAUnitTestSuite { 19 | } 20 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/search/local/SimulatedAnnealingSearchTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.search.local; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import aima.core.search.local.SimulatedAnnealingSearch; 7 | 8 | public class SimulatedAnnealingSearchTest { 9 | 10 | @Test 11 | public void testForGivenNegativeDeltaEProbabilityOfAcceptanceDecreasesWithDecreasingTemperature() { 12 | // this isn't very nice. the object's state is uninitialized but is ok 13 | // for this test. 14 | SimulatedAnnealingSearch search = new SimulatedAnnealingSearch(null); 15 | int deltaE = -1; 16 | double higherTemperature = 30.0; 17 | double lowerTemperature = 29.5; 18 | 19 | Assert.assertTrue(search.probabilityOfAcceptance(lowerTemperature, 20 | deltaE) < search.probabilityOfAcceptance(higherTemperature, 21 | deltaE)); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/AgentProgram.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): pg 35.
5 | * An agent's behavior is described by the 'agent function' that maps any given percept 6 | * sequence to an action. Internally, the agent function for an artificial agent will be 7 | * implemented by an agent program. 8 | */ 9 | 10 | /** 11 | * @author Ravi Mohan 12 | * @author Ciaran O'Reilly 13 | */ 14 | public interface AgentProgram { 15 | /** 16 | * The Agent's program, which maps any given percept sequences to an action. 17 | * 18 | * @param percept 19 | * The current percept of a sequence perceived by the Agent. 20 | * @return the Action to be taken in response to the currently perceived 21 | * percept. 22 | */ 23 | Action execute(Percept percept); 24 | } 25 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/framework/NumericAttributeSpecification.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.framework; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class NumericAttributeSpecification implements AttributeSpecification { 8 | 9 | // a simple attribute representing a number reprsented as a double . 10 | private String name; 11 | 12 | public NumericAttributeSpecification(String name) { 13 | this.name = name; 14 | } 15 | 16 | public boolean isValid(String string) { 17 | try { 18 | Double.parseDouble(string); 19 | return true; 20 | } catch (Exception e) { 21 | return false; 22 | } 23 | } 24 | 25 | public String getAttributeName() { 26 | return name; 27 | } 28 | 29 | public Attribute createAttribute(String rawValue) { 30 | return new NumericAttribute(Double.parseDouble(rawValue), this); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/demo/search/GenerateRandomEightPuzzleBoard.java: -------------------------------------------------------------------------------- 1 | package aima.gui.demo.search; 2 | 3 | import java.util.Random; 4 | 5 | import aima.core.environment.eightpuzzle.EightPuzzleBoard; 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * 10 | */ 11 | 12 | public class GenerateRandomEightPuzzleBoard { 13 | public static void main(String[] args) { 14 | Random r = new Random(); 15 | EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 0, 1, 2, 3, 16 | 4, 5, 6, 7, 8 }); 17 | for (int i = 0; i < 50; i++) { 18 | int th = r.nextInt(4); 19 | if (th == 0) { 20 | board.moveGapUp(); 21 | } 22 | if (th == 1) { 23 | board.moveGapDown(); 24 | } 25 | if (th == 2) { 26 | board.moveGapLeft(); 27 | } 28 | if (th == 3) { 29 | board.moveGapRight(); 30 | } 31 | } 32 | System.out.println(board); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/algorithms/LogicUtils.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.algorithms; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.logic.propositional.parsing.ast.BinarySentence; 6 | import aima.core.logic.propositional.parsing.ast.Sentence; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public class LogicUtils { 13 | 14 | public static Sentence chainWith(String connector, List sentences) { 15 | if (sentences.size() == 0) { 16 | return null; 17 | } else if (sentences.size() == 1) { 18 | return (Sentence) sentences.get(0); 19 | } else { 20 | Sentence soFar = (Sentence) sentences.get(0); 21 | for (int i = 1; i < sentences.size(); i++) { 22 | Sentence next = (Sentence) sentences.get(i); 23 | soFar = new BinarySentence(connector, soFar, next); 24 | } 25 | return soFar; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/csp/Constraint.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.csp; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * A constraint specifies the allowable combinations of values for a set of 7 | * variables. Each constraint consists of a pair , where scope is a 8 | * tuple of variables that participate in the constraint and rel is a relation 9 | * that defines the values that those variables can take on. 10 | * 11 | * Note: Implementations of this interface define the different kinds of 12 | * relations that constraints can represent. 13 | * 14 | * @author Ruediger Lunde 15 | */ 16 | public interface Constraint { 17 | /** Returns a tuple of variables that participate in the constraint. */ 18 | List getScope(); 19 | 20 | /** Constrains the values that the variables can take on. */ 21 | boolean isSatisfiedWith(Assignment assignment); 22 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/datastructure/Point2D.java: -------------------------------------------------------------------------------- 1 | package aima.core.util.datastructure; 2 | 3 | /** 4 | * Simplified version of java.awt.geom.Point2D. We do not want 5 | * dependencies to presentation layer packages here. 6 | * 7 | * @author R. Lunde 8 | */ 9 | public class Point2D { 10 | private double x; 11 | private double y; 12 | 13 | public Point2D(double x, double y) { 14 | this.x = x; 15 | this.y = y; 16 | } 17 | 18 | public double getX() { 19 | return x; 20 | } 21 | 22 | public double getY() { 23 | return y; 24 | } 25 | 26 | /** 27 | * Returns the Euclidean distance between a specified point and this point. 28 | */ 29 | public double distance(Point2D pt) { 30 | double result = (pt.getX() - x) * (pt.getX() - x); 31 | result += (pt.getY() - y) * (pt.getY() - y); 32 | return Math.sqrt(result); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/framework/PopupShower.java: -------------------------------------------------------------------------------- 1 | package aima.gui.framework; 2 | 3 | import java.awt.event.MouseAdapter; 4 | import java.awt.event.MouseEvent; 5 | 6 | import javax.swing.JPopupMenu; 7 | 8 | /** 9 | * Useful helper class for showing popup menus. The idea is taken from the 10 | * java tutorial "How to Use Menus". 11 | * 12 | * @author Ruediger Lunde 13 | */ 14 | public class PopupShower extends MouseAdapter { 15 | JPopupMenu popup; 16 | 17 | public PopupShower(JPopupMenu popup) { 18 | this.popup = popup; 19 | } 20 | 21 | public void mousePressed(MouseEvent e) { 22 | maybeShowPopup(e); 23 | } 24 | 25 | public void mouseReleased(MouseEvent e) { 26 | maybeShowPopup(e); 27 | } 28 | 29 | private void maybeShowPopup(MouseEvent e) { 30 | if (e.isPopupTrigger()) { 31 | popup.show(e.getComponent(), e.getX(), e.getY()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/Query.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability; 2 | 3 | import java.util.Hashtable; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class Query { 10 | 11 | private String queryVariable; 12 | 13 | private Hashtable evidenceVariables; 14 | 15 | public Query(String queryVariable, String[] evidenceVariables, 16 | boolean[] evidenceValues) { 17 | this.queryVariable = queryVariable; 18 | this.evidenceVariables = new Hashtable(); 19 | for (int i = 0; i < evidenceVariables.length; i++) { 20 | this.evidenceVariables.put(evidenceVariables[i], new Boolean( 21 | evidenceValues[i])); 22 | } 23 | } 24 | 25 | public Hashtable getEvidenceVariables() { 26 | return evidenceVariables; 27 | } 28 | 29 | public String getQueryVariable() { 30 | return queryVariable; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/visitors/SymbolCollector.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.visitors; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import aima.core.logic.propositional.parsing.ast.Sentence; 7 | import aima.core.logic.propositional.parsing.ast.Symbol; 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public class SymbolCollector extends BasicTraverser { 14 | 15 | @Override 16 | public Object visitSymbol(Symbol s, Object arg) { 17 | Set symbolsCollectedSoFar = (Set) arg; 18 | symbolsCollectedSoFar.add(new Symbol(s.getValue())); 19 | return symbolsCollectedSoFar; 20 | } 21 | 22 | public Set getSymbolsIn(Sentence s) { 23 | if (s == null) {// empty knowledge bases == null fix this later 24 | return new HashSet(); 25 | } 26 | return (Set) s.accept(this, new HashSet()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/cellworld/CellWorldPosition.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.cellworld; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class CellWorldPosition { 8 | private int x, y; 9 | 10 | public CellWorldPosition(int x, int y) { 11 | this.x = x; 12 | this.y = y; 13 | } 14 | 15 | public int getX() { 16 | return x; 17 | } 18 | 19 | public int getY() { 20 | return y; 21 | } 22 | 23 | @Override 24 | public boolean equals(Object o) { 25 | if (o == this) { 26 | return true; 27 | } 28 | if (!(o instanceof CellWorldPosition)) { 29 | return false; 30 | } 31 | CellWorldPosition cwp = (CellWorldPosition) o; 32 | return ((this.x == cwp.x) && (this.y == cwp.y)); 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return x + 31 * y; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "< " + x + " , " + y + " > "; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aima-core/build.properties: -------------------------------------------------------------------------------- 1 | # AIMA-CORE 2 | # DO NOT MODIFY THIS FILE DIRECTLY -- use build.properties.local 3 | # 4 | # To use different values for properties in this file: 5 | # a) Create a build.properties.local in the same directory as build.xml 6 | # or 7 | # b) Use -Dproperty=value arguments 8 | 9 | # VERSION 10 | aima-core.version=0.9.14 11 | # DIRECTORY LOCATIONS 12 | aima-core.dir.src=${aima-core.basedir}/src 13 | aima-core.dir.lib=${aima-core.basedir}/lib 14 | # TEMP DIRECTORIES FOR BUILDING and RELEASING 15 | aima-core.dir.build=${aima-core.basedir}/build 16 | aima-core.dir.build.bin=${aima-core.dir.build}/bin 17 | aima-core.dir.build.doc=${aima-core.dir.build}/doc 18 | aima-core.dir.build.release=${aima-core.dir.build}/release 19 | 20 | # COMPILER VALUES 21 | aima-core.compiler.debug=true 22 | aima-core.compiler.debuglevel=source,lines,vars 23 | aima-core.compiler.source=1.6 24 | aima-core.compiler.target=1.6 -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/aprog/simplerule/EQUALCondition.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl.aprog.simplerule; 2 | 3 | import aima.core.agent.impl.ObjectWithDynamicAttributes; 4 | 5 | /** 6 | * Implementation of an EQUALity condition. 7 | * 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public class EQUALCondition extends Condition { 15 | private Object key; 16 | 17 | private Object value; 18 | 19 | public EQUALCondition(Object aKey, Object aValue) { 20 | assert (null != aKey); 21 | assert (null != aValue); 22 | 23 | key = aKey; 24 | value = aValue; 25 | } 26 | 27 | @Override 28 | public boolean evaluate(ObjectWithDynamicAttributes p) { 29 | return value.equals(p.getAttribute(key)); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | StringBuilder sb = new StringBuilder(); 35 | 36 | return sb.append(key).append("==").append(value).toString(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/SimpleEnvironmentView.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.Action; 4 | import aima.core.agent.Agent; 5 | import aima.core.agent.EnvironmentState; 6 | import aima.core.agent.EnvironmentView; 7 | 8 | /** 9 | * Simple environment view which uses the standard 10 | * output stream to inform about relevant events. 11 | * @author Ruediger Lunde 12 | */ 13 | public class SimpleEnvironmentView implements EnvironmentView { 14 | @Override 15 | public void agentActed(Agent agent, Action action, 16 | EnvironmentState resultingState) { 17 | System.out.println("Agent acted: " + action.toString()); 18 | } 19 | @Override 20 | public void agentAdded(Agent agent, EnvironmentState resultingState) { 21 | System.out.println("Agent added."); 22 | } 23 | @Override 24 | public void notify(String msg) { 25 | System.out.println("Message: " + msg); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/datastructure/Pair.java: -------------------------------------------------------------------------------- 1 | package aima.core.util.datastructure; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Pair { 8 | private final X a; 9 | 10 | private final Y b; 11 | 12 | public Pair(X a, Y b) { 13 | this.a = a; 14 | this.b = b; 15 | } 16 | 17 | public X getFirst() { 18 | return a; 19 | } 20 | 21 | public Y getSecond() { 22 | return b; 23 | } 24 | 25 | @Override 26 | public boolean equals(Object o) { 27 | if (o instanceof Pair) { 28 | Pair p = (Pair) o; 29 | return a.equals(p.a) && b.equals(p.b); 30 | } 31 | return false; 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | return a.hashCode() + 31 * b.hashCode(); 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "< " + getFirst().toString() + " , " + getSecond().toString() 42 | + " > "; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/entities/MapNode.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data.entities; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Represents a node within the map. Nodes 7 | * can be part of a way, points of interest, or marks. 8 | * A full java bean interface is provided. So it is 9 | * easy, to serialize objects using XMLEncoder. 10 | * @author Ruediger Lunde 11 | */ 12 | public interface MapNode extends MapEntity { 13 | 14 | /** Checks whether latitude and longitude values have been set. */ 15 | public boolean hasPosition(); 16 | /** Sets latitude and longitude values for the node. */ 17 | public void setPosition(float lat, float lon); 18 | /** Returns the latitude value. */ 19 | public float getLat(); 20 | /** Returns the longitude value. */ 21 | public float getLon(); 22 | 23 | /** Provides read-only access to the maintained list of way references. */ 24 | public List getWayRefs(); 25 | } 26 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/ResultFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import aima.core.agent.Action; 4 | 5 | /** 6 | * Artificial Intelligence A Modern Approach (3rd Edition): page 67. 7 | * 8 | * A description of what each action does; the formal name for this is the 9 | * transition model, specified by a function RESULT(s, a) that returns the state 10 | * that results from doing action a in state s. We also use the term successor 11 | * to refer to any state reachable from a given state by a single action. 12 | */ 13 | public interface ResultFunction { 14 | /** 15 | * Returns the state that results from doing action a in state s 16 | * 17 | * @param s 18 | * a particular state. 19 | * @param a 20 | * an action to be performed in state s. 21 | * @return the state that results from doing action a in state s. 22 | */ 23 | Object result(Object s, Action a); 24 | } 25 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/StepCostFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import aima.core.agent.Action; 4 | 5 | /** 6 | * Artificial Intelligence A Modern Approach (3rd Edition): page 68. 7 | * 8 | * The step cost of taking action a in state s to reach state s' 9 | * is denoted by c(s, a, s'). 10 | */ 11 | 12 | /** 13 | * @author Ravi Mohan 14 | * @author Ciaran O'Reilly 15 | */ 16 | public interface StepCostFunction { 17 | /** 18 | * Calculate the step cost of taking action a in state s to reach state s'. 19 | * 20 | * @param s 21 | * the state from which action a is to be performed. 22 | * @param a 23 | * the action to be taken. 24 | * 25 | * @param sPrime 26 | * the state reached by taking the action. 27 | * @return the cost of taking action a in state s to reach state s'. 28 | */ 29 | double c(Object s, Action a, Object sPrime); 30 | } -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/environment/vacuum/EnvironmentViewActionTracker.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.environment.vacuum; 2 | 3 | import aima.core.agent.Action; 4 | import aima.core.agent.Agent; 5 | import aima.core.agent.EnvironmentState; 6 | import aima.core.agent.EnvironmentView; 7 | 8 | public class EnvironmentViewActionTracker implements EnvironmentView { 9 | private StringBuilder actions = null; 10 | 11 | public EnvironmentViewActionTracker(StringBuilder envChanges) { 12 | this.actions = envChanges; 13 | } 14 | 15 | // 16 | // START-EnvironmentView 17 | public void notify(String msg) { 18 | // Do nothing by default. 19 | } 20 | 21 | public void agentAdded(Agent agent, EnvironmentState state) { 22 | // Do nothing by default. 23 | } 24 | 25 | public void agentActed(Agent agent, Action action, EnvironmentState state) { 26 | actions.append(action); 27 | } 28 | 29 | // END-EnvironmentView 30 | // 31 | } 32 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/data/MapEvent.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.data; 2 | 3 | /** 4 | * Provides map data change information to interested listeners. 5 | * @author Ruediger Lunde 6 | */ 7 | public class MapEvent { 8 | OsmMap source; 9 | Type type; 10 | long objId; 11 | 12 | public MapEvent(OsmMap source, Type type) { 13 | this.source = source; 14 | this.type = type; 15 | objId = -1; 16 | } 17 | 18 | public MapEvent(OsmMap source, Type type, long objId) { 19 | this.source = source; 20 | this.type = type; 21 | this.objId = objId; 22 | } 23 | 24 | public OsmMap getSource() { 25 | return source; 26 | } 27 | 28 | public Type getType() { 29 | return type; 30 | } 31 | 32 | public long getObjId() { 33 | return objId; 34 | } 35 | 36 | /** Describes the kind of change. */ 37 | public enum Type { 38 | MAP_NEW, MAP_MODIFIED, MARKER_ADDED, MARKER_REMOVED, TRACK_MODIFIED, MAP_CLEARED; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/Connectors.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Connectors { 8 | public static final String AND = "AND"; 9 | 10 | public static final String OR = "OR"; 11 | 12 | public static final String NOT = "NOT"; 13 | 14 | public static final String IMPLIES = "=>"; 15 | 16 | public static final String BICOND = "<=>"; 17 | 18 | public static boolean isAND(String connector) { 19 | return AND.equals(connector); 20 | } 21 | 22 | public static boolean isOR(String connector) { 23 | return OR.equals(connector); 24 | } 25 | 26 | public static boolean isNOT(String connector) { 27 | return NOT.equals(connector); 28 | } 29 | 30 | public static boolean isIMPLIES(String connector) { 31 | return IMPLIES.equals(connector); 32 | } 33 | 34 | public static boolean isBICOND(String connector) { 35 | return BICOND.equals(connector); 36 | } 37 | } -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/demo/logic/PLResolutionDemo.java: -------------------------------------------------------------------------------- 1 | package aima.gui.demo.logic; 2 | 3 | import aima.core.logic.propositional.algorithms.KnowledgeBase; 4 | import aima.core.logic.propositional.algorithms.PLResolution; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class PLResolutionDemo { 11 | private static PLResolution plr = new PLResolution(); 12 | 13 | public static void main(String[] args) { 14 | KnowledgeBase kb = new KnowledgeBase(); 15 | String fact = "((B11 => (NOT P11)) AND B11)"; 16 | kb.tell(fact); 17 | System.out.println("\nPLResolutionDemo\n"); 18 | System.out.println("adding " + fact + "to knowldegebase"); 19 | displayResolutionResults(kb, "(NOT B11)"); 20 | } 21 | 22 | private static void displayResolutionResults(KnowledgeBase kb, String query) { 23 | System.out.println("Running plResolution of query " + query 24 | + " on knowledgeBase gives " + plr.plResolution(kb, query)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/DynamicPercept.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.Percept; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * @author Ciaran O'Reilly 8 | */ 9 | public class DynamicPercept extends ObjectWithDynamicAttributes implements 10 | Percept { 11 | public DynamicPercept() { 12 | 13 | } 14 | 15 | @Override 16 | public String describeType() { 17 | return Percept.class.getSimpleName(); 18 | } 19 | 20 | public DynamicPercept(Object key1, Object value1) { 21 | setAttribute(key1, value1); 22 | } 23 | 24 | public DynamicPercept(Object key1, Object value1, Object key2, Object value2) { 25 | setAttribute(key1, value1); 26 | setAttribute(key2, value2); 27 | } 28 | 29 | public DynamicPercept(Object[] keys, Object[] values) { 30 | assert (keys.length == values.length); 31 | 32 | for (int i = 0; i < keys.length; i++) { 33 | setAttribute(keys[i], values[i]); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/neural/NNConfig.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.neural; 2 | 3 | import java.util.Hashtable; 4 | 5 | /* 6 | * a holder for config data for neural networks and possibly for other 7 | * learning systems. 8 | */ 9 | 10 | /** 11 | * @author Ravi Mohan 12 | * 13 | */ 14 | public class NNConfig { 15 | private final Hashtable hash; 16 | 17 | public NNConfig(Hashtable hash) { 18 | this.hash = hash; 19 | } 20 | 21 | public NNConfig() { 22 | this.hash = new Hashtable(); 23 | } 24 | 25 | public double getParameterAsDouble(String key) { 26 | 27 | return (Double) hash.get(key); 28 | } 29 | 30 | public int getParameterAsInteger(String key) { 31 | 32 | return (Integer) hash.get(key); 33 | } 34 | 35 | public void setConfig(String key, Double value) { 36 | hash.put(key, value); 37 | } 38 | 39 | public void setConfig(String key, int value) { 40 | hash.put(key, value); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepGoal.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | * 10 | */ 11 | public class ProofStepGoal extends AbstractProofStep { 12 | // 13 | private static final List _noPredecessors = new ArrayList(); 14 | // 15 | private Object proof = ""; 16 | 17 | public ProofStepGoal(Object proof) { 18 | this.proof = proof; 19 | } 20 | 21 | // 22 | // START-ProofStep 23 | @Override 24 | public List getPredecessorSteps() { 25 | return Collections.unmodifiableList(_noPredecessors); 26 | } 27 | 28 | @Override 29 | public String getProof() { 30 | return proof.toString(); 31 | } 32 | 33 | @Override 34 | public String getJustification() { 35 | return "Goal"; 36 | } 37 | // END-ProofStep 38 | // 39 | } 40 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/Metrics.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import java.util.Hashtable; 4 | import java.util.Set; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class Metrics { 11 | private Hashtable hash; 12 | 13 | public Metrics() { 14 | this.hash = new Hashtable(); 15 | } 16 | 17 | public void set(String name, int i) { 18 | hash.put(name, Integer.toString(i)); 19 | } 20 | 21 | public void set(String name, double d) { 22 | hash.put(name, Double.toString(d)); 23 | } 24 | 25 | public int getInt(String name) { 26 | return new Integer(hash.get(name)).intValue(); 27 | } 28 | 29 | public double getDouble(String name) { 30 | return new Double(hash.get(name)).doubleValue(); 31 | } 32 | 33 | public String get(String name) { 34 | return hash.get(name); 35 | } 36 | 37 | public Set keySet() { 38 | return hash.keySet(); 39 | } 40 | } -------------------------------------------------------------------------------- /aima-all/release/aima-gui-VacuumApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Vacuum Demo Application 5 | Vacuum Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepPremise.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | * 10 | */ 11 | public class ProofStepPremise extends AbstractProofStep { 12 | // 13 | private static final List _noPredecessors = new ArrayList(); 14 | // 15 | private Object proof = ""; 16 | 17 | public ProofStepPremise(Object proof) { 18 | this.proof = proof; 19 | } 20 | 21 | // 22 | // START-ProofStep 23 | @Override 24 | public List getPredecessorSteps() { 25 | return Collections.unmodifiableList(_noPredecessors); 26 | } 27 | 28 | @Override 29 | public String getProof() { 30 | return proof.toString(); 31 | } 32 | 33 | @Override 34 | public String getJustification() { 35 | return "Premise"; 36 | } 37 | // END-ProofStep 38 | // 39 | } 40 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/aprog/simplerule/ANDCondition.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl.aprog.simplerule; 2 | 3 | import aima.core.agent.impl.ObjectWithDynamicAttributes; 4 | 5 | /** 6 | * Implementation of an AND condition. 7 | * 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public class ANDCondition extends Condition { 15 | private Condition left; 16 | 17 | private Condition right; 18 | 19 | public ANDCondition(Condition aLeftCon, Condition aRightCon) { 20 | assert (null != aLeftCon); 21 | assert (null != aRightCon); 22 | 23 | left = aLeftCon; 24 | right = aRightCon; 25 | } 26 | 27 | @Override 28 | public boolean evaluate(ObjectWithDynamicAttributes p) { 29 | return (left.evaluate(p) && right.evaluate(p)); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | StringBuilder sb = new StringBuilder(); 35 | 36 | return sb.append("[").append(left).append(" && ").append(right).append( 37 | "]").toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/aprog/simplerule/ORCondition.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl.aprog.simplerule; 2 | 3 | import aima.core.agent.impl.ObjectWithDynamicAttributes; 4 | 5 | /** 6 | * Implementation of an OR condition. 7 | * 8 | */ 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public class ORCondition extends Condition { 15 | private Condition left; 16 | 17 | private Condition right; 18 | 19 | public ORCondition(Condition aLeftCon, Condition aRightCon) { 20 | assert (null != aLeftCon); 21 | assert (null != aRightCon); 22 | 23 | left = aLeftCon; 24 | right = aRightCon; 25 | } 26 | 27 | @Override 28 | public boolean evaluate(ObjectWithDynamicAttributes p) { 29 | return (left.evaluate(p) || right.evaluate(p)); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | StringBuilder sb = new StringBuilder(); 35 | 36 | return sb.append("[").append(left).append(" || ").append(right).append( 37 | "]").toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/csp/NotEqualConstraint.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.csp; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Represents a binary constraint which forbids equal values. 8 | * 9 | * @author Ruediger Lunde 10 | */ 11 | public class NotEqualConstraint implements Constraint { 12 | 13 | private Variable var1; 14 | private Variable var2; 15 | private List scope; 16 | 17 | public NotEqualConstraint(Variable var1, Variable var2) { 18 | this.var1 = var1; 19 | this.var2 = var2; 20 | scope = new ArrayList(2); 21 | scope.add(var1); 22 | scope.add(var2); 23 | } 24 | 25 | @Override 26 | public List getScope() { 27 | return scope; 28 | } 29 | 30 | @Override 31 | public boolean isSatisfiedWith(Assignment assignment) { 32 | Object value1 = assignment.getAssignment(var1); 33 | return value1 == null || !value1.equals(assignment.getAssignment(var2)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/impl/AbstractAgent.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent.impl; 2 | 3 | import aima.core.agent.Action; 4 | import aima.core.agent.Agent; 5 | import aima.core.agent.AgentProgram; 6 | import aima.core.agent.Percept; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * @author Ciaran O'Reilly 11 | */ 12 | public abstract class AbstractAgent implements Agent { 13 | 14 | protected AgentProgram program; 15 | private boolean alive = true; 16 | 17 | public AbstractAgent() { 18 | 19 | } 20 | 21 | public AbstractAgent(AgentProgram aProgram) { 22 | program = aProgram; 23 | } 24 | 25 | // 26 | // START-Agent 27 | public Action execute(Percept p) { 28 | if (null != program) { 29 | return program.execute(p); 30 | } 31 | return NoOpAction.NO_OP; 32 | } 33 | 34 | public boolean isAlive() { 35 | return alive; 36 | } 37 | 38 | public void setAlive(boolean alive) { 39 | this.alive = alive; 40 | } 41 | 42 | // END-Agent 43 | // 44 | } -------------------------------------------------------------------------------- /aima-all/release/aima-gui-EightPuzzleApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8-Puzzle Demo Application 5 | 8-Puzzle Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-all/release/aima-gui-TicTacToeApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tic-Tac-Toe Demo Application 5 | Tic-Tac-Toe Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-all/release/aima-gui-NQueensApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | N-Queens Problem Demo Application 5 | N-Queens Problem Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains classes, which are useful to create map agents. 3 | * The contained Map interface provides 4 | * a simple but sufficient set of read methods for designing 5 | * environments, agents and viewers. ExtendableMap 6 | * implements this interface and adds functionality for 7 | * creation and modification. It maintains named locations with 8 | * coordinates and links between them. 9 | * The MapEnvironment enables a MapAgent 10 | * to travel through a world whose topology is described by a map. 11 | * Adaptable heuristic functions let the agent modify the 12 | * heuristic function with respect to the current goal. Standardized 13 | * dynamic attribute names in class DynAttributeNames 14 | * make information exchange between environment 15 | * and agent a bit safer without introducing direct dependencies. 16 | */ 17 | package aima.core.environment.map; -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPRewardFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | import java.util.Hashtable; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class MDPRewardFunction { 10 | Hashtable stateToReward; 11 | 12 | public MDPRewardFunction() { 13 | stateToReward = new Hashtable(); 14 | } 15 | 16 | public double getRewardFor(STATE_TYPE state) { 17 | return stateToReward.get(state); 18 | } 19 | 20 | public void setReward(STATE_TYPE state, Double reward) { 21 | stateToReward.put(state, reward); 22 | } 23 | 24 | @Override 25 | public String toString() { 26 | return stateToReward.toString(); 27 | } 28 | 29 | public MDPUtilityFunction asUtilityFunction() { 30 | MDPUtilityFunction uf = new MDPUtilityFunction(); 31 | for (STATE_TYPE state : stateToReward.keySet()) { 32 | uf.setUtility(state, getRewardFor(state)); 33 | } 34 | return uf; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aima-all/release/aima-gui-MapColoringApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Map Coloring CSP Demo Application 5 | Map Coloring CSP Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/inductive/DLTestFactory.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.inductive; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import aima.core.learning.framework.DataSet; 7 | 8 | /** 9 | * @author Ravi Mohan 10 | * 11 | */ 12 | public class DLTestFactory { 13 | 14 | public List createDLTestsWithAttributeCount(DataSet ds, int i) { 15 | if (i != 1) { 16 | throw new RuntimeException( 17 | "For now DLTests with only 1 attribute can be craeted , not" 18 | + i); 19 | } 20 | List nonTargetAttributes = ds.getNonTargetAttributes(); 21 | List tests = new ArrayList(); 22 | for (String ntAttribute : nonTargetAttributes) { 23 | List ntaValues = ds.getPossibleAttributeValues(ntAttribute); 24 | for (String ntaValue : ntaValues) { 25 | 26 | DLTest test = new DLTest(); 27 | test.add(ntAttribute, ntaValue); 28 | tests.add(test); 29 | 30 | } 31 | } 32 | return tests; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/probability/ProbabilityTestSuite.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.probability; 2 | 3 | import org.junit.runner.RunWith; 4 | import org.junit.runners.Suite; 5 | 6 | import aima.test.core.unit.probability.decision.PolicyIterationTest; 7 | import aima.test.core.unit.probability.decision.ValueIterationTest; 8 | import aima.test.core.unit.probability.reasoning.HMMAgentTest; 9 | import aima.test.core.unit.probability.reasoning.HMMTest; 10 | import aima.test.core.unit.probability.reasoning.ParticleFilterTest; 11 | import aima.test.core.unit.probability.reasoning.RandomVariableTest; 12 | 13 | @RunWith(Suite.class) 14 | @Suite.SuiteClasses( { PolicyIterationTest.class, ValueIterationTest.class, 15 | HMMAgentTest.class, HMMTest.class, ParticleFilterTest.class, 16 | RandomVariableTest.class, BayesNetNodeTest.class, BayesNetTest.class, 17 | EnumerationAskTest.class, EnumerationJointAskTest.class, 18 | ProbabilitySamplingTest.class }) 19 | public class ProbabilityTestSuite { 20 | 21 | } 22 | -------------------------------------------------------------------------------- /aima-all/release/aima-gui-RouteFindingAgentApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Route Finding Agent Demo Application 5 | Route Finding Agent Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/visitors/NegativeSymbolCollector.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.visitors; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import aima.core.logic.propositional.parsing.ast.Sentence; 7 | import aima.core.logic.propositional.parsing.ast.Symbol; 8 | import aima.core.logic.propositional.parsing.ast.UnarySentence; 9 | import aima.core.util.SetOps; 10 | 11 | /** 12 | * @author Ravi Mohan 13 | * 14 | */ 15 | public class NegativeSymbolCollector extends BasicTraverser { 16 | @Override 17 | public Object visitNotSentence(UnarySentence ns, Object arg) { 18 | Set s = (Set) arg; 19 | if (ns.getNegated() instanceof Symbol) { 20 | s.add((Symbol) ns.getNegated()); 21 | } else { 22 | s = SetOps 23 | .union(s, (Set) ns.getNegated().accept(this, arg)); 24 | } 25 | return s; 26 | } 27 | 28 | public Set getNegativeSymbolsIn(Sentence s) { 29 | return (Set) s.accept(this, new HashSet()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/applications/vacuum/VacuumFrame.java: -------------------------------------------------------------------------------- 1 | package aima.gui.applications.vacuum; 2 | 3 | import aima.gui.framework.AgentAppFrame; 4 | 5 | /** 6 | * Adds some selectors to the base class and adjusts its size. 7 | * 8 | * @author Ruediger Lunde 9 | */ 10 | public class VacuumFrame extends AgentAppFrame { 11 | private static final long serialVersionUID = 1L; 12 | public static String ENV_SEL = "EnvSelection"; 13 | public static String AGENT_SEL = "AgentSelection"; 14 | 15 | public VacuumFrame() { 16 | setTitle("Vacuum Agent Application"); 17 | setSelectors(new String[] { ENV_SEL, AGENT_SEL }, new String[] { 18 | "Select Environment", "Select Agent" }); 19 | setSelectorItems(ENV_SEL, new String[] { "A/B Environment" }, 0); 20 | setSelectorItems(AGENT_SEL, new String[] { 21 | "TableDrivenVacuumAgent", 22 | "ReflexVacuumAgent", 23 | "SimpleReflexVacuumAgent", 24 | "ModelBasedReflexVacuumAgent" }, 25 | 0); 26 | setEnvView(new VacuumView()); 27 | setSize(800, 400); 28 | } 29 | } -------------------------------------------------------------------------------- /aima-all/release/aimax-osm-OsmSearchDemoAgentApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OSM Agent Search Demo 5 | OSM Agent Search Demo 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/informed/GreedyBestFirstEvaluationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.informed; 2 | 3 | import aima.core.search.framework.EvaluationFunction; 4 | import aima.core.search.framework.HeuristicFunction; 5 | import aima.core.search.framework.Node; 6 | 7 | /** 8 | * Artificial Intelligence A Modern Approach (3rd Edition): page 92. 9 | * 10 | * Greedy best-first search tries to expand the node that is closest to the goal, 11 | * on the grounds that this is likely to lead to a solution quickly. Thus, it evaluates 12 | * nodes by using just the heuristic function; that is, f(n) = h(n) 13 | */ 14 | 15 | /** 16 | * @author Ciaran O'Reilly 17 | * 18 | */ 19 | public class GreedyBestFirstEvaluationFunction implements EvaluationFunction { 20 | 21 | private HeuristicFunction hf = null; 22 | 23 | public GreedyBestFirstEvaluationFunction(HeuristicFunction hf) { 24 | this.hf = hf; 25 | } 26 | 27 | public double f(Node n) { 28 | // f(n) = h(n) 29 | return hf.h(n.getState()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/Proof.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import aima.core.logic.fol.parsing.ast.Term; 7 | import aima.core.logic.fol.parsing.ast.Variable; 8 | 9 | /** 10 | * @author Ciaran O'Reilly 11 | * 12 | */ 13 | public interface Proof { 14 | /** 15 | * 16 | * @return A list of proof steps that show how an answer was derived. 17 | */ 18 | List getSteps(); 19 | 20 | /** 21 | * 22 | * @return a Map of bindings for any variables that were in the original 23 | * query. Will be an empty Map if no variables existed in the 24 | * original query. 25 | */ 26 | Map getAnswerBindings(); 27 | 28 | /** 29 | * 30 | * @param updatedBindings 31 | * allows for the bindings to be renamed. Note: should not be 32 | * used for any other reason. 33 | */ 34 | void replaceAnswerBindings(Map updatedBindings); 35 | } 36 | -------------------------------------------------------------------------------- /aima-core/src/main/resource/aima/core/learning/data/rabbiteyes.csv: -------------------------------------------------------------------------------- 1 | 15,21.66 2 | 15,22.75 3 | 15,22.3 4 | 18,31.25 5 | 28,44.79 6 | 29,40.55 7 | 37,50.25 8 | 37,46.88 9 | 44,52.33 10 | 50,63.47 11 | 50,61.13 12 | 60,81 13 | 61,73.09 14 | 64,79.09 15 | 65,79.51 16 | 65,65.31 17 | 72,71.9 18 | 75,86.1 19 | 75,94.6 20 | 82,92.5 21 | 85,105 22 | 91,101.7 23 | 91,102.9 24 | 97,110 25 | 98,104.3 26 | 125,134.9 27 | 142, 130.68 28 | 147, 155.3 29 | 147,152.2 30 | 150,144.5 31 | 159,142.15 32 | 165,139.81 33 | 183,153.22 34 | 192,145.72 35 | 195,161.1 36 | 218,174.18 37 | 218,173.03 38 | 219,173.54 39 | 224,178.86 40 | 225,177.68 41 | 227,173.73 42 | 232,159.98 43 | 232,161.29 44 | 237,187.07 45 | 246,176.13 46 | 258,183.4 47 | 276,186.26 48 | 285,189.66 49 | 300,186.09 50 | 301,186.7 51 | 305,186.8 52 | 312,195.1 53 | 317,216.41 54 | 338,203.23 55 | 347,188.38 56 | 354,189.7 57 | 357,195.31 58 | 375,202.63 59 | 394,224.82 60 | 513,203.3 61 | 535,209.7 62 | 554,233.9 63 | 591,234.7 64 | 648,244.3 65 | 660,231 66 | 705,242.4 67 | 723,230.77 68 | 756,242.57 69 | 768,232.12 70 | 860,246.7 71 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepRenaming.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | * 10 | */ 11 | public class ProofStepRenaming extends AbstractProofStep { 12 | private List predecessors = new ArrayList(); 13 | private Object proof = ""; 14 | 15 | public ProofStepRenaming(Object proof, ProofStep predecessor) { 16 | this.proof = proof; 17 | this.predecessors.add(predecessor); 18 | } 19 | 20 | // 21 | // START-ProofStep 22 | @Override 23 | public List getPredecessorSteps() { 24 | return Collections.unmodifiableList(predecessors); 25 | } 26 | 27 | @Override 28 | public String getProof() { 29 | return proof.toString(); 30 | } 31 | 32 | @Override 33 | public String getJustification() { 34 | return "Renaming of " + predecessors.get(0).getStepNumber(); 35 | } 36 | // END-ProofStep 37 | // 38 | } 39 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/agent/impl/DynamicPerceptTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.agent.impl; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import aima.core.agent.impl.DynamicPercept; 7 | 8 | public class DynamicPerceptTest { 9 | 10 | @Test 11 | public void testToString() { 12 | DynamicPercept p = new DynamicPercept("key1", "value1"); 13 | 14 | Assert.assertEquals("Percept[key1==value1]", p.toString()); 15 | 16 | p = new DynamicPercept("key1", "value1", "key2", "value2"); 17 | 18 | Assert 19 | .assertEquals("Percept[key1==value1, key2==value2]", p 20 | .toString()); 21 | } 22 | 23 | @Test 24 | public void testEquals() { 25 | DynamicPercept p1 = new DynamicPercept(); 26 | DynamicPercept p2 = new DynamicPercept(); 27 | 28 | Assert.assertEquals(p1, p2); 29 | 30 | p1 = new DynamicPercept("key1", "value1"); 31 | 32 | Assert.assertNotSame(p1, p2); 33 | 34 | p2 = new DynamicPercept("key1", "value1"); 35 | 36 | Assert.assertEquals(p1, p2); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/environment/eightpuzzle/MisplacedTileHeuristicFunctionTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.environment.eightpuzzle; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import aima.core.environment.eightpuzzle.EightPuzzleBoard; 7 | import aima.core.environment.eightpuzzle.MisplacedTilleHeuristicFunction; 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public class MisplacedTileHeuristicFunctionTest { 14 | 15 | @Test 16 | public void testHeuristicCalculation() { 17 | MisplacedTilleHeuristicFunction fn = new MisplacedTilleHeuristicFunction(); 18 | EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 2, 0, 5, 6, 19 | 4, 8, 3, 7, 1 }); 20 | Assert.assertEquals(7.0, fn.h(board), 0.001); 21 | 22 | board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 0, 7, 1 }); 23 | Assert.assertEquals(6.0, fn.h(board), 0.001); 24 | 25 | board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 7, 0, 1 }); 26 | Assert.assertEquals(7.0, fn.h(board), 0.001); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/informed/AStarSearch.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.informed; 2 | 3 | import aima.core.search.framework.HeuristicFunction; 4 | import aima.core.search.framework.QueueSearch; 5 | 6 | /** 7 | * Artificial Intelligence A Modern Approach (3rd Edition): page 93. 8 | * 9 | * The most widely known form of best-first search is called A* Search (pronounced 10 | * "A-star search"). It evaluates nodes by combining g(n), the cost to reach the node, 11 | * and h(n), the cost to get from the node to the goal:
12 | * f(n) = g(n) + h(n).
13 | * Since g(n) gives the path cost from the start node to node n, and h(n) is the 14 | * estimated cost of the cheapest path from n to the goal, we have
15 | * f(n) = estimated cost of the cheapest solution through n. 16 | */ 17 | 18 | /** 19 | * @author Ravi Mohan 20 | * 21 | */ 22 | public class AStarSearch extends BestFirstSearch { 23 | 24 | public AStarSearch(QueueSearch search, HeuristicFunction hf) { 25 | super(search, new AStarEvaluationFunction(hf)); 26 | } 27 | } -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/logic/propositional/parsing/ListTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.logic.propositional.parsing; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import aima.core.logic.propositional.parsing.ast.Symbol; 10 | 11 | /** 12 | * @author Ravi Mohan 13 | * 14 | */ 15 | public class ListTest { 16 | 17 | @Test 18 | public void testListOfSymbolsClone() { 19 | ArrayList l = new ArrayList(); 20 | l.add(new Symbol("A")); 21 | l.add(new Symbol("B")); 22 | l.add(new Symbol("C")); 23 | List l2 = (List) l.clone(); 24 | l2.remove(new Symbol("B")); 25 | Assert.assertEquals(3, l.size()); 26 | Assert.assertEquals(2, l2.size()); 27 | } 28 | 29 | @Test 30 | public void testListRemove() { 31 | List one = new ArrayList(); 32 | one.add(new Integer(1)); 33 | Assert.assertEquals(1, one.size()); 34 | one.remove(0); 35 | Assert.assertEquals(0, one.size()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/viewer/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains the presentation layer classes of the 3 | * OSM viewer. The class MapViewPane gets its data from an 4 | * OsmMap object and visualizes it on a canvas. It also 5 | * reacts on keyboard and mouse events and provides a popup menu. 6 | * By default, it uses a DefaultEntityRenderer to draw entities but 7 | * other renderers can be used as well. The default renderer does not 8 | * decide itself, which icon to use for a certain entity, or which color. 9 | * Instead, it assumes, that all entities have been classified before and 10 | * provide an attached DefaultEntityViewInfo object. For this 11 | * purpose, the OSM map must be equipped with an entity classifier. 12 | * Suitable examples of entity classifiers are provided by the 13 | * MapStyleFactory. The MapViewFrame 14 | * demonstrates, how the viewer can be embedded within a graphical 15 | * application frame.

16 | */ 17 | package aimax.osm.viewer; -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/gps/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * This package contains components for accessing GPS systems 3 | * using a serial port connection and the NMEA protocol. It relies 4 | * on the RXTX serial port library. To use the functionality, it is 5 | * therefore necessary, to download the rs232 serial port library 6 | * from http://www.rxtx.org/ and to install it correctly. After that, 7 | * rename NmeaSerialPortReader.txt to 8 | * NmeaSerialPortReader.java. 9 | * 10 | *

Class GpsLocator is used to publish position 11 | * informations. It receives NMEA messages via a NmeaReader. 12 | * The message source can either be a serial port or a file. A 13 | * reader factory exists, which hides implementation details. The 14 | * serial port reader, which is provided as text file, initially scans 15 | * all serial ports and selects the first which provides NEMEA messages. 16 | * When connecting a second time, it uses the information of the last 17 | * successful scan. 18 | */ 19 | package aimax.osm.gps; -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/logic/propositional/algorithms/PLFCEntailsTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.logic.propositional.algorithms; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Before; 5 | import org.junit.Test; 6 | 7 | import aima.core.logic.propositional.algorithms.KnowledgeBase; 8 | import aima.core.logic.propositional.algorithms.PLFCEntails; 9 | import aima.core.logic.propositional.parsing.PEParser; 10 | 11 | /** 12 | * @author Ravi Mohan 13 | * 14 | */ 15 | public class PLFCEntailsTest { 16 | PEParser parser; 17 | 18 | PLFCEntails plfce; 19 | 20 | @Before 21 | public void setUp() { 22 | plfce = new PLFCEntails(); 23 | } 24 | 25 | @Test 26 | public void testAIMAExample() { 27 | KnowledgeBase kb = new KnowledgeBase(); 28 | kb.tell(" (P => Q)"); 29 | kb.tell("((L AND M) => P)"); 30 | kb.tell("((B AND L) => M)"); 31 | kb.tell("( (A AND P) => L)"); 32 | kb.tell("((A AND B) => L)"); 33 | kb.tell("(A)"); 34 | kb.tell("(B)"); 35 | 36 | Assert.assertEquals(true, plfce.plfcEntails(kb, "Q")); 37 | } 38 | } -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/logic/fol/PredicateCollectorTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.logic.fol; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import aima.core.logic.fol.PredicateCollector; 10 | import aima.core.logic.fol.domain.DomainFactory; 11 | import aima.core.logic.fol.parsing.FOLParser; 12 | import aima.core.logic.fol.parsing.ast.Predicate; 13 | import aima.core.logic.fol.parsing.ast.Sentence; 14 | 15 | /** 16 | * @author Ravi Mohan 17 | * 18 | */ 19 | public class PredicateCollectorTest { 20 | PredicateCollector collector; 21 | 22 | FOLParser parser; 23 | 24 | @Before 25 | public void setUp() { 26 | collector = new PredicateCollector(); 27 | parser = new FOLParser(DomainFactory.weaponsDomain()); 28 | } 29 | 30 | @Test 31 | public void testSimpleSentence() { 32 | Sentence s = parser.parse("(Missile(x) => Weapon(x))"); 33 | List predicates = collector.getPredicates(s); 34 | Assert.assertNotNull(predicates); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/common/Token.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.common; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Token { 8 | private String text; 9 | 10 | private int type; 11 | 12 | public Token(int type, String text) { 13 | this.type = type; 14 | this.text = text; 15 | } 16 | 17 | public String getText() { 18 | return text; 19 | } 20 | 21 | public int getType() { 22 | return type; 23 | } 24 | 25 | @Override 26 | public boolean equals(Object o) { 27 | 28 | if (this == o) { 29 | return true; 30 | } 31 | if ((o == null) || (this.getClass() != o.getClass())) { 32 | return false; 33 | } 34 | Token other = (Token) o; 35 | return ((other.type == type) && (other.text.equals(text))); 36 | } 37 | 38 | @Override 39 | public int hashCode() { 40 | int result = 17; 41 | result = 37 * result + type; 42 | result = 37 * result + text.hashCode(); 43 | return 17; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "[ " + type + " " + text + " ]"; 49 | } 50 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepFoChAlreadyAFact.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import aima.core.logic.fol.kb.data.Literal; 8 | 9 | /** 10 | * @author Ciaran O'Reilly 11 | * 12 | */ 13 | public class ProofStepFoChAlreadyAFact extends AbstractProofStep { 14 | // 15 | private static final List _noPredecessors = new ArrayList(); 16 | // 17 | private Literal fact = null; 18 | 19 | public ProofStepFoChAlreadyAFact(Literal fact) { 20 | this.fact = fact; 21 | } 22 | 23 | // 24 | // START-ProofStep 25 | @Override 26 | public List getPredecessorSteps() { 27 | return Collections.unmodifiableList(_noPredecessors); 28 | } 29 | 30 | @Override 31 | public String getProof() { 32 | return fact.toString(); 33 | } 34 | 35 | @Override 36 | public String getJustification() { 37 | return "Already a known fact in the KB."; 38 | } 39 | // END-ProofStep 40 | // 41 | } 42 | -------------------------------------------------------------------------------- /aima-all/release/aimax-osm-MiniNaviApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OSM Mini Navigation Application 5 | OSM Mini Navigation Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/gps/NmeaFileReader.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.gps; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | 7 | /** 8 | * Reads NMEA data from file. 9 | * @author Ruediger Lunde 10 | * 11 | */ 12 | public class NmeaFileReader extends NmeaReader { 13 | private File file; 14 | private long delay = 0; //1000l; 15 | 16 | public NmeaFileReader(File file) { 17 | this.file = file; 18 | } 19 | 20 | @Override 21 | public void openStream() throws Exception { 22 | inputStream = new BufferedInputStream(new FileInputStream(file)); 23 | Thread thread = new FileReaderThread(); 24 | thread.run(); 25 | } 26 | 27 | private class FileReaderThread extends Thread { 28 | @Override 29 | public void run() { 30 | try { 31 | while (inputStream.available() > 0) { 32 | readFromStream(true); 33 | if (delay > 0) 34 | sleep(delay); 35 | } 36 | closeStream(); 37 | } catch (Exception e) { 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/probability/reasoning/RandomVariableTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.probability.reasoning; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | 9 | import aima.core.probability.RandomVariable; 10 | import aima.core.probability.reasoning.HmmConstants; 11 | 12 | /** 13 | * @author Ravi Mohan 14 | * 15 | */ 16 | public class RandomVariableTest { 17 | 18 | private RandomVariable aDistribution; 19 | 20 | @Before 21 | public void setUp() { 22 | List states = Arrays.asList(new String[] { 23 | HmmConstants.DOOR_OPEN, HmmConstants.DOOR_CLOSED }); 24 | aDistribution = new RandomVariable("HiddenState", states); 25 | } 26 | 27 | @Test(expected = RuntimeException.class) 28 | public void testSettingValuesOnInvalidStateThrowsException() { 29 | aDistribution.setProbabilityOf("invalid", 0.5); 30 | } 31 | 32 | @Test(expected = RuntimeException.class) 33 | public void testGettingValuesOnInvalidStateThrowsException() { 34 | aDistribution.getProbabilityOf("invalid"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/PLVisitor.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing; 2 | 3 | import aima.core.logic.common.Visitor; 4 | import aima.core.logic.propositional.parsing.ast.BinarySentence; 5 | import aima.core.logic.propositional.parsing.ast.FalseSentence; 6 | import aima.core.logic.propositional.parsing.ast.MultiSentence; 7 | import aima.core.logic.propositional.parsing.ast.Symbol; 8 | import aima.core.logic.propositional.parsing.ast.TrueSentence; 9 | import aima.core.logic.propositional.parsing.ast.UnarySentence; 10 | 11 | /** 12 | * @author Ravi Mohan 13 | * 14 | */ 15 | public interface PLVisitor extends Visitor { 16 | public Object visitSymbol(Symbol s, Object arg); 17 | 18 | public Object visitTrueSentence(TrueSentence ts, Object arg); 19 | 20 | public Object visitFalseSentence(FalseSentence fs, Object arg); 21 | 22 | public Object visitNotSentence(UnarySentence fs, Object arg); 23 | 24 | public Object visitBinarySentence(BinarySentence fs, Object arg); 25 | 26 | public Object visitMultiSentence(MultiSentence fs, Object arg); 27 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/AdaptableHeuristicFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.map; 2 | 3 | import aima.core.search.framework.HeuristicFunction; 4 | 5 | /** 6 | * This class extends heuristic functions in two ways: It maintains a goal and a 7 | * map to estimate distance to goal for states in route planning problems, and 8 | * it provides a method to adapt to different goals. 9 | * 10 | * @author Ruediger Lunde 11 | */ 12 | public abstract class AdaptableHeuristicFunction implements HeuristicFunction, 13 | Cloneable { 14 | /** The Current Goal. */ 15 | protected Object goal; 16 | /** The map to be used for distance to goal estimates. */ 17 | protected Map map; 18 | 19 | /** 20 | * Modifies goal and map information and returns the modified heuristic 21 | * function. 22 | */ 23 | public AdaptableHeuristicFunction adaptToGoal(Object goal, Map map) { 24 | this.goal = goal; 25 | this.map = map; 26 | return this; 27 | } 28 | 29 | // when subclassing: Don't forget to implement the most important method 30 | // public double h(Object state) 31 | } 32 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/datastructure/Triplet.java: -------------------------------------------------------------------------------- 1 | package aima.core.util.datastructure; 2 | 3 | /** 4 | * @author Ravi Mohan 5 | * 6 | */ 7 | public class Triplet { 8 | private final X x; 9 | 10 | private final Y y; 11 | 12 | private final Z z; 13 | 14 | public Triplet(X x, Y y, Z z) { 15 | this.x = x; 16 | this.y = y; 17 | this.z = z; 18 | } 19 | 20 | public X getFirst() { 21 | return x; 22 | } 23 | 24 | public Y getSecond() { 25 | return y; 26 | } 27 | 28 | public Z getThird() { 29 | return z; 30 | } 31 | 32 | @Override 33 | public boolean equals(Object o) { 34 | if (o instanceof Triplet) { 35 | Triplet other = (Triplet) o; 36 | return (x.equals(other.x)) && (y.equals(other.y)) 37 | && (z.equals(other.z)); 38 | } 39 | return false; 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return x.hashCode() + 31 * y.hashCode() + 31 * z.hashCode(); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "< " + x.toString() + " , " + y.toString() + " , " 50 | + z.toString() + " >"; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /aima-all/release/aimax-osm-OSMAndAIMADemoApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OSM and AIMA Unified Demo Application 5 | OSM and AIMA Unified Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /aima-all/release/aimax-osm-OsmViewerPlusApp.jnlp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OSM Map Viewer Plus Demo Application 5 | OSM Map Viewer Plus Demo Application 6 | AIMA3e-Java Open Source Project 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/search/framework/NodeTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.search.framework; 2 | 3 | import java.util.List; 4 | 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import aima.core.search.framework.Node; 9 | 10 | /** 11 | * @author Ravi Mohan 12 | * 13 | */ 14 | public class NodeTest { 15 | 16 | @Test 17 | public void testRootNode() { 18 | Node node1 = new Node("state1"); 19 | Assert.assertTrue(node1.isRootNode()); 20 | Node node2 = new Node("state2", node1, null, 1.0); 21 | Assert.assertTrue(node1.isRootNode()); 22 | Assert.assertFalse(node2.isRootNode()); 23 | Assert.assertEquals(node1, node2.getParent()); 24 | } 25 | 26 | @Test 27 | public void testGetPathFromRoot() { 28 | Node node1 = new Node("state1"); 29 | Node node2 = new Node("state2", node1, null, 1.0); 30 | Node node3 = new Node("state3", node2, null, 1.0); 31 | List path = node3.getPathFromRoot(); 32 | Assert.assertEquals(node1, path.get(0)); 33 | Assert.assertEquals(node2, path.get(1)); 34 | Assert.assertEquals(node3, path.get(2)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/datastructure/FIFOQueue.java: -------------------------------------------------------------------------------- 1 | package aima.core.util.datastructure; 2 | 3 | import java.util.Collection; 4 | import java.util.LinkedList; 5 | 6 | /** 7 | * Artificial Intelligence A Modern Approach (3rd Edition): pg 80.
8 | * 9 | * First-in, first-out or FIFO queue, which pops the oldest element of the queue; 10 | */ 11 | 12 | /** 13 | * @author Ravi Mohan 14 | * @author Ciaran O'Reilly 15 | */ 16 | public class FIFOQueue extends LinkedList implements Queue { 17 | private static final long serialVersionUID = 1; 18 | 19 | public FIFOQueue() { 20 | super(); 21 | } 22 | 23 | public FIFOQueue(Collection c) { 24 | super(c); 25 | } 26 | 27 | // 28 | // START-Queue 29 | public boolean isEmpty() { 30 | return 0 == size(); 31 | } 32 | 33 | public E pop() { 34 | return poll(); 35 | } 36 | 37 | public void push(E element) { 38 | this.addLast(element); 39 | } 40 | 41 | public Queue insert(E element) { 42 | if (offer(element)) { 43 | return this; 44 | } 45 | return null; 46 | } 47 | // END-Queue 48 | // 49 | } -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/applications/OsmAimaDemoApp.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.applications; 2 | 3 | import java.util.Locale; 4 | 5 | import aima.gui.applications.AimaDemoApp; 6 | import aima.gui.applications.AimaDemoFrame; 7 | 8 | /** 9 | * The all-in-one demo application including all apps and 10 | * demos from the aima-gui project and some of the apps from 11 | * the aimax-osm project. 12 | * 13 | * @author Ruediger Lunde 14 | */ 15 | public class OsmAimaDemoApp { 16 | 17 | /** Registers agent applications and console program demos. */ 18 | public static void registerDemos(AimaDemoFrame frame) { 19 | frame.addApp(RoutePlannerApp.class); 20 | frame.addApp(OsmAgentApp.class); 21 | frame.addApp(SearchDemoOsmAgentApp.class); 22 | } 23 | 24 | /** Starts the demo. */ 25 | public static void main(String[] args) { 26 | Locale.setDefault(Locale.US); 27 | AimaDemoFrame frame = new AimaDemoFrame(); 28 | frame.setTitle("AIMA3e Java Demos with OSM"); 29 | AimaDemoApp.registerDemos(frame); 30 | registerDemos(frame); 31 | frame.setSize(800, 600); 32 | frame.setVisible(true); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/learners/MajorityLearner.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.learners; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import aima.core.learning.framework.DataSet; 7 | import aima.core.learning.framework.Example; 8 | import aima.core.learning.framework.Learner; 9 | import aima.core.util.Util; 10 | 11 | /** 12 | * @author Ravi Mohan 13 | * 14 | */ 15 | public class MajorityLearner implements Learner { 16 | 17 | private String result; 18 | 19 | public void train(DataSet ds) { 20 | List targets = new ArrayList(); 21 | for (Example e : ds.examples) { 22 | targets.add(e.targetValue()); 23 | } 24 | result = Util.mode(targets); 25 | } 26 | 27 | public String predict(Example e) { 28 | return result; 29 | } 30 | 31 | public int[] test(DataSet ds) { 32 | int[] results = new int[] { 0, 0 }; 33 | 34 | for (Example e : ds.examples) { 35 | if (e.targetValue().equals(result)) { 36 | results[0] = results[0] + 1; 37 | } else { 38 | results[1] = results[1] + 1; 39 | } 40 | } 41 | return results; 42 | } 43 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/otter/LightestClauseHeuristic.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.otter; 2 | 3 | import java.util.Set; 4 | 5 | import aima.core.logic.fol.kb.data.Clause; 6 | 7 | /** 8 | * @author Ciaran O'Reilly 9 | * 10 | */ 11 | 12 | // Heuristic for selecting lightest clause from SOS. 13 | // To avoid recalculating the lightest clause 14 | // on every call, the interface supports defining 15 | // the initial sos and updates to that set so 16 | // that it can maintain its own internal data 17 | // structures to allow for incremental re-calculation 18 | // of the lightest clause. 19 | public interface LightestClauseHeuristic { 20 | 21 | // Get the lightest clause from the SOS 22 | Clause getLightestClause(); 23 | 24 | // SOS life-cycle methods allowing implementations 25 | // of this interface to incrementally update 26 | // the calculation of the lightest clause as opposed 27 | // to having to recalculate each time. 28 | void initialSOS(Set clauses); 29 | 30 | void addedClauseToSOS(Clause clause); 31 | 32 | void removedClauseFromSOS(Clause clause); 33 | } 34 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/kb/data/ReducedLiteral.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.kb.data; 2 | 3 | import aima.core.logic.fol.parsing.ast.AtomicSentence; 4 | 5 | /** 6 | * @see http://logic.stanford.edu/classes/cs157/2008/lectures/lecture13.pdf 7 | */ 8 | 9 | /** 10 | * @author Ciaran O'Reilly 11 | * 12 | */ 13 | public class ReducedLiteral extends Literal { 14 | private String strRep = null; 15 | 16 | public ReducedLiteral(AtomicSentence atom) { 17 | super(atom); 18 | } 19 | 20 | public ReducedLiteral(AtomicSentence atom, boolean negated) { 21 | super(atom, negated); 22 | } 23 | 24 | @Override 25 | public Literal newInstance(AtomicSentence atom) { 26 | return new ReducedLiteral(atom, isNegativeLiteral()); 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | if (null == strRep) { 32 | StringBuilder sb = new StringBuilder(); 33 | sb.append("["); 34 | if (isNegativeLiteral()) { 35 | sb.append("~"); 36 | } 37 | sb.append(getAtomicSentence().toString()); 38 | sb.append("]"); 39 | strRep = sb.toString(); 40 | } 41 | 42 | return strRep; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/framework/TreeSearch.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.framework; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Artificial Intelligence A Modern Approach (3rd Edition): Figure 3.7, page 77. 7 | * 8 | * function TREE-SEARCH(problem) returns a solution, or failure 9 | * initialize the frontier using the initial state of the problem 10 | * loop do 11 | * if the frontier is empty then return failure 12 | * choose a leaf node and remove it from the frontier 13 | * if the node contains a goal state then return the corresponding solution 14 | * expand the chosen node, adding the resulting nodes to the frontier 15 | * 16 | * Figure 3.7 An informal description of the general tree-search algorithm. 17 | */ 18 | 19 | /** 20 | * @author Ravi Mohan 21 | * 22 | */ 23 | public class TreeSearch extends QueueSearch { 24 | 25 | @Override 26 | public List getResultingNodesToAddToFrontier(Node nodeToExpand, 27 | Problem problem) { 28 | // expand the chosen node, adding the resulting nodes to the frontier 29 | return expandNode(nodeToExpand, problem); 30 | } 31 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/Symbol.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import aima.core.logic.propositional.parsing.PLVisitor; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class Symbol extends AtomicSentence { 10 | private String value; 11 | 12 | public Symbol(String value) { 13 | this.value = value; 14 | } 15 | 16 | public String getValue() { 17 | return value; 18 | } 19 | 20 | @Override 21 | public boolean equals(Object o) { 22 | 23 | if (this == o) { 24 | return true; 25 | } 26 | if ((o == null) || (this.getClass() != o.getClass())) { 27 | return false; 28 | } 29 | Symbol sym = (Symbol) o; 30 | return (sym.getValue().equals(getValue())); 31 | 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | int result = 17; 37 | result = 37 * result + value.hashCode(); 38 | return result; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return getValue(); 44 | } 45 | 46 | @Override 47 | public Object accept(PLVisitor plv, Object arg) { 48 | return plv.visitSymbol(this, arg); 49 | } 50 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/DynAttributeNames.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.map; 2 | 3 | /** 4 | * The AIMA framework uses dynamic attributes to make implementations of agents 5 | * and environments completely independent of each other. The disadvantage of 6 | * this concept is, that it's error-prone. This set of constants is designed to 7 | * make information exchange more reliable for map agents. Two kinds of 8 | * attributes are distinguished. Percept attributes are attached to percepts. 9 | * They are generated by the environment and read by by the agent. 10 | * EnvironmentState attributes are attached to the EnvironmentState of the 11 | * Environment. 12 | * 13 | * @author Ruediger Lunde 14 | */ 15 | public class DynAttributeNames { 16 | /** 17 | * Name of a dynamic attribute, which contains the current location of the 18 | * agent. Expected value type: String. 19 | */ 20 | public static final String AGENT_LOCATION = "location"; 21 | /** 22 | * Name of a dynamic attribute, which tells the agent where it is. Expected 23 | * value type: String. 24 | */ 25 | public static final String PERCEPT_IN = "in"; 26 | } 27 | -------------------------------------------------------------------------------- /aima-core/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) <2003-2011> 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/decision/MDPUtilityFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.decision; 2 | 3 | import java.util.Hashtable; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class MDPUtilityFunction { 10 | private Hashtable hash; 11 | 12 | public MDPUtilityFunction() { 13 | hash = new Hashtable(); 14 | } 15 | 16 | public Double getUtility(STATE_TYPE state) { 17 | Double d = hash.get(state); 18 | if (d == null) { 19 | System.out.println("no value for " + state); 20 | } 21 | return d; 22 | } 23 | 24 | public void setUtility(STATE_TYPE state, double utility) { 25 | hash.put(state, utility); 26 | } 27 | 28 | public MDPUtilityFunction copy() { 29 | MDPUtilityFunction other = new MDPUtilityFunction(); 30 | for (STATE_TYPE state : hash.keySet()) { 31 | other.setUtility(state, hash.get(state)); 32 | } 33 | return other; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return hash.toString(); 39 | } 40 | 41 | public boolean hasUtilityFor(STATE_TYPE state) { 42 | 43 | return hash.keySet().contains(state); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /aimax-osm/src/main/java/aimax/osm/applications/OsmViewerApp.java: -------------------------------------------------------------------------------- 1 | package aimax.osm.applications; 2 | 3 | import java.util.Locale; 4 | 5 | import aimax.osm.data.DataResource; 6 | import aimax.osm.viewer.MapViewFrame; 7 | 8 | /** 9 | * Opens a MapViewFrame and initializes it with a 10 | * map of Ulm, provided that a file with name ulm.osm is found 11 | * in the resource/maps path. 12 | * @author Ruediger Lunde 13 | */ 14 | public class OsmViewerApp { 15 | /** 16 | * Start application with program arg -screenwidth=xx 17 | * (with xx the width in cm) 18 | * or -screensize=yy (with yy measured diagonally in inch). 19 | */ 20 | public static void main(String[] args) { 21 | // indicates progress when reading large maps (for testing only) 22 | // Logger.getLogger("aimax.osm").setLevel(Level.FINEST); 23 | // Logger.getLogger("").getHandlers()[0].setLevel(Level.FINE); 24 | 25 | Locale.setDefault(Locale.US); 26 | MapViewFrame frame = new MapViewFrame(args); 27 | frame.readMap(DataResource.getULMFileResource()); 28 | frame.setTitle("OSM Viewer"); 29 | frame.setSize(800, 600); 30 | frame.setVisible(true); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /aima-gui/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) <2003-2011> 2 | 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/kb/data/CNF.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.kb.data; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | /** 8 | * Conjunctive Normal Form (CNF) : a conjunction of clauses, where each 9 | * clause is a disjunction of literals. 10 | */ 11 | 12 | /** 13 | * @author Ciaran O'Reilly 14 | * 15 | */ 16 | public class CNF { 17 | 18 | private List conjunctionOfClauses = new ArrayList(); 19 | 20 | public CNF(List conjunctionOfClauses) { 21 | this.conjunctionOfClauses.addAll(conjunctionOfClauses); 22 | } 23 | 24 | public int getNumberOfClauses() { 25 | return conjunctionOfClauses.size(); 26 | } 27 | 28 | public List getConjunctionOfClauses() { 29 | return Collections.unmodifiableList(conjunctionOfClauses); 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | StringBuilder sb = new StringBuilder(); 35 | for (int i = 0; i < conjunctionOfClauses.size(); i++) { 36 | if (i > 0) { 37 | sb.append(","); 38 | } 39 | sb.append(conjunctionOfClauses.get(i).toString()); 40 | } 41 | 42 | return sb.toString(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/informed/AStarEvaluationFunction.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.informed; 2 | 3 | import aima.core.search.framework.EvaluationFunction; 4 | import aima.core.search.framework.HeuristicFunction; 5 | import aima.core.search.framework.Node; 6 | import aima.core.search.framework.PathCostFunction; 7 | 8 | /** 9 | * Artificial Intelligence A Modern Approach (3rd Edition): page 93. 10 | * 11 | * The most widely known form of best-first search is called A* search (pronounced "A-star 12 | * Search"). It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the cost 13 | * to get from the node to the goal:
14 | * 15 | * f(n) = g(n) + h(n). 16 | * 17 | */ 18 | 19 | /** 20 | * @author Ciaran O'Reilly 21 | * 22 | */ 23 | public class AStarEvaluationFunction implements EvaluationFunction { 24 | 25 | private PathCostFunction gf = new PathCostFunction(); 26 | private HeuristicFunction hf = null; 27 | 28 | public AStarEvaluationFunction(HeuristicFunction hf) { 29 | this.hf = hf; 30 | } 31 | 32 | public double f(Node n) { 33 | // f(n) = g(n) + h(n) 34 | return gf.g(n) + hf.h(n.getState()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/vacuum/VacuumEnvPercept.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.vacuum; 2 | 3 | import aima.core.agent.impl.DynamicPercept; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * @author Ciaran O'Reilly 8 | */ 9 | public class VacuumEnvPercept extends DynamicPercept { 10 | public static final String ATTRIBUTE_AGENT_LOCATION = "agentLocation"; 11 | public static final String ATTRIBUTE_STATE = "state"; 12 | 13 | public VacuumEnvPercept(String agentLocation, 14 | VacuumEnvironment.LocationState state) { 15 | setAttribute(ATTRIBUTE_AGENT_LOCATION, agentLocation); 16 | setAttribute(ATTRIBUTE_STATE, state); 17 | } 18 | 19 | public String getAgentLocation() { 20 | return (String) getAttribute(ATTRIBUTE_AGENT_LOCATION); 21 | } 22 | 23 | public VacuumEnvironment.LocationState getLocationState() { 24 | return (VacuumEnvironment.LocationState) getAttribute(ATTRIBUTE_STATE); 25 | } 26 | 27 | public String toString() { 28 | StringBuilder sb = new StringBuilder(); 29 | 30 | sb.append("["); 31 | sb.append(getAgentLocation()); 32 | sb.append(", "); 33 | sb.append(getLocationState()); 34 | sb.append("]"); 35 | 36 | return sb.toString(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepChainDropped.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import aima.core.logic.fol.kb.data.Chain; 8 | 9 | /** 10 | * @author Ciaran O'Reilly 11 | * 12 | */ 13 | public class ProofStepChainDropped extends AbstractProofStep { 14 | private List predecessors = new ArrayList(); 15 | private Chain dropped = null; 16 | private Chain droppedOff = null; 17 | 18 | public ProofStepChainDropped(Chain dropped, Chain droppedOff) { 19 | this.dropped = dropped; 20 | this.droppedOff = droppedOff; 21 | this.predecessors.add(droppedOff.getProofStep()); 22 | } 23 | 24 | // 25 | // START-ProofStep 26 | @Override 27 | public List getPredecessorSteps() { 28 | return Collections.unmodifiableList(predecessors); 29 | } 30 | 31 | @Override 32 | public String getProof() { 33 | return dropped.toString(); 34 | } 35 | 36 | @Override 37 | public String getJustification() { 38 | return "Dropped: " + droppedOff.getProofStep().getStepNumber(); 39 | } 40 | // END-ProofStep 41 | // 42 | } 43 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/util/FrequencyCounter.java: -------------------------------------------------------------------------------- 1 | package aima.core.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.Set; 6 | 7 | /** 8 | * @author Ravi Mohan 9 | * 10 | */ 11 | public class FrequencyCounter { 12 | private Map counter; 13 | 14 | public FrequencyCounter() { 15 | counter = new HashMap(); 16 | } 17 | 18 | public Integer getCount(T key) { 19 | Integer value = counter.get(key); 20 | if (value == null) { 21 | return 0; 22 | } 23 | return value; 24 | } 25 | 26 | public void incrementFor(T key) { 27 | Integer value = counter.get(key); 28 | if (value == null) { 29 | counter.put(key, 1); 30 | } else { 31 | counter.put(key, value + 1); 32 | } 33 | } 34 | 35 | public Double probabilityOf(T key) { 36 | Integer value = getCount(key); 37 | if (value == 0) { 38 | return 0.0; 39 | } else { 40 | Double total = 0.0; 41 | for (T k : counter.keySet()) { 42 | total += getCount(k); 43 | } 44 | return value / total; 45 | } 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return counter.toString(); 51 | } 52 | 53 | public Set getStates() { 54 | return counter.keySet(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/environment/map/Map.java: -------------------------------------------------------------------------------- 1 | package aima.core.environment.map; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.util.datastructure.Point2D; 6 | 7 | /** 8 | * Provides a general interface for maps. 9 | * 10 | * @author Ruediger Lunde 11 | */ 12 | public interface Map { 13 | 14 | /** Returns a list of all locations. */ 15 | public List getLocations(); 16 | 17 | /** 18 | * Answers to the question: Where can I get, following one of the 19 | * connections starting at the specified location? 20 | */ 21 | public List getLocationsLinkedTo(String fromLocation); 22 | 23 | /** 24 | * Returns the travel distance between the two specified locations if they 25 | * are linked by a connection and null otherwise. 26 | */ 27 | public Double getDistance(String fromLocation, String toLocation); 28 | 29 | /** 30 | * Returns the position of the specified location. The position is 31 | * represented by two coordinates, e.g. latitude and longitude values. 32 | */ 33 | public Point2D getPosition(String loc); 34 | 35 | /** 36 | * Returns a location which is selected by random. 37 | */ 38 | public String randomlyGenerateDestination(); 39 | } 40 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/probability/reasoning/SensorModel.java: -------------------------------------------------------------------------------- 1 | package aima.core.probability.reasoning; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import aima.core.util.datastructure.Table; 7 | import aima.core.util.math.Matrix; 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * 12 | */ 13 | public class SensorModel { 14 | private Table table; 15 | 16 | private List states; 17 | 18 | public SensorModel(List states, List perceptions) { 19 | this.states = states; 20 | table = new Table(states, perceptions); 21 | } 22 | 23 | public void setSensingProbability(String state, String perception, 24 | double probability) { 25 | table.set(state, perception, probability); 26 | } 27 | 28 | public Double get(String state, String perception) { 29 | return table.get(state, perception); 30 | } 31 | 32 | public Matrix asMatrix(String perception) { 33 | List values = new ArrayList(); 34 | // for (String state : aBelief.states()) { 35 | for (String state : states) { 36 | values.add(get(state, perception)); 37 | } 38 | Matrix OMatrix = Matrix.createDiagonalMatrix(values); 39 | return OMatrix; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /aima-gui/src/main/java/aima/gui/demo/agent/TrivialVacuumDemo.java: -------------------------------------------------------------------------------- 1 | package aima.gui.demo.agent; 2 | 3 | import aima.core.agent.Agent; 4 | import aima.core.agent.Environment; 5 | import aima.core.agent.EnvironmentView; 6 | import aima.core.agent.impl.SimpleEnvironmentView; 7 | import aima.core.environment.vacuum.ModelBasedReflexVacuumAgent; 8 | import aima.core.environment.vacuum.VacuumEnvironment; 9 | 10 | /** 11 | * Demonstrates, how to set up a simple environment, place an agent in it, 12 | * and run it. The vacuum world is used as a simple example. 13 | * 14 | * @author Ruediger Lunde 15 | */ 16 | public class TrivialVacuumDemo { 17 | public static void main(String[] args) { 18 | // create environment with random state of cleaning. 19 | Environment env = new VacuumEnvironment(); 20 | EnvironmentView view = new SimpleEnvironmentView(); 21 | env.addEnvironmentView(view); 22 | 23 | Agent a = null; 24 | a = new ModelBasedReflexVacuumAgent(); 25 | // a = new ReflexVacuumAgent(); 26 | // a = new SimpleReflexVacuumAgent(); 27 | // a = new TableDrivenVacuumAgent(); 28 | 29 | env.addAgent(a); 30 | env.step(16); 31 | env.notifyViews("Performance=" + env.getPerformanceMeasure(a)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/agent/Agent.java: -------------------------------------------------------------------------------- 1 | package aima.core.agent; 2 | 3 | /** 4 | * Artificial Intelligence A Modern Approach (3rd Edition): Figure 2.1, page 35.
5 | * 6 | * Figure 2.1 Agents interact with environments through sensors and actuators. 7 | */ 8 | 9 | /** 10 | * @author Ravi Mohan 11 | * @author Ciaran O'Reilly 12 | */ 13 | public interface Agent extends EnvironmentObject { 14 | /** 15 | * Call the Agent's program, which maps any given percept sequences to an 16 | * action. 17 | * 18 | * @param percept 19 | * The current percept of a sequence perceived by the Agent. 20 | * @return the Action to be taken in response to the currently perceived 21 | * percept. 22 | */ 23 | Action execute(Percept percept); 24 | 25 | /** 26 | * Life-cycle indicator as to the liveness of an Agent. 27 | * 28 | * @return true if the Agent is to be considered alive, false otherwise. 29 | */ 30 | boolean isAlive(); 31 | 32 | /** 33 | * Set the current liveness of the Agent. 34 | * 35 | * @param alive 36 | * set to true if the Agent is to be considered alive, false 37 | * otherwise. 38 | */ 39 | void setAlive(boolean alive); 40 | } 41 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/propositional/parsing/ast/UnarySentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.propositional.parsing.ast; 2 | 3 | import aima.core.logic.propositional.parsing.PLVisitor; 4 | 5 | /** 6 | * @author Ravi Mohan 7 | * 8 | */ 9 | public class UnarySentence extends ComplexSentence { 10 | private Sentence negated; 11 | 12 | public Sentence getNegated() { 13 | return negated; 14 | } 15 | 16 | public UnarySentence(Sentence negated) { 17 | this.negated = negated; 18 | } 19 | 20 | @Override 21 | public boolean equals(Object o) { 22 | 23 | if (this == o) { 24 | return true; 25 | } 26 | if ((o == null) || (this.getClass() != o.getClass())) { 27 | return false; 28 | } 29 | UnarySentence ns = (UnarySentence) o; 30 | return (ns.negated.equals(negated)); 31 | 32 | } 33 | 34 | @Override 35 | public int hashCode() { 36 | int result = 17; 37 | result = 37 * result + negated.hashCode(); 38 | return result; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return " ( NOT " + negated.toString() + " ) "; 44 | } 45 | 46 | @Override 47 | public Object accept(PLVisitor plv, Object arg) { 48 | return plv.visitNotSentence(this, arg); 49 | } 50 | } -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/learning/inductive/ConstantDecisonTree.java: -------------------------------------------------------------------------------- 1 | package aima.core.learning.inductive; 2 | 3 | import aima.core.learning.framework.Example; 4 | import aima.core.util.Util; 5 | 6 | /** 7 | * @author Ravi Mohan 8 | * 9 | */ 10 | public class ConstantDecisonTree extends DecisionTree { 11 | // represents leaf nodes like "Yes" or "No" 12 | private String value; 13 | 14 | public ConstantDecisonTree(String value) { 15 | this.value = value; 16 | } 17 | 18 | @Override 19 | public void addLeaf(String attributeValue, String decision) { 20 | throw new RuntimeException("cannot add Leaf to ConstantDecisonTree"); 21 | } 22 | 23 | @Override 24 | public void addNode(String attributeValue, DecisionTree tree) { 25 | throw new RuntimeException("cannot add Node to ConstantDecisonTree"); 26 | } 27 | 28 | @Override 29 | public Object predict(Example e) { 30 | return value; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "DECISION -> " + value; 36 | } 37 | 38 | @Override 39 | public String toString(int depth, StringBuffer buf) { 40 | buf.append(Util.ntimes("\t", depth + 1)); 41 | buf.append("DECISION -> " + value + "\n"); 42 | return buf.toString(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/logic/fol/inference/proof/ProofStepClauseClausifySentence.java: -------------------------------------------------------------------------------- 1 | package aima.core.logic.fol.inference.proof; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import aima.core.logic.fol.kb.data.Clause; 8 | import aima.core.logic.fol.parsing.ast.Sentence; 9 | 10 | /** 11 | * @author Ciaran O'Reilly 12 | * 13 | */ 14 | public class ProofStepClauseClausifySentence extends AbstractProofStep { 15 | private List predecessors = new ArrayList(); 16 | private Clause clausified = null; 17 | 18 | public ProofStepClauseClausifySentence(Clause clausified, 19 | Sentence origSentence) { 20 | this.clausified = clausified; 21 | this.predecessors.add(new ProofStepPremise(origSentence)); 22 | } 23 | 24 | // 25 | // START-ProofStep 26 | @Override 27 | public List getPredecessorSteps() { 28 | return Collections.unmodifiableList(predecessors); 29 | } 30 | 31 | @Override 32 | public String getProof() { 33 | return clausified.toString(); 34 | } 35 | 36 | @Override 37 | public String getJustification() { 38 | return "Clausified " + predecessors.get(0).getStepNumber(); 39 | } 40 | // END-ProofStep 41 | // 42 | } 43 | -------------------------------------------------------------------------------- /aima-core/src/main/java/aima/core/search/uninformed/DepthFirstSearch.java: -------------------------------------------------------------------------------- 1 | package aima.core.search.uninformed; 2 | 3 | import java.util.List; 4 | 5 | import aima.core.agent.Action; 6 | import aima.core.search.framework.Metrics; 7 | import aima.core.search.framework.Node; 8 | import aima.core.search.framework.Problem; 9 | import aima.core.search.framework.QueueSearch; 10 | import aima.core.search.framework.Search; 11 | import aima.core.util.datastructure.LIFOQueue; 12 | 13 | /** 14 | * Artificial Intelligence A Modern Approach (3rd Edition): page 85. 15 | * 16 | * Depth-first search always expands the deepest node in the current frontier of the search tree. 17 | * 18 | * Note: Supports both Tree and Graph based versions by assigning an instance 19 | * of TreeSearch or GraphSearch to its constructor. 20 | */ 21 | 22 | /** 23 | * @author Ravi Mohan 24 | * 25 | */ 26 | public class DepthFirstSearch implements Search { 27 | 28 | QueueSearch search; 29 | 30 | public DepthFirstSearch(QueueSearch search) { 31 | this.search = search; 32 | } 33 | 34 | public List search(Problem p) { 35 | return search.search(p, new LIFOQueue()); 36 | } 37 | 38 | public Metrics getMetrics() { 39 | return search.getMetrics(); 40 | } 41 | } -------------------------------------------------------------------------------- /aima-core/src/test/java/aima/test/core/unit/agent/impl/PerceptSequenceTest.java: -------------------------------------------------------------------------------- 1 | package aima.test.core.unit.agent.impl; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import aima.core.agent.Percept; 10 | import aima.core.agent.impl.DynamicPercept; 11 | 12 | /** 13 | * @author Ciaran O'Reilly 14 | * 15 | */ 16 | public class PerceptSequenceTest { 17 | 18 | @Test 19 | public void testToString() { 20 | List ps = new ArrayList(); 21 | ps.add(new DynamicPercept("key1", "value1")); 22 | 23 | Assert.assertEquals("[Percept[key1==value1]]", ps.toString()); 24 | 25 | ps.add(new DynamicPercept("key1", "value1", "key2", "value2")); 26 | 27 | Assert.assertEquals( 28 | "[Percept[key1==value1], Percept[key1==value1, key2==value2]]", 29 | ps.toString()); 30 | } 31 | 32 | @Test 33 | public void testEquals() { 34 | List ps1 = new ArrayList(); 35 | List ps2 = new ArrayList(); 36 | 37 | Assert.assertEquals(ps1, ps2); 38 | 39 | ps1.add(new DynamicPercept("key1", "value1")); 40 | 41 | Assert.assertNotSame(ps1, ps2); 42 | 43 | ps2.add(new DynamicPercept("key1", "value1")); 44 | 45 | Assert.assertEquals(ps1, ps2); 46 | } 47 | } 48 | --------------------------------------------------------------------------------