LPS Visualisation

A visualiser system for logic-based framework LPS

Created by Jinwei Zhang

Presentation Overview

  • Background
  • Implementation
  • Conclusion

Background

  • LPS
  • Traffic layouts
  • Technology Background

LPS

LPS stand for Logic Production Systems. It is a "logic-based framework for programming databases and AI (intelligent agent) applications"

LPS combines both production rules and logic program in a single logic-based framework.

Logic production system framework is in the form of < \(R ,L ,D\) >

\(R\): stands for a set of reactive Rules. It is in the form of \( ∀X[antecedent→∃Yconsequent].\)

\(L\): stands for logic programming.\(L=L_{int}∪L_{events}∪L_{aux}.\)

\(D\): stands for domain theory \(D = D_{pre}∪D_{post}.\)

Traffic Background:

One-way,T-junction,Cross-junction,Roundabout,Overtaking

Technology stack

Logic: LPS, LPS.js, LPS.cli(testing)

Front-end: Boostrap, JavaScript, PixiJS,

Back-end: AWS, ExpressJS, MongoDB

Implementation

  • LPS program with traffic norms
  • System front end
  • System back end

LPS program

oneway.lps


% we assume the destination is reachable
maxTime(200).
cycleInterval(30).

loadModule('../scripts/module.js').

fluents([
   stopped(VehicleName),
   velocity(VehicleName, Speed),
   moving(VehicleName),
   coordinate(X, Y),
   location(VehicleName, coordinate(X, Y), Direction),
   trafficLight(coordinate(X, Y), Working_status, Color, FacingDirection),
   street(StreetName, coordinate(X, Y), Width, Height, Number_of_lane),
   goal(VehicleName,coordinate(X, Y))
]).

% events will reserved for traffic lights
events ([

]).

actions ([
  step(Vehicle, NextPlace),
  turn(Vehicle, NewHeading),
  arrive(Vehicle)
]).

initially([
  moving(car0),
  location(car0, coordinate(150, 225), eastward),
  goal(car0,coordinate(900, 225)),
  velocity(car0, 5)
]).



street(mainStreet , coordinate(100, 200), 900, 50, 1).

cloud(coordinate(140,100)).
cloud(coordinate(250,90)).
cloud(coordinate(300,120)).
cloud(coordinate(640,100)).
cloud(coordinate(750,90)).
cloud(coordinate(800,120)).

goal(Vehicle,coordinate(A, B)) from _ to T,
location(Vehicle, coordinate(X, Y), Direction), A==X, B==Y,moving(Vehicle) at T ->
  % testPrint(Vehicle+ ' we have arrived'),
  arrive(Vehicle) at T.


goal(Vehicle,coordinate(A, B)) from _ to T,
location(Vehicle, coordinate(X, Y), Direction), moving(Vehicle) at T ->
  % need to find the right direction here
  % driving forward
    drive(Vehicle) from T to _.

drive(Vehicle) from T to T1 <-
  location(Vehicle, coordinate(X, Y), Direction),
  Direction == northward,
  velocity(Vehicle, Num),
  NewY = Y - Num,
  NextPlace = coordinate(X, NewY),
  step(Vehicle, NextPlace) from T1 to T2.

drive(Vehicle) from T to T1 <-
  location(Vehicle, coordinate(X, Y), Direction),
  Direction == southward,
  velocity(Vehicle, Num),
  NewY = Y + Num,
  NextPlace = coordinate(X, NewY),
  step(Vehicle, NextPlace) from T1 to T2.

drive(Vehicle) from T to T1 <-
  location(Vehicle, coordinate(X, Y), Direction),
  Direction == westward,
  velocity(Vehicle, Num),
  NewX = X-Num,
  NextPlace = coordinate(NewX, Y),
  step(Vehicle, NextPlace) from T1 to T2.

drive(Vehicle) from T to T1 <-
  location(Vehicle, coordinate(X, Y), Direction),
  Direction == eastward,
  velocity(Vehicle, Num),
  NewX = X + Num,
  NextPlace = coordinate(NewX, Y),
  step(Vehicle, NextPlace) from T1 to T2.

% on(coordinate(X,Y),Street) <-



updates(step(Vehicle, NextPlace), location(Vehicle, OldPlace, Direction),  location(Vehicle, NextPlace, Direction)).
updates(turn(Vehicle, NewHeading) , location(Vehicle, Place, OldHeading), location(Vehicle, Place, NewHeading)).
terminates(arrive(Vehicle), moving(Vehicle)).
initiates(arrive(Vehicle), stopped(Vehicle)).

					

Login/Register

One lane traffic road

T-junction road

Cross junction road

Roundabout

Overtaking

Conclusion

  • Evaluation
  • Challenge Faced
  • Future Work

THE END

- Try the visualiser online
- Source code & documentation