I hope this is the correct area to post this type of question, sorry if it's not. I am trying to create an elementary CLIPS shell that selects cars suitable for a user based on some user inputs. I have created most of the shell ok but I cannot get the last function to work to filter the data from (vehicles) based on the elements I am trying to filter on such as:
Basically I have created a data structure for vehicles and I have pushed a load of instances to the stucture the other elements are variables I prompt the user for, once complete I want to filter and print the results in a function called automobileresults or something.
The source I have so far is as follows, thanks to anyone that can help with the final problem.
(defrule seats
=>
(printout
t crlf
"--------------------------------------------------" crlf
"Welcome to the UHI Automobile Suitability Selector" crlf
"--------------------------------------------------" crlf
crlf
"Please input available selections ONLY."
t crlf
t crlf
t crlf
"Please input the number of seats required?" crlf
"Select one of the following numerals (1, 2, 3, 4, 5, 6)" crlf
)
(assert (seats (seats-is (read))))
)
(defrule transmission
=>
(printout
t crlf
t crlf
"Please input a transmission type"
t crlf
"(m)anual" crlf
"(a)utomatic" crlf
t crlf
"Input ONE of the following letters (m, a)" crlf
)
(assert (transmission (transmission-is (read))))
)
(defrule tax
=>
(printout
t crlf
t crlf
"Please input tax band acceptability!"
t crlf
"(h)igh band" crlf
"(l)ow band" crlf
t crlf
"Input ONE of the following letters (h, l)" crlf
)
(assert (tax (tax-is (read))))
)
(defrule insurancegroup
=>
(printout
t crlf
t crlf
"Please input target insurance group!(1 expersive 7 cheap)"
t crlf
"Select one of the following numerals (1, 2, 3, 4, 5, 6, 7)" crlf
)
(assert (insurancegroup (insurancegroup-is (read))))
)
(defrule range
=>
(printout
t crlf
t crlf
"Please input your model range preferences"
t crlf
"(e)ntry level" crlf
"(m)id range" crlf
"(t)op range" crlf
t crlf
"Input ONE of the following letters (e, m, t)" crlf
)
(assert (range (range-is (read))))
)
=>
(printout
t crlf
t crlf "You made the following selections."
t crlf
"Seats : "?seats-is crlf
"Transmission: "?transmission-is crlf
"Taxation Lvl: "?tax-is crlf
"Insur Group : "?insurancegroup-is crlf
"Range : "?range-is
t crlf
)
)
(defrule results
??????????? Help Pls need to print out the filtered results from the inputs)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I hope this is the correct area to post this type of question, sorry if it's not. I am trying to create an elementary CLIPS shell that selects cars suitable for a user based on some user inputs. I have created most of the shell ok but I cannot get the last function to work to filter the data from (vehicles) based on the elements I am trying to filter on such as:
(seats (seats-is) --> vehicles (seats)
(tax (tax-is) --> vehicles (tax)
(transmission (transmission-is) --> (vehicles (transmission)
(insurancegroup-is) --> (vehicles (insurancegroup)
(range (range-is) --> (vehicles (range)
Basically I have created a data structure for vehicles and I have pushed a load of instances to the stucture the other elements are variables I prompt the user for, once complete I want to filter and print the results in a function called automobileresults or something.
The source I have so far is as follows, thanks to anyone that can help with the final problem.
(deftemplate seats
(field seats-is (type INTEGER)))
(deftemplate transmission
(field transmission-is (type SYMBOL)))
(deftemplate tax
(field tax-is (type SYMBOL)))
(deftemplate insurancegroup
(field insurancegroup-is (type INTEGER)))
(deftemplate range
(field range-is (type SYMBOL)))
(deftemplate vehicles
(slot seats)
(slot manufacturer)
(multislot vehiclename)
(multislot vehiclegenre)
(slot transmission)
(slot tax)
(slot insurancegroup)
(slot range))
(deffacts vehicles
(vehicles (seats 6) (vehiclegenre MPV) (manufacturer Nissan) (vehiclename Almera Tino)
(transmission m) (tax h) (insurancegroup 3) (range t))
(vehicles (seats 6) (vehiclegenre MPV) (manufacturer Ford) (vehiclename Galaxy)
(transmission m) (tax h) (insurancegroup 3) (range t))
(vehicles (seats 5) (vehiclegenre SUPERMINI) (manufacturer Ford) (vehiclename KA)
(transmission m) (tax l) (insurancegroup 7) (range t))
(vehicles (seats 5) (vehiclegenre SUPERMINI) (manufacturer Citoren) (vehiclename Saxo)
(transmission a) (tax l) (insurancegroup 6) (range t))
(vehicles (seats 5) (vehiclegenre SUPERMINI) (manufacturer Vaxhall) (vehiclename Corsa)
(transmission a) (tax l) (insurancegroup 6) (range t))
)
(defrule seats
=>
(printout
t crlf
"--------------------------------------------------" crlf
"Welcome to the UHI Automobile Suitability Selector" crlf
"--------------------------------------------------" crlf
crlf
"Please input available selections ONLY."
t crlf
t crlf
t crlf
"Please input the number of seats required?" crlf
"Select one of the following numerals (1, 2, 3, 4, 5, 6)" crlf
)
(assert (seats (seats-is (read))))
)
(defrule transmission
=>
(printout
t crlf
t crlf
"Please input a transmission type"
t crlf
"(m)anual" crlf
"(a)utomatic" crlf
t crlf
"Input ONE of the following letters (m, a)" crlf
)
(assert (transmission (transmission-is (read))))
)
(defrule tax
=>
(printout
t crlf
t crlf
"Please input tax band acceptability!"
t crlf
"(h)igh band" crlf
"(l)ow band" crlf
t crlf
"Input ONE of the following letters (h, l)" crlf
)
(assert (tax (tax-is (read))))
)
(defrule insurancegroup
=>
(printout
t crlf
t crlf
"Please input target insurance group!(1 expersive 7 cheap)"
t crlf
"Select one of the following numerals (1, 2, 3, 4, 5, 6, 7)" crlf
)
(assert (insurancegroup (insurancegroup-is (read))))
)
(defrule range
=>
(printout
t crlf
t crlf
"Please input your model range preferences"
t crlf
"(e)ntry level" crlf
"(m)id range" crlf
"(t)op range" crlf
t crlf
"Input ONE of the following letters (e, m, t)" crlf
)
(assert (range (range-is (read))))
)
(defrule mainmethod
(seats)
(transmission)
(tax)
(insurancegroup)
(range)
(results)
=>
)
(defrule showselections
(seats (seats-is ?seats-is))
(transmission (transmission-is ?transmission-is))
(tax (tax-is ?tax-is))
(insurancegroup (insurancegroup-is ?insurancegroup-is))
(range (range-is ?range-is))
=>
(printout
t crlf
t crlf "You made the following selections."
t crlf
"Seats : "?seats-is crlf
"Transmission: "?transmission-is crlf
"Taxation Lvl: "?tax-is crlf
"Insur Group : "?insurancegroup-is crlf
"Range : "?range-is
t crlf
)
)
(defrule results
??????????? Help Pls need to print out the filtered results from the inputs)
(defrule results
(seats (seats-is ?seats-is))
(transmission (transmission-is ?transmission-is))
(tax (tax-is ?tax-is))
(insurancegroup (insurancegroup-is ?insurancegroup-is))
(range (range-is ?range-is))
(vehicles (vehiclename $?name)
(seats ?seats-is)
(transmission ?transmission-is)
(tax ?tax-is)
(insurancegroup ?insurancegroup-is)
(range ?range-is))
=>
(printout t "Vehicle name is " (implode$ ?name) crlf))