暖通空调控制系统规则编写与模糊逻辑应用
1. 系统组件创建
在开始控制暖通空调系统之前,需要创建相关的组件实例,包括通风口(Vent)、热泵(HeatPump)和温度计(Thermometer)。以下是创建这些组件实例的代码:
(defclass Vent control.Vent)
(defclass HeatPump control.HeatPump)
;; Create the Vent and Thermometer Beans
(bind ?n (n-floors))
(while (> ?n 0) do
(definstance Thermometer
(new control.Thermometer ?*hw* ?n))
(definstance Vent (new control.Vent ?*hw* ?n))
(bind ?n (- ?n 1)))
;; Create the HeatPump Beans
(bind ?n (n-heatpumps))
(while (> ?n 0) do
(definstance HeatPump (new control.HeatPump ?*hw* ?n))
(bind ?n (- ?n 1)))
创建完成后,可以使用批处理命令执行上述代码,然后使用 facts
命令检查所有的影子事实是否存在。若重复检查,会发现温度数据随时间变化,且与模拟器图形用户界面(GUI)中的读数保持同步。若使用Jess - Win IDE,还能实时观察事实的变化。