Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (deftemplate path
- (slot start)
- (slot end)
- (multislot path)
- (slot cost))
- (deftemplate find_NG
- (slot start)
- (slot end))
- (deffacts variable_table
- (path (start A) (end B) (path A C R F B) (cost 6))
- (path (start A) (end C) (path A C ) (cost 3.6))
- (path (start A) (end D)(path A C R F D) (cost 5.4))
- (path (start A) (end F) (path A C R F ) (cost 5.5 ) )
- (path (start C) (end B) (path C R F B) (cost 3.6) )
- (path (start C) (end D) (path C R F D) (cost 3.6))
- (path (start C) (end E) (path C R F E) (cost 2.6))
- (path (start C) (end K) (path C R F K) (cost 2))
- )
- (defrule lancesaisiepoint
- ?f1 <- (debut point)
- =>
- (retract ?f1)
- (printout t "how ma
- ny point ")
- (bind ?point (read))
- (assert (point ?point))
- )
- (defrule saisiepoint
- ?f <- (point ?a)
- (test (> ?a 0))
- =>
- (printout t "Entrer nbr point " crlf)
- (printout t "Point name ")
- (bind ?start (read))
- (printout t "Point Value ")
- (bind ?pvalue (read))
- (assert (positive ?start ?pvalue))
- (retract ?f)
- (assert (point (- ?a 1)))
- )
- (defrule lancesaisiemoins
- ?f1 <- (point 0)
- =>
- (retract ?f1)
- (printout t "how many negatives ")
- (bind ?neg (read))
- (assert (moins ?neg))
- )
- (defrule saisiemoins
- ?f <- (moins ?a)
- (test (> ?a 0))
- =>
- (printout t "Entrer nbr of negatives" crlf)
- (printout t "negative name ")
- (bind ?end (read))
- (printout t "negative value ")
- (bind ?negvalue (read))
- (assert (negative ?end ?negvalue ))
- (retract ?f)
- (assert (moins(- ?a 1))))
- (defrule supprnbrpoint ; compter
- ?x<- (point 0)
- =>
- (retract ?x)
- )
- (defrule supprnbrmoins
- ?x<- (moins 0)
- =>
- (retract ?x)
- )
- (defrule info_grid
- ?M <- (positive ?start ?pvalue)
- ?K <- (negative ?end ?negvalue )
- =>
- (assert (start ?start end ?end))
- )
- (defrule variable
- (start ?start end ?end)
- (path (start ?start) (end ?end) (path $?path) (cost ?cost) )
- =>
- (printout t " the PATH " ?start " to " ?end " by " ?path " cost " ?cost crlf)
- (assert (informations ?start to ?end path ?path cost ?cost))
- )
- (defrule cost_low
- (declare (salience -10))
- ;; Rule needs to execute last
- (informations ?start to ?end path ?path cost ?cost)
- (not (informations ? to ? path ? cost ?cost2&:(< ?cost2 ?cost)))
- ;; Need to match infos facts
- =>
- (printout t "The Path from " ?start " is "?end "," ?path " and has the lowest cost : " ?cost crlf))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement