Woldgang, Thanks a Lot for help me.
Of course that your jess code will be very good sample for me. Jonatas Falcão. On Mon, 8 Dec 2008 19:43:37 +0100, Wolfgang Laun wrote > ; > ; Parking positions may be classified by a minimum or maximum length > ; and by minumum and maximum passenger capacity of the plane. Probably > ; the best solution is to maintaint a slot for the upper and another one > ; for the lower limit. Register flight allocation in slot "flight". > ; > (deftemplate ParkingPosition > (slot posId) > (slot national) > (slot minLength)(slot maxLength) > (slot minPass)(slot maxPass) > (slot flight)) > > , > ; Flight. > ; Register parking position allocation in slot "position". > ; > (deftemplate Flight > (slot number) > (slot length) > (slot pass) > (slot position)) > > ; Implements an answer to one of the questions, although I'm not > ; an expert: Typically, flight numbers in the range from 1000 to 4999 > ; are for national flights. > ; > (deffunction isNational (?number) > (return (and (>= ?number 1000) (<= ?number 4999))) > ) > > ; > ; The Rule > ; Make sure we're in the correct bracked for passenger capacity and > ; plane length, and naional/international distinction. > ; > (defrule matchPos > ?flight <- (Flight (number ?number)(pass ?pass)(length ?length)(position > nil)) > ?pos <- (ParkingPosition (posId ?posId) > (minPass ?minPass &:(< ?minPass ?pass)) > (maxPass ?maxPass &:(>= ?maxPass ?pass)) > (minLength ?minLength &:(< ?minLength > ?length)) > (maxLength ?maxLength &:(>= ?maxLength > ?length)) > (national ?national &:(= ?national > (isNational ?number))) > (flight nil)) > => > (modify ?pos (flight ?number)) > (modify ?flight (position ?posId)) > (printout t "flight " ?number " at " ?posId crlf) > ) > > (deffacts fs > (ParkingPosition (posId A)(national TRUE) (minLength 55)(maxLength > 999)(minPass 0)(maxPass 9999)) > (ParkingPosition (posId B)(national TRUE) (minLength 0)(maxLength > 55)(minPass 40)(maxPass 9999)) > (ParkingPosition (posId C)(national FALSE)(minLength 0)(maxLength > 50)(minPass 0)(maxPass 9999)) > (ParkingPosition (posId D)(national TRUE) (minLength 0)(maxLength > 55)(minPass 40)(maxPass 9999)) > > (Flight (number 909)(pass 140)(length 48)) > (Flight (number 1010)(pass 150)(length 63)) > (Flight (number 2020)(pass 198)(length 55)) > (Flight (number 3030)(pass 60)(length 55)) > ) > > (reset) > (run) > > The output is: > flight 3030 at D > flight 2020 at B > flight 1010 at A > flight 909 at C > > I'd like to point out that this is far from perfect. > Parking position classes and plane charateristics may overlap in such > a way that one plane may be accomodated in several positions with > different parameters. The rule matchPos might fit a plane into the > only slot fit for another flight. If there are other parking positions > for the first plane, it may be possible to find a solution for all flights. > > Wolfgang > > On Mon, Dec 8, 2008 at 4:57 PM, Jônatas Falcao <[EMAIL PROTECTED]> wrote: > > Hi Friends, > > I have a problem to solve in Jess, but I don´t know how solve this. > > I am creating a prototype for input airplane in airport parking slots: > > The example is: > 1 - I have 4 airplanes, where 3 airplanes are on National flights, and 1 > Internacional: > > 1o. airplane: International Flight , 140 passengers, size of > Airplane 48 ; -> (fact) > 2o. airplane: National Flight , 150 passengers; size of Airplane 63 > -> (fact) > 3o. airplane: National Flight , 198 passengers; size of Airplane 55 > -> (fact) > 4o. airplane: National Flight , 60 passengers; size of Airplane 55 > -> (fact) > > 2 - Suppose that I have 4 slot parking (positions) in my fictitious > airport: > > - position "A" - for National flights only and alocate airplanes > >55mts ; > - position "B" - for National flights only and alocate airplanes > 40 > and <= 55mts ; > - position "C" - for International flights only and alocate airplanes > <= 50mts ; > - position "D" - for National flights only and alocate airplanes > 40 > and <= 55mts ; > > 3 - The order to put airplane in each position is: > > ** QUANTITY PASSENGERS + AIRPLANE SIZE + TYPE OF FLIGHT (Int./Nat.) > ** > > > 4 - The Question is: How I make rules in Jess to use the order above ??. > I created a rule to sort by passengers, but I don´t know how to use rules > with airplane size and type of flight together ? > > - How is possible create a rule to verify if flight is International or not > from flightNumber, and > alocate in correct position ? > > > > The correct answers for this problem probably are: > > "3o. Airplane with 198 pax, alocate in position B" > "2o. Airplane with 150 pax, alocate in position A" > "1o. Airplane with 148 pax, alocate in position D" > "4o. Airplane with 198 60, alocate in position C" > > BUT I DON´T HAVE KNOW HOW CREATE THE RULES FOR THIS ANSWERS, IS POSSIBLE TO > HELP ME ? > > ********* Follows the my initial Jess code: ************ > > (deftemplate FlightsProgramming "Information Flights" > (slot FlightNumber (default Whatever) ) > (slot QtyPassenger (default 0) ) > (slot Size (default 0) ) > (slot Selected (default false) ) > ) > > (defrule verify-pax > ?SelectAirplane <- (FlightsProgramming (FlightNumber ?ItemFlightNumber) > (QtyPassenger ?ItemQtyPassenger) > (Size ?ItemSize) > (Selected false ) ) > (not (FlightsProgramming (Selected false) (QtyPassenger ?p&:(> ?p > ?ItemQtyPassenger)))) > => > (printout t "Slot Parking Priority: " ?ItemFlightNumber ", > QtyPassenger:" ?ItemQtyPassenger ", Size: " ?ItemSize crlf) > (modify ?SelectAirplane (Selected true) ) > ) > > ;******* Defining Facts *********** > (assert > (FlightsProgramming > (FlightNumber "I0001") > (QtyPassenger 140) > (Size 48) > ) > ) > (assert > (FlightsProgramming > (FlightNumber "N1234") > (QtyPassenger 150) > (Size 63) > ) > ) > (assert > (FlightsProgramming > (FlightNumber "N4529") > (QtyPassenger 198) > (Size 55) > ) > ) > (assert > (FlightsProgramming > (FlightNumber "N44676") > (QtyPassenger 60) > (Size 55) > ) > ) > > (run) > > Thanks for advance and sorry by my bad english, > > Jonatas Falcao > MsC. Student > ITA - Instituto Tecnologico de Aeronautica > (Aeronautical Technological Institute) > CTA - Comando Geral de Tecnologia Aerospacial > (General Command of Aerospace Technology) > > São Jose dos Campos - Brazil > > > > ----------------------------------------------------------------------- Get news, entertainment and everything you care about at Live.com. Check it out! Jônatas Falcão ITA - Instituto Tecnologico de Aeronautica CTA - Comando Geral de Tecnologia Aerospacial SJC - Campo Montenegro Sao Paulo - Brasil
