Home>>Examples

Example Codes

I.          CNP as an Imperative Programming Paradigm – procedural CNP-solutions

Selection Sort – Selection Sort

Generic Systematic Search (DEPTH-FIRST WITH LEAP-FROGGING, BREADTH-FIRST, UNIFORM-COST, BEST-FIRST, A*)

o   Map Traversal Problem

§  MTP AStar with Libs

§  MTP DFS with Libs

o   8-tiles Puzzle – 8-tiles AStar with Libs

BACKRACKING

o   Map Traversal Problem – MTP Backtracking-procedural

 

II.          CNP as a Declarative Programming Paradigm – declarative and hybrid CNP-solutions

II.1.            STATE SPACE SEARCH

II.1.1.       BACKTRACKING

Approach 1: Complete CN, copy of the Simple State Space (copy of the world)

o   Map Traversal Problem

§  one solution – MTP Backtracking-one solution

§  all solutions – MTP Backtracking-all solutions

§  find cost/length of the solution – MTP Backtracking-solution cost

o   Missionaries and Cannibals Problem – MissCan Backtracking- solution cost

o   8-tiles Puzzle – 8-tiles Backtracking-solution cost

o   Monkey and Banana Problem – MonBan Backtracking-Simple State Space

Approach 2: Complete CN, copy of the State Space

o   Monkey and Banana Problem – MonBan Backtracking- State Space

Approach 3: Iterative CN

o   Map Traversal Problem with a global variable and one subnet – MTP Backtracking-iterative

o   Missionaries and Cannibals Problem with a subnet variable and one subnet – MissCan Backtracking-iterative

o   Monkey and Banana Problem with a global variable and 2 subnets - MonBan Backtracking-iterative

Approach 4: Recursive CN

o   Map Traversal Problem – MTP Backtracking-recursive

o   Missionaries and Cannibals Problem with primitives, mixing condition and action – MissCan Backtracking-recursive

o   Monkey and Banana Problem with constants as actual subnet’s parameters – MonBan Backtracking-recursive

 

II.1.2.       COST-LIMITED SEARCH

Approach 1: Complete CN, copy of the Simple State Space

o   Map Traversal Problem – MTP CostLimited

Approach 4: Recursive CN

o   Missionaries and Cannibals Problem - MissCan CostLimited-recursive

 

II.1.3.       DEPTH-LIMITED SEARCH

Approach 1: Complete CN, copy of the Simple State Space

o   8-tiles Puzzle - 8-tiles DepthLimited

Approach 3: Iterative CN

o   Map Traversal Problem - MTP DepthLimited-iterative

Approach 4: Recursive CN

o   Map Traversal Problem - MTP DepthLimited-recursve

 

II.1.4.       Optimal Search (version of BRANCH-AND-BOUND)

Approach 1: Complete CN, copy of the Simple State Space

o   Map Traversal Problem - MTP BranchBound

 

II.1.5.       HILL-CLIMBING

Approach 1: Complete CN, copy of the Simple State Space

§  HILL-CLIMBING with allowed downhill-movements - Map Traversal Problem - MTP HillClimbing-downhills allowed

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem - MTP HillClimbing-downhills forbidden

Approach 4: Recursive CN

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem

Version 1 - with primitives, mixing condition and action - MTP HillClimbing-recursive 1

Version 2 - with constants as actual subnet’s parameters - MTP HillClimbing-recursive 2

 

II.1.6.       IRREVOCABLE HILL-CLIMBING – (like HILL-CLIMBING but with [NUMBEROFARROWS=1] or [BACKTRACKING=NO])

Approach 1: Complete CN, copy of the Simple State Space

§  HILL-CLIMBING with allowed downhill-movements - Map Traversal Problem - MTP IrrHillClimbing-downhills allowed

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem -MTP IrrHillClimbing-downhills forbidden

Approach 4: Recursive CN

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem

Version 1 - with primitives, mixing condition and action - MTP IrrHillClimbing-recursive 1

Version 2 - with constants as actual subnet’s parameters – MTP IrrHillClimbing-recursive 2

 

II.1.7.       HILL-CLIMBING with limited revocability - like HILL-CLIMBING but with [NUMBEROFARROWS=b]

Approach 1: Complete CN, copy of the Simple State Space

§  HILL-CLIMBING with allowed downhill-movements - Map Traversal Problem - MTP LimRevHillClimbing-downhills allowed

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem - MTP LimRevHillClimbing-downhills forbidden

Approach 4: Recursive CN

§  HILL-CLIMBING with forbidden downhill-movements - Map Traversal Problem

Version 1 - with primitives, mixing condition and action - MTP LimRevHillClimbing-recursive 1

Version 2 - with constants as actual subnet’s parameters – MTP LimRevHillClimbing-recursive 2

 

II.1.8.       STOCHASTIC HILL-CLIMBING

Approach 1: Complete CN, copy of the Simple State Space

§  STOCHASTIC HILL-CLIMBING - Map Traversal Problem - MTP StochHillClimbing

Approach 4: Recursive CN

§  STOCHASTIC HILL-CLIMBING - Map Traversal Problem - MTP StochHillClimbing-recursive

 

II.1.9.       FIRST-CHOICE HILL-CLIMBING

Approach 1: Complete CN, copy of the Simple State Space

§  FIRST-CHOICE HILL-CLIMBING - Map Traversal Problem - MTP FirstChoiceHillClimbing

 

II.1.10.   SIMULATED ANNEALING – hybrid solution

o   The Traveling Salesperson - TSP SimAnn-ABCDE

 

II.2.            CONSTRAINT SATISFACTION PROBLEMS – 8-QUEENS PROBLEM

II.2.1.       BACKTRACKING-подход

o   FORWARD CHECKING with static and dynamic variable and value ordering heuristics (MRV, degree and LCV) – 8-Queens FC static&dynamic heuristics

o   FORWARD CHECKING with static static variable and value ordering heuristics (degree and static LCV) - 8-Queens FC static heuristics

o   FORWARD CHECKING - 8-Queens FC

o   Stochastic FORWARD CHECKING (Forward Checking with random variable and value ordering) - 8-Queens StochFC

 

II.2.2.       LOCAL SEARCH

o   CBLS with most conflicted variable chosen – 8-Queens CLBS most conflicted variable

o   Stochastic CBLS (CBLS with randomly chosen conflicted variable) –8-Queens StochCLBS

 

II.3.            IDENTIFICATION AND DIAGNOSTIC PROBLEMS

o   Animal Identification Problem (forward execution) – Animals forward

o   Animal Identification Problem (backward execution) - Animals backward

 

II.4.            NONDETERMINISTIC AND RANDOMIZED MODELS IN COMPUTATION THEORY AND ALGORITHM DESIGN

o   NFA – NFA

o   NCFG

§  Regular Expressions- NCFG regular expressions

§  Arithmetic Expressions - NCFG arithmetic expressions

o   Nondeterministic Turing machine –NTM

o   Probabilistic Turing machine – declarative solution - PTM declarative

o   Probabilistic Turing machine – procedural solution - PTM procedural

o   Game Tree Evaluation - Game Tree Evaluation

 

II.5.            Simulating core Prolog AND ITS Computation Control

o   CNP model of a core Prolog program - Simulating PROLOG

o   Simulating the PROLOG’s CUT - Simulating CUT

o   Modeling of the common uses of the CUT

§  Confirming the choice of a rule – Mutually Exclusive Clauses

§  The CUT-FAIL combination (modeling of the NOT) - Simulating NOT

Avoiding (stopping) an infinite loop - Stopping Infinite Loo

 

Homeme>>Primitives