Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search 在剪辑中查找具有条件的最低值_Search_Compare_Conditional Statements_Clips - Fatal编程技术网

Search 在剪辑中查找具有条件的最低值

Search 在剪辑中查找具有条件的最低值,search,compare,conditional-statements,clips,Search,Compare,Conditional Statements,Clips,我正在制作一个剪辑程序,其中我有: 酒店事实(酒店名称城市之星) 国家事实,其中显示属于某个国家的所有城市:(pais countryname city1 city2….) 价格事实:(precio hotelname可获得的房间价格种类OMS) 问题是,我需要根据一些特征找到最便宜的酒店,例如,假设我有以下初步事实: (deffacts condiciones-iniciales (hotel RiuTaino PuntaCana 5 ) (hotel RiuFelicidad PuntaCa

我正在制作一个剪辑程序,其中我有:

酒店事实(酒店名称城市之星)

国家事实,其中显示属于某个国家的所有城市:(pais countryname city1 city2….)

价格事实:(precio hotelname可获得的房间价格种类OMS)

问题是,我需要根据一些特征找到最便宜的酒店,例如,假设我有以下初步事实:

(deffacts condiciones-iniciales
(hotel RiuTaino PuntaCana 5 )
(hotel RiuFelicidad PuntaCana 4)
(hotel RiuMaracana PuntaCana 4 )
(hotel RiuMaracana2 Baradero 4 )
(hotel RiuRon Baradero 4 )
(hotel RiuMaya RivieraMaya 4 )
(hotel RiuMojito RivieraMaya 4 )
(hotel RiuTequila RivieraMaya 5 )
(hotel RiuSalvaje ElCarmen 4 )
(hotel RiuMontana ElCarmen 4 )
(hotel RiuSantuario ElCarmen 5 )
(pais Rep_Dominicana PuntaCana Baradero SantoDomingo )
(pais Mejico ELCarmen RivieraMaya Cancun)
(precio RiuTaino suite 500 3)
(precio RiuTaino standar 200 20)
(precio RiuFelicidad suite 400 2)
(precio RiuFelicidad standar 100 0)
(precio RiuMaracana suite 600 0)
(precio RiuMaracana standar 300 22)
(precio RiuMaracana2 suite 650 1)
(precio RiuMaracana2 standar 350 2)
(precio RiuRon suite 900 6)
(precio RiuRon standar 700 18)
(precio RiuMaya suite 900 16)
(precio RiuMaya standar 700 88)
(precio RiuMojito suite 550 7)
(precio RiuMojito standar 170 0)
(precio RiuTequila suite 400 3)
(precio RiuTequila standar 350 2)
)
例如,我想找一家在多米尼加共和国(任何城市)最便宜的四星级酒店,有标准间和空余房间。为了找到符合这些特征的酒店,我做了以下工作:

(defrule busca-hoteles
(hotel ?hotel ?ciudad ?estrellas)
(pais Rep_Dominicana $? ?ciudad $?)
(test (= ?estrellas 4))
(precio ?hotel standar ? ?habitaciones)
(test (> ?habitaciones 0))
=>
(printout t ?hotel crlf)
)

但是,我该怎么做才能在满足这些要求的产品中找到最便宜的呢?我完全迷路了。提前感谢您的帮助:)

以下是如何修改规则以找到最便宜的房间:

(defrule busca-hoteles

   ;; The city is in the dominica republic

   (pais Rep_Dominicana $? ?ciudad $?)

   ;; The hotel is in the city and 4 stars

   (hotel ?hotel ?ciudad 4)

   ;; There are available standard rooms in the hotel

   (precio ?hotel standar ?price ?habitaciones)
   (test (> ?habitaciones 0))

   ;; There are no other 4 star hotel in the same
   ;; city with available standard rooms and a
   ;; lower price

   (not (and (hotel ?hotel2 ?ciudad 4)
             (precio ?hotel2 standar ?price2 ?habitaciones2)
             (test (> ?habitaciones2 0))
             (test (< ?price2 ?price))))

   =>

   (printout t "Cheapest 4 star hotel in " ?ciudad " is " 
               ?hotel " at " ?price crlf))
(defrule busca hoteles酒店
这座城市位于多米尼加共和国
(pais代表多米尼加$ciudad$)
这家旅馆在城里,是四星级的
(城市4号酒店)
这家旅馆有标准间
(precio?standar?price?habitaciones酒店)
(测试(>0)
同一地区没有其他四星级酒店
;城市,有可用的标准客房和
更低的价格
(非(和(酒店?酒店2?城市4)
(precio?hotel2标准?价格2?居住区2)
(测试(>?居住区2 0))
(测试(<?价格2?价格)))
=>
(打印出的“世界上最便宜的四星级酒店”?ciudad“是”
酒店“在”?价格(crlf))