A Multi-Agent System-Based Approach for Optimal Operation of Building Microgrids with Rooftop Greenhouse

In this paper, an optimal energy management scheme for building microgrids with rooftop greenhouse is proposed. A building energy management system (BEMS) is utilized for the optimal fulfilment of energy demands in the building and the greenhouse. The exhaust heat generated due to the operation of air conditioners in the building is used for fulfilling the cooling demands of the greenhouse via chillers. In addition to thermal and cooling demands, the four major control parameters (temperature, humidity, light intensity, and CO2 concentration) are also considered for optimal growth of crops in the greenhouse. A multi-agent system (MAS) is adopted to realize the interaction among several households of the building, the greenhouse, and the BEMS. The MAS comprises of several inner-level, intermediate level, and upper-level agents, which are responsible for their respective tasks. The performance of the proposed optimization strategy is evaluated for two seasons of a year, i.e., summer and winter. Numerical simulations have demonstrated the effectiveness of the proposed operation scheme for optimal operation of building microgrids with rooftop greenhouses.


Introduction
The increase in energy demand and greenhouse gas emissions are becoming global issues, and various studies have been conducted to overcome these problems [1,2].Microgrids are considered a potential solution to these problems due to their ability to sustain the penetration of distributed energy resources, especially renewable energy sources [3][4][5][6].In [3], the authors have analyzed the benefits of microgrids, i.e., reliability improvement, sustaining the penetration of renewable sources, self-healing, active load control, and improved generation efficiencies.In [4], the impact of intelligent demand management to limit the periods of strain on network and electricity markets is analyzed.In [5,6], the role of microgrids in providing higher local reliability during islanding events in comparison with conventional power system is analyzed.
In addition, several studies on microgrids about demand response (DR), auto-configuration, fault analysis, and control are also available in the literature.Optimal operation of microgrids considering DR and auto-configuration function are studied based on multi-agent system (MAS) in [7,8], respectively.In [9], unsymmetrical faults of microgrids are studied based on definite two relationship matrices.In [10], a versatile convex programming for DR optimization via automatic load management is proposed.In [11], stand-alone hybrid microgrids using general regression neural Energies 2018, 11, 1876 2 of 24 network and radial basis function network-sliding mode methods are studied for extracting the maximum power output for a hybrid power system.An algorithm is developed in [12] for solving the distribution ground faults of microgrids considering the three phase models.In [13], smart houses having photovoltaic arrays, wind turbine, biomass and geothermal energy are reviewed for optimal operation strategies of households.In [14], an energy consumption model of home appliances in a residential microgrid based on set of sequential uninterruptible energy phases is proposed.During transition from grid-connected to islanded mode, a multi-droop control strategy has been developed to mitigate voltage and frequency variations by [15].A study of a microgrid using a novel voltage controller using the integration of a vanadium redox battery with solar energy is carried out by [16].In [17], a novel intelligent damping controller to damp power system oscillations is proposed to improve both transient stability and system oscillations.
There are many types of microgrids and building microgrids have attracted the interest of researchers due to higher consumption of energy [18].Building microgrids are operated by building energy management systems (BEMSs) [19][20][21][22].Energy cost was reduced through peak load shaving and load shifting after installing smart systems at buildings by [19].Based on a linear scheduling model, a schedule for half hourly electricity prices from utility grid and peak demand costs is developed by [20].In [21], an optimal scheduling for building microgrids considering economic constraints based on temperature dependent thermal load modeling was carried out.The power scheduling and bidding strategy for building microgrids is formulated as a stochastic program by [22] via Monte Carlo simulations.
Meanwhile, the development of the agriculture sector is at its beginning stages and various researches are carried out in [23][24][25].In [23], the authors have proposed a sophisticated information and communication technology (ICT) infrastructure for gathering, storing, analyzing, and exploiting various information in planning and decision making for future farms.In [24,25] a cloud-based platform is studied for combining agriculture technology with ICT.Intelligent greenhouses are considered an advanced form of conventional greenhouse [26].Intelligent greenhouses are composed of various sensors and automated management facilities for maintaining the indoor environment.In order to optimize the growth of the crops in greenhouses, four control parameters (i.e., temperature, humidity, CO 2 concentration, and light intensity) must be controlled.Various studies are available in the literature for controlling the internal environment of greenhouses [27][28][29][30].In [27], study of two fuzzy logic controllers that are comprised of fuzzy proportional and proportional-derivative control using desired climatic set points is carried out.A general framework for a robust adaptive neural network-based feedback linearization controller design for the indoor environment of a greenhouse is studied by [28].In [29], the use of "double thermal screen" and "double glazing" for assessing energy management of greenhouses are analyzed.The concept of energy management for a closed greenhouse integrated with a thermal energy storage system (TESS) is presented by [30].
Intelligent greenhouses can be integrated into buildings to receive benefit from the advancements in intelligent greenhouses and BEMS technologies, i.e., rooftop greenhouses.A rooftop greenhouse has the potential to create a new agricultural space in the cities using the rooftop, which is otherwise an unproductive space.In addition, by integrating food production into buildings, the self-sufficiency of cities can be increased and transportation requirements and environmental impacts can be reduced [31][32][33][34].Therefore recently, various research has been performed on the applicability of rooftop greenhouses [35][36][37][38][39][40].
In [35], a residential building with rooftop greenhouse is analyzed for quantifying the environmental impacts and energy requirements.The techno-economic and environmental impacts of integrating rooftop greenhouses in buildings are analyzed by [36][37][38][39].In [36], the effect on the indoor temperature of the last floor apartments is analyzed by installing greenhouse on the rooftop.The analysis of rooftop greenhouse for controlling energy and emissions flow is carried out via the integration of energy, water, and CO 2 flows.The mutual exchange between greenhouse and building is proposed to reduce the consumption of energy by [37].The reduction of the carbon Energies 2018, 11, 1876 3 of 24 footprint of horticultural products produced in urban rooftop greenhouses is observed in these studies.The suitability of the hot air accumulated in the rooftop greenhouse for recirculation to heat the building is evaluated by [38].In [39], the feasibility of implementation of rooftop greenhouses in non-residential urban areas is analyzed.However, most of the research mentioned in the previous paragraphs are conducted in terms of agricultural engineering and the feasibility of a rooftop greenhouse is not analyzed.Studies on the optimal energy management of buildings with rooftop greenhouses are limited and are more challenging due to the mutual coupling of energies.The concept of a smart rooftop greenhouse, which considers automation and energy efficiency by combining smart grids, is the advanced form of a rooftop greenhouse [40].
In smart rooftop greenhouses, a communication infrastructure is required to interact between the building and the greenhouse.All the components of the greenhouse need to interact with the BEMS to update their status and to receive commands.Similarly, buildings generally have several households.All the households send their information to BEMS and BEMS makes optimal schedules based on the provided information.Due to the widespread use of MAS for optimization of BEMS [41][42][43][44], a MAS can be utilized to realize the communication between BEMS and individual households.In [41], a MAS for microgrids is developed considering the function of agents, interactions among agents, and an effective agent protocol.Utilizing a semi-centralized decision method using MASs for various energy zones (electrical, heating, and cooling) to improve energy efficiency and reduce energy costs is studied by [42].In [43,44], MASs are developed for the optimal operation of buildings considering the indoor environment and occupants' comfort.
It can be observed from the literature survey that various studies are available on the internal environment control of greenhouses and rooftop greenhouses.However, most of the research is mainly focused on internal climate control only without considering the energy costs [27][28][29][30].This may result in a higher operation cost due to the in-optimal utilization of resources.Similarly, studies on the integrated optimal operation of building and rooftop greenhouses are also limited.The integrated optimal operation is challenging due to the coupling of energy sources and the interdependence of loads.
In this paper, an optimal operation strategy is proposed for a smart building with a rooftop greenhouse.The households of the building and the greenhouse have both thermal (heating and cooling) and electrical loads.However, the greenhouse has additional constraints for maintaining the indoor environment by controlling the control parameters.Moreover, the waste heat generated by air-conditioners is utilized to fulfil the heat requirements of the greenhouse.A MAS is developed to realize the interaction among different agents of the building microgrid.Each household in the building has several local agents and an intermediate agent.Similarly, the greenhouse also has several local agents and an intermediate agent.The intermediate agents of each household and the greenhouse are responsible for interacting with the BEMS.The performance of the proposed optimal operation strategy for building microgrid with rooftop greenhouse is tested for two seasons of a year, i.e., winter and summer.The operation schedules of the microgrid equipment and attainment of the control parameters are analyzed for both of the seasons.

Building Microgrids Configuration
The proposed building microgrid in this study is comprised of a building having n houses and a rooftop greenhouse, i.e., building microgrid with rooftop greenhouse.The configuration of the proposed building microgrid is shown in Figure 1.The building microgrid contains a combined heat and power (CHP) generator, heat only boiler (HOB), chiller, electric heat pump (EHP), photovoltaic (PV) array, TESS, and battery energy storage system (BESS).The equipment specific to the greenhouse is listed in the next section.The building microgrid is connected with the utility grid, thus it can trade power with the utility grid.The cooling demand of houses in the building is fulfilled using the air Energies 2018, 11, 1876 4 of 24 conditioner units installed in each house.The exhaust heat generated due to the operation of these air conditioners is collected and is used to fulfil the cooling demand of the greenhouse using a chiller.Excess exhaust heat is stored in the TESS unit, as shown in Figure 1.Similarly, the heating demand of the greenhouse is fulfilled using the available heating sources, i.e., CHP, TESS, HOB, and EHP.Finally, the electric demand can be fulfilled either by using the local resources or by trading with the utility grid.
CHP, TESS, HOB, and EHP.Finally, the electric demand can be fulfilled either by using the local resources or by trading with the utility grid.
In this study, a building microgrid is considered, which contains n households and a greenhouse on the rooftop of the building.Each household has separate air-conditioner to fulfil its cooling load demands.The heating demands can be fulfilled by using the heat generating equipment of the microgrid via a heat pipe line.Both air conditioner and heat pipe line are used to control the indoor temperature of each household of the microgrid according to its requirements.The residents of each household can specify their departure and arrival times along with their required temperature at arrival time.The BEMS will find an optimal solution to achieve the set target for the specified time in an economic way.Similarly, the users can specify their comfortable range for sleeping time, which will be economically fulfilled by the BEMS.The electric demand can be fulfilled by either using the local power generation or by buying power from the utility grid.

Greenhouse Configuration and Control Elements
In an intelligent greenhouse, the climate control parameters are automatically controlled to provide optimum conditions for the growth of plants [45].Climate control is achieved by the automatic control of greenhouse equipment such as ventilation system, automation valves for heating and cooling pipes, fogging system, dehumidifier, artificial light, air circulation fans, and CO2 injection.Climate control system for greenhouse collects the information from the local sensors and sends suitable control signals to the equipment for their operation.The modeling of the proposed greenhouse for the optimal growth of crops is shown in Figure 2.Each plant has different requirements of control parameters (temperature, humidity, carbon dioxide, and lighting) for its optimal growth [46].The importance of the four major control factors for optimal growth of plants is described in the following sections.In this study, a building microgrid is considered, which contains n households and a greenhouse on the rooftop of the building.Each household has separate air-conditioner to fulfil its cooling load demands.The heating demands can be fulfilled by using the heat generating equipment of the microgrid via a heat pipe line.Both air conditioner and heat pipe line are used to control the indoor temperature of each household of the microgrid according to its requirements.The residents of each household can specify their departure and arrival times along with their required temperature at arrival time.The BEMS will find an optimal solution to achieve the set target for the specified time in an economic way.Similarly, the users can specify their comfortable range for sleeping time, which will be economically fulfilled by the BEMS.The electric demand can be fulfilled by either using the local power generation or by buying power from the utility grid.

Greenhouse Configuration and Control Elements
In an intelligent greenhouse, the climate control parameters are automatically controlled to provide optimum conditions for the growth of plants [45].Climate control is achieved by the automatic control of greenhouse equipment such as ventilation system, automation valves for heating and cooling pipes, fogging system, dehumidifier, artificial light, air circulation fans, and CO 2 injection.Climate control system for greenhouse collects the information from the local sensors and sends suitable control signals to the equipment for their operation.The modeling of the proposed greenhouse for the optimal growth of crops is shown in Figure 2.Each plant has different requirements of control parameters (temperature, humidity, carbon dioxide, and lighting) for its optimal growth [46].The importance of the four major control factors for optimal growth of plants is described in the following sections.
injection.Climate control system for greenhouse collects the information from the local sensors and sends suitable control signals to the equipment for their operation.The modeling of the proposed greenhouse for the optimal growth of crops is shown in Figure 2.Each plant has different requirements of control parameters (temperature, humidity, carbon dioxide, and lighting) for its optimal growth [46].The importance of the four major control factors for optimal growth of plants is described in the following sections.

Indoor Temperature
Indoor temperature is an important factor for crop growth due to its influence on photosynthesis process and respiration [47].Photosynthesis, being a biochemical reaction, increases with increase in temperature.Similarly, the respiration rate of plants increases with increase in the temperature [48].However, if temperature is too high or too low, growth of crop is inhibited due to the unsuitable respiration rate and the hindrance of cell activity [49].Therefore, the indoor temperature of the greenhouse should be controlled within an appropriate range by using the greenhouse equipment.

Humidity
Humidity is the most difficult parameter to control due to its fluctuation with change in air temperature and the transpiration of plants.Inappropriate levels of humidity can adversely affect the plants and cause diseases in the leaves and roots.Additionally, higher humidity halts the transpiration process of plants and lower humidity effects the growth rate.Therefore, humidity should be controlled within an appropriate range by using the greenhouse equipment [50,51].

CO 2 Concentration
Carbon dioxide concentration directly influences the photosynthesis process in crops.The CO 2 compensation point is the point at which the photosynthetic rate and the respiration rate are equal.Therefore, CO 2 concentration should be higher than the CO 2 compensation point for efficient photosynthesis of the plant.The CO 2 saturation point is the point at which the photosynthetic rate does not increase even if the carbon dioxide concentration is increased.Therefore, CO 2 concentration should be controlled between the CO 2 compensation point and the CO 2 saturation point [50,51].

Light Intensity
Light intensity is also an important factor for the optimal growth of crops due to its effect on photosynthesis.If the amount of light is insufficient, the crop growth gets diminished due to the deterioration of photosynthesis.Therefore, light intensity should be maintained above a certain limit.

Proposed Multi-Agent System
The proposed optimization algorithm is implemented through a MAS in the building microgrid with rooftop greenhouse.Both the building and the greenhouse have separate task-specific agents and also share some common agents.Details about each of these agents and their respective tasks are explained in the following sections.

Outer-Level Multi-Agent System
The outer-level MAS consists of the BEMS agent, energy supply facilities, and intermediate agents such as household agents (HAs), and a greenhouse agent (GHA), as shown in Figure 3.The BEMS agent is responsible for the operation of the entire building microgrid with rooftop greenhouse.It receives information from the intermediate agents and makes schedules for the optimal operation of the entire building microgrid.The final schedules are sent to the outer-level agents of the households and the greenhouse.These outer-level agents get information from their respective inner-level agents and inform the schedules received from the BEMS agent to them.The details of inner-level agents along with their respective tasks are explained in the following section.

Greenhouse Agents
The greenhouse contains active, reactive, and passive agents that are responsible for various tasks.The sensors, such as a CO2 concentration sensor (CCS), temperature and humidity sensor (THS), and light intensity sensor (LI), are passive agents.These agents periodically send the measured values to the GHA.The agents specific to the equipment of the greenhouse are reactive agents.These agents include a forced ventilation agent (FVA), artificial light agent (ALA), air circulation fans agent (ACFA), natural ventilation motor agent (NVMA), CO2 injection agent (CIA), dehumidifier agent (DA), fogging system agent (FSA), heating pipe agent (HPA), and cooling pipe agent (CPA) as shown in Figure 4.These agents follow the commands of the GHA and they are reactive agents.The GHA is an active agent, which monitors the status of reactive agents and uses the information of passive agents to make decisions.These decisions are informed to the BEMS agent for updating and/or rescheduling the resources.

Greenhouse Agents
The greenhouse contains active, reactive, and passive agents that are responsible for various tasks.The sensors, such as a CO 2 concentration sensor (CCS), temperature and humidity sensor (THS), and light intensity sensor (LI), are passive agents.These agents periodically send the measured values to the GHA.The agents specific to the equipment of the greenhouse are reactive agents.These agents include a forced ventilation agent (FVA), artificial light agent (ALA), air circulation fans agent (ACFA), natural ventilation motor agent (NVMA), CO 2 injection agent (CIA), dehumidifier agent (DA), fogging system agent (FSA), heating pipe agent (HPA), and cooling pipe agent (CPA) as shown in Figure 4.These agents follow the commands of the GHA and they are reactive agents.The GHA is an active agent, which monitors the status of reactive agents and uses the information of passive agents to make decisions.These decisions are informed to the BEMS agent for updating and/or re-scheduling the resources.

Individual Household Agents
Each household in the building has a set of local agents as shown in Figure 5. Similar to the greenhouse, the agents in an individual household can be categorized as active, passive, and reactive agents.The sensors agents (SA) in each household, which are responsible for sending their measured data periodically to their respective HA are the passive agents.The equipment-specific agents (i.e., air-conditioner agent (ACA), HPA, and electric load agent (ELA)) are reactive agents.The HA in each household is an active agent that uses the information of its inner-level agents to make decisions and communicates with the BEMS agents.Residents of each household can specify their desired temperature setting values and their arrival and departure times to their respective HA.The HA will communicate this information with the BEMS agent and get optimal schedules for the equipment to fulfil the user demands.

Greenhouse Agents
The greenhouse contains active, reactive, and passive agents that are responsible for various tasks.The sensors, such as a CO2 concentration sensor (CCS), temperature and humidity sensor (THS), and light intensity sensor (LI), are passive agents.These agents periodically send the measured values to the GHA.The agents specific to the equipment of the greenhouse are reactive agents.These agents include a forced ventilation agent (FVA), artificial light agent (ALA), air circulation fans agent (ACFA), natural ventilation motor agent (NVMA), CO2 injection agent (CIA), dehumidifier agent (DA), fogging system agent (FSA), heating pipe agent (HPA), and cooling pipe agent (CPA) as shown in Figure 4.These agents follow the commands of the GHA and they are reactive agents.The GHA is an active agent, which monitors the status of reactive agents and uses the information of passive agents to make decisions.These decisions are informed to the BEMS agent for updating and/or rescheduling the resources.

Individual Household Agents
Each household in the building has a set of local agents as shown in Figure 5. Similar to the greenhouse, the agents in an individual household can be categorized as active, passive, and reactive agents.The sensors agents (SA) in each household, which are responsible for sending their measured data periodically to their respective HA are the passive agents.The equipment-specific agents (i.e., air-conditioner agent (ACA), HPA, and electric load agent (ELA)) are reactive agents.The HA in each household is an active agent that uses the information of its inner-level agents to make decisions and communicates with the BEMS agents.Residents of each household can specify their desired temperature setting values and their arrival and departure times to their respective HA.The HA will communicate this information with the BEMS agent and get optimal schedules for the equipment to fulfil the user demands.

Communication among Different Agents
In this study, communication among the agents is realized through agent communication language (ACL) messages by using modified contract net protocol (MCNP) [52].The communication between different agents in the proposed scheme is shown in Figure 6.Firstly, the BEMS agent sends message to the utility grid agent for inquiring the market price signals.The utility grid agent sends the day-ahead market price for each hour of the day to the BEMS agent.Then, the BEMS sends the market price information to the registered outer-level agents along with call for proposal (cfp) messages.The outer-level agents having inner-level agents (GHA and HAs) send cfp messages to their respective registered inner-level agents.After receiving the required information such as generation cost, capacity, and operation status from inner-level agents, outer level agents decide their participation in the operation.The outer-level agents send the collective information to the BEMS agent or send a refusal message.Similarly, each individual inner-level agent can send its refusal messages, if it is not willing to participate in the operation process.After receiving the information from all agents, the BEMS performs the optimization and sends the acceptance or rejection messages about proposals to each agent.In case of acceptance, outer level agents send the schedules received from the BEMS to the registered inner-level agents.In this way, one round of optimization is completed for the proposed building microgrid with rooftop greenhouse.The detailed process for communication among different outer-level agents and the BEMS is shown in Algorithm 1.

Communication among Different Agents
In this study, communication among the agents is realized through agent communication language (ACL) messages by using modified contract net protocol (MCNP) [52].The communication between different agents in the proposed scheme is shown in Figure 6.Firstly, the BEMS agent sends message to the utility grid agent for inquiring the market price signals.The utility grid agent sends the day-ahead market price for each hour of the day to the BEMS agent.Then, the BEMS sends the market price information to the registered outer-level agents along with call for proposal (cfp) messages.The outer-level agents having inner-level agents (GHA and HAs) send cfp messages to their respective registered inner-level agents.After receiving the required information such as generation cost, capacity, and operation status from inner-level agents, outer level agents decide their participation in the operation.The outer-level agents send the collective information to the BEMS agent or send a refusal message.Similarly, each individual inner-level agent can send its refusal messages, if it is not willing to participate in the operation process.After receiving the information from all agents, the BEMS performs the optimization and sends the acceptance or rejection messages about proposals to each agent.In case of acceptance, outer level agents send the schedules received from the BEMS to the registered inner-level agents.In this way, one round of optimization is completed for the proposed building microgrid with rooftop greenhouse.The detailed process for communication among different outer-level agents and the BEMS is shown in Algorithm 1. Algorithm 2 shows the detailed process for communication among outer-level agents and their respective registered inner-level agents.

Flowchart for Building Microgrid with Rooftop Greenhouse Using Multi-Agent System
The flowchart for building a microgrid with rooftop greenhouse using a MAS is shown in Figure 7.The BEMS agent receives the information, such as buying and selling price signals from the utility grid, external environment parameters, and load profiles.BEMS communicates with other agents for getting their information following Algorithms 1 and 2. After receiving all information, BEMS performs optimization and informs the optimal schedules to other agents.The output of each energy supply equipment is decided for minimizing the operation cost of the microgrid network.The amount of trading power with the utility grid is decided to maximize the profit of the microgrid.

Flowchart for Building Microgrid with Rooftop Greenhouse Using Multi-Agent System
The flowchart for building a microgrid with rooftop greenhouse using a MAS is shown in Figure 7.The BEMS agent receives the information, such as buying and selling price signals from the utility grid, external environment parameters, and load profiles.BEMS communicates with other agents for getting their information following Algorithms 1 and 2. After receiving all information, BEMS performs optimization and informs the optimal schedules to other agents.The output of each energy supply equipment is decided for minimizing the operation cost of the microgrid network.The amount of trading power with the utility grid is decided to maximize the profit of the microgrid.

Flowchart for Building Microgrid with Rooftop Greenhouse Using Multi-Agent System
The flowchart for building a microgrid with rooftop greenhouse using a MAS is shown in Figure 7.The BEMS agent receives the information, such as buying and selling price signals from the utility grid, external environment parameters, and load profiles.BEMS communicates with other agents for getting their information following Algorithms 1 and 2. After receiving all information, BEMS performs optimization and informs the optimal schedules to other agents.The output of each energy supply equipment is decided for minimizing the operation cost of the microgrid network.The amount of trading power with the utility grid is decided to maximize the profit of the microgrid.

Estimation of Greenhouse and Building Control Parameters
The estimation methods for the four major control parameters of greenhouse, considered in this study, are described in the following sections.

Indoor Temperature of Greenhouse and Building
The indoor temperature of greenhouse can be calculated using Equation (1) [53] ) is on, heat is exchanged between the pipe and the greenhouse according to the heat transfer coefficient of the pipe (η gh_pipe ) and area of the pipe (A gh_htp , A gh_chl p ) in m 2 .Similarly, heat is exchanged between the pipe and the soil according to the heat transfer coefficient of the soil (η gh_soil ) due to the temperature difference between them (θ ).The water temperature of the heating and cooling pipes can be calculated using Equations ( 2) and (3), respectively.For calculating the water temperature of pipe, specific heat of water (SH w ) in kJ/(kg K), water density (ρ w ) in kg/m 3 , and volume of respective pipes (V gh_htp , V gh_chl p ) in m 3 are used.In Equation ( 2), H gh t is the heat load of the greenhouse and C Load t in Equation ( 3) is the cooling load of the greenhouse.
The indoor temperature of each household in the building can be calculated using Equation (4).Temperature of household at time t (θ in t,n ) is a function of household temperature at the previous time interval t − 1 (θ in t−1,n ) and temperature change at the current time interval.Temperature change at the current time interval is a function of the following parameters: j ac t,n : Heat absorbed from solar radiations (kJ/h) j ho_htp t,n : Heat exchanged through heating pipe (kJ/h) j ho_wall t,n : Heat exchanged through wall of each households (kJ/h) In Equation ( 4), V ho n is the volume of each household.
Water temperature of the heating pipe for each household is similar with Equation (2).

Humidity Control for Greenhouse
The relative humidity of the greenhouse (RH gh t ) in % can be computed using partial (p gh_par t ) and saturated vapor pressures (p gh_sat t ) in Pa, as given by Equation ( 5).The saturated vapor can be computed using nonlinear Equation ( 6).This nonlinear equation can be transformed into a linear equation using Taylor series [56].The partial pressure of vapor is a function of the atmospheric pressure (p atm ) and water contents in the air (w gh t ) as shown in Equation (7).
Water contents in the air (g/kg) at time t is a function of the water contents in the air at a previous time interval t − 1 (w gh t−1 ) and a change in water content at the current time interval t.Water content at t is affected by the transpiration of crops (w tran ) in g/hm 2 , natural and forced ventilation, fogging system, and dehumidifier.Natural ventilation is effected by the wind speed (n ws t ) in m/s, wind entering a ratio through the natural ventilation window (η nv ), air density (ρ a ), area of natural ventilation window (A nv ), operation status of natural ventilation (u nv t ), and water contents difference in indoor and outdoor (w out t − w gh t ).Forced ventilation is effected by the ventilation speed of fan ( f ws ), air density, area of greenhouse, operation status of forced ventilation (u f v t ), and water contents difference in indoor and outdoor.The amount of water content produced by the fogging system depends on its efficiency (w f g max /P f g max ) and amount of power consumed (P f g t ).Similarly, the amount of water content absorbed by the dehumidifier depends on its efficiency (w dh max /P dh max ) and amount of power consumed (P dh t ). Energies If the outdoor temperature (θ out t ) and humidity (RH out t ) in % are known, the external water contents (w out t ) in the air can be calculated using Equations ( 9)-( 11), similar to the internal water contents of the air.).The CO 2 change due to respiration is calculated using the respiration coefficient of crops (c res ) in g/m 2 hK, area of greenhouse, and respiration rate of the crops (a 5 , a 6 ).The CO 2 change due to photosynthesis is calculated using photosynthesis coefficient of crops (c phot ) in g/J, total amount of light (I total t ) in W/m 2 , and area of the greenhouse.

Light Control for Greenhouse
Light intensity can be calculated using Equation (13).Where, P sr t is the solar radiations, η sr is the transmittance of solar light, and P li t,i is the light produced by ith artificial light unit.

Objective Function
The objective function aims to minimize the operational costs of the building microgrid.The first term of the objective function (14) shows the generation cost of CHP (C CHP i ).The second and third terms show the buying price (PR Buy t ) and selling price (PR Sell t ) for trading electricity with the utility grid.The fourth and fifth terms show the operation cost of greenhouse chiller (C Chl ) and chiller on the building (C Chl_B ), respectively.The amount of cooling energy can be computed using the amount of heat used and the energy efficiency ratings of chillers.The last term of (14) shows the operation cost of HOB (C HOB ).
where ) or can be stored in building TESS, which can be later used by building a chiller.The amount of exhaust heat generated by the air conditioner was modeled considering the waste heat generation rate and the amount of power consumed by the air conditioner as given by Equation (18) ) of the greenhouse, as given by (19).The cooling energy generated by EHP can be calculated considering the power consumed by the EHP along with its COP (η EHP_cool ).Similarly, the cooling demand of house r can be fulfilled by using its local AC unit(s), as given by Equation (20). where

Greenhouse Constraints
Temperature constraints are divided into daytime (θ ) and non-day time (θ normal min , θ normal max ) as shown in Equation ( 21).An addition bound for average temperature (θ aver min , θ aver max ) is also considered, as shown in Equation (22).Constraints of water temperatures for the heat pipe (θ ) are given by Equation (23).Constraints of water contents in the air of Equations ( 24) and ( 25) are modeled using Equations ( 5)- (7).Therefore, the relative humidity can be controlled within the range (RH min , RH max ) as given by Equation (26).Constraints of CO 2 concentration (CO 2 min , CO 2 max ) are given by Equation (27).Constraint of light intensity (I total min ) is given by Equation (28).Equations ( 29)-(32) are constraints of each equipment for controlling the internal environmental of greenhouse, i.e., dehumidifier (P dh max ), fogging (P f g max ), CO 2 generator (P co 2 max ), and artificial lights (P li max ).Constraints of air circulation fan (acc min ) are given by Equations ( 33) and (34).

Building Constraints
The generation range of the air conditioner is a function of the amount of power consumed (P ac t,n ), as given by Equation (35).Constraints of water temperature (P ho_htp t,n ) for heat pipe (P ho_htp min , P ho_htp max ) are given by Equation (36).Constraints of temperature for each household in the building are divided into four categories, as shown in Equation (37).0 ≤ P ac t,n ≤ P ac Daytime (θ resin min n , θ resin max n )

•
Arrival time of resident (θ set n )

Battery Energy Storage System Constraints
Discharging and charging of BESS are modeled considering discharging loss (L B− ) and charging loss (L B+ ) as given by Equations ( 38) and (39).State of charge (SOC) of BESS at time t (SOC B t ) is a function of SOC at previous interval t − 1 and the amount of power charged or discharged at t, as given by Equations (40).In Equations ( 38)- (40), P B cap is the capacity of BESS.

Thermal Energy Storage System Constraints
Discharging and charging of TESS are modeled considering loss per hour (L T ) as given by Equations ( 41) and (42).SOC of TESS at time t (SOC T t ) is a function of SOC at previous interval t − 1 and amount of heat energy charged or discharged at t, as given by Equation (43).In Equations ( 41)-( 43), H T cap is the capacity of TESS.

Other Constraints
Energy generation equipment such as CHP, EHP, HOB, chiller, and building chiller should operate within their capacity range (P CHP max , P EHP max , H HOB max , CO Chl max , CO Chl_B max ).The constraints for these equipment are given by Equations ( 44)- (48).

Input Parameters
The operation cost, capacity, and COP of each energy generation equipment used in this study are shown in Table 1.The time-of-use (TOU) day-ahead market price signals are taken as inputs and are shown Figure 8.Initial values, loss rates, and capacity of BESS and TESS are shown in Table 2. Table 3 shows the acceptable bounds of the control parameters for the greenhouse.The temperature of each household in the building must be controlled within the setting bounds.Table 4 shows the sleeping and waking up times of the residents in each household.During sleeping time, the temperature should be controlled within 21-22 • C. Figure 9a shows the time when the residents are out of the household and the temperature bound should be controlled within 0-30 • C. When the residents arrive at the household, temperature of each household should be controlled to the preset temperature level by the resident.In all other cases, temperature bounds should be controlled as shown Figure 9b, which is set by the residents of each household.Table 3 shows the acceptable bounds of the control parameters for the greenhouse.The temperature of each household in the building must be controlled within the setting bounds.Table 4 shows the sleeping and waking up times of the residents in each household.During sleeping time, the temperature should be controlled within 21-22 °C. Figure 9a shows the time when the residents are out of the household and the temperature bound should be controlled within 0-30 °C.When the residents arrive at the household, temperature of each household should be controlled to the preset temperature level by the resident.In all other cases, temperature bounds should be controlled as shown Figure 9b, which is set by the residents of each household.

Summer Season
Energy balance of power, heat, and cooling are shown in Figure 10.In the off-peak and mid-peak periods, the price for buying electricity from the utility grid is lower than the generation cost of the CHP.During off-peak period, there is no heat load, except time interval 1, therefore, power is purchased from the utility grid during these intervals.During mid-peak hours, CHP is operated to fulfil the heat load demand.For economical operation, BESS charges power in the off-peak period and discharges the charges power at the peak period.In the peak period, the buying price from the utility grid is higher than the CHP price, therefore, the CHP is operated to its fullest.Excess heat is stored in the TESS and surplus power is sold to the utility grid.PV generates the power during intervals 8-18.In summer, heat energy is used for fulfilling the cooling demand of the greenhouse using chillers.TESS stores and releases heat for optimal heat energy management.The cooling energy is supplied mainly through the chiller, which utilizes the heat generated by the CHP, as shown in Figure 10c.
EHP is only used when there is shortage of heat energy due to higher generation cost.The exhaust heat produced due to the operation of air-conditioner in the building is used by the chillers to produce cooling energy for the greenhouse.

Winter Season
Energy balance of power and heat are shown in Figure 13a,b, respectively.During the winter season, cooling is not required and more heating is required to maintain the indoor climate for crops.Similarly, no cooling is required in the building, therefore, results of the cooling energy are not shown in the simulation results.In the initial intervals of the day, the CHP generation amount is controlled by the heat load due to the lower market selling prices, as shown in Figure 13a.During peak price intervals, CHP is operated fully and an excess of heat is stored in the TESS, which is used at the last intervals of the day.During the last off-peak hours, TESS is discharged to fulfil the heat requirements of the microgrid, as shown in Figure 13b.During the off-peak intervals (last six intervals), electricity is bought from the utility grid due to lower market price and the ability of TESS to feed the heat loads.Table 6 shows the schedules of equipment operating for maintaining the indoor environment of the greenhouse.Since the outside temperature is lower in winter, the heating pipe valve is operated frequently to maintain a proper growth temperature.Similarly, in the winter season, the use of artificial light is also more frequent due to shorter day time.Table 5 shows the schedule of equipment operating for maintaining the indoor environment of the greenhouse.Since the outside temperature is higher in the summer, the cooling pipe valve is used frequently for maintaining a proper growth temperature.When carbon dioxide is injected, air circulation fans are used to distribute it evenly inside the greenhouse.In the greenhouse, the internal humidity is increased due to the transpiration of crops, so the dehumidifier is used for controlling the humidity.Artificial lights are mainly used when the solar radiations are not sufficient (early morning and night time).As a result, the temperature, humidity, lighting, and carbon dioxide concentration of the greenhouse can be controlled within the set range as shown in Figure 11.The temperature of each household in the building is also controlled within the defined range, as shown in Figure 12.The residents of building 1 to 5 go out and come back as specified in Figure 9a.Therefore, a significant difference in temperature during the presence and absence of residents can be observed from Figure 12.Additionally, when the residents return household, the room temperature is set to the pre-set value (Figure 9b), as shown in Figure 12.However, at least one of the residents stayed in the household all the time for households 6 to 10.Therefore, only the temperature difference between sleeping and awake times can be observed, as specified in Table 4.

Winter Season
Energy balance of power and heat are shown in Figure 13a,b, respectively.During the winter season, cooling is not required and more heating is required to maintain the indoor climate for crops.Similarly, no cooling is required in the building, therefore, results of the cooling energy are not shown in the simulation results.In the initial intervals of the day, the CHP generation amount is controlled by the heat load due to the lower market selling prices, as shown in Figure 13a.During peak price intervals, CHP is operated fully and an excess of heat is stored in the TESS, which is used at the last intervals of the day.During the last off-peak hours, TESS is discharged to fulfil the heat requirements of the microgrid, as shown in Figure 13b.During the off-peak intervals (last six intervals), electricity is bought from the utility grid due to lower market price and the ability of TESS to feed the heat loads.Table 6 shows the schedules of equipment operating for maintaining the indoor environment of the greenhouse.Since the outside temperature is lower in winter, the heating pipe valve is operated frequently to maintain a proper growth temperature.Similarly, in the winter season, the use of artificial light is also more frequent due to shorter day time.

Winter Season
Energy balance of power and heat are shown in Figure 13a,b, respectively.During the winter season, cooling is not required and more heating is required to maintain the indoor climate for crops.Similarly, no cooling is required in the building, therefore, results of the cooling energy are not shown in the simulation results.In the initial intervals of the day, the CHP generation amount is controlled by the heat load due to the lower market selling prices, as shown in Figure 13a.During peak price intervals, CHP is operated fully and an excess of heat is stored in the TESS, which is used at the last intervals of the day.During the last off-peak hours, TESS is discharged to fulfil the heat requirements of the microgrid, as shown in Figure 13b.During the off-peak intervals (last six intervals), electricity is bought from the utility grid due to lower market price and the ability of TESS to feed the heat loads.Table 6 shows the schedules of equipment operating for maintaining the indoor environment of the greenhouse.Since the outside temperature is lower in winter, the heating pipe valve is operated frequently to maintain a proper growth temperature.Similarly, in the winter season, the use of artificial light is also more frequent due to shorter day time.It can be observed from Figure 14 that the indoor control parameters of the greenhouse are within It can be observed from Figure 14 that the indoor control parameters of the greenhouse are within the specified ranges throughout the day.Similarly, the indoor temperature of all the ten households is also within the specified range by the residents (Figure 9 and Table 4), as shown in Figure 15.Similar to the summer season, residents of households 1 to 5 are not at home throughout the day, while at least one resident of households 6 to 10 is at home throughout the day.It can be observed from Figure 14 that the indoor control parameters of the greenhouse are within the specified ranges throughout the day.Similarly, the indoor temperature of all the ten households is also within the specified range by the residents (Figure 9 and Table 4), as shown in Figure 15.Similar to the summer season, residents of households 1 to 5 are not at home throughout the day, while at least one resident of households 6 to 10 is at home throughout the day.

Conclusions
In order to minimize the operation cost, this paper has proposed an optimal operation method for building a microgrid with rooftop greenhouses.The proposed operation scheme has been realized by using a MAS in a single PC.Simulation results have proved the economic feasibility of integrating the greenhouse in building microgrid.The waste heat generated by the air conditioners of the building is used for fulfilling the cooling demand of the greenhouse via a chiller, which is otherwise wasted.The operation cost has reduced due to better utilization of the CHP and EHP units while reducing waste heat.The coupling effect of the energy demand in the building and the greenhouse is analyzed for two seasons of a year, i.e., summer and winter.The operation cost of the summer season is 27% higher than that of the winter season due to the higher magnitude of the cooling load.The amount of power usage in the summer season is 13% higher than that of the winter season due to utilization of air conditioners and EHP units.The operating rate of the cooling pipe in summer was three times higher than that of the heating pipe in winter.
In this study, forecasted values of wind speed, solar irradiations, and loads are utilized.However, these parameters are subjected to uncertainties. the consideration of uncertainties in the proposed model could be a valuable extension of this article.Similarly, the islanded operation of the microgrid along with the failure of local equipment also need to be considered in future studies.
Author Contributions: The paper was a collaborative effort between the authors.The authors contributed

Conclusions
In order to minimize the operation cost, this paper has proposed an optimal operation method for building a microgrid with rooftop greenhouses.The proposed operation scheme has been realized by using a MAS in a single PC.Simulation results have proved the economic feasibility of integrating the greenhouse in building microgrid.The waste heat generated by the air conditioners of the building is used for fulfilling the cooling demand of the greenhouse via a chiller, which is otherwise wasted.The operation cost has reduced due to better utilization of the CHP and EHP units while reducing waste heat.The coupling effect of the energy demand in the building and the greenhouse is analyzed for two seasons of a year, i.e., summer and winter.The operation cost of the summer season is 27% higher than that of the winter season due to the higher magnitude of the cooling load.The amount of power usage in the summer season is 13% higher than that of the winter season due to utilization of air conditioners and EHP units.The operating rate of the cooling pipe in summer was three times higher than that of the heating pipe in winter.

Figure 7 .
Figure 7. Flowchart for operation of the proposed building microgrid with rooftop greenhouse.

Figure 7 .
Figure 7. Flowchart for operation of the proposed building microgrid with rooftop greenhouse.Figure 7. Flowchart for operation of the proposed building microgrid with rooftop greenhouse.

Figure 7 .
Figure 7. Flowchart for operation of the proposed building microgrid with rooftop greenhouse.Figure 7. Flowchart for operation of the proposed building microgrid with rooftop greenhouse.

Figure 10 .
Figure 10.Energy balance in summer season: (a) power; (b) heat energy; and (c) cooling energy.

Figure 10 .
Figure 10.Energy balance in summer season: (a) power; (b) heat energy; and (c) cooling energy.

Figure 10 .
Figure 10.Energy balance in summer season: (a) power; (b) heat energy; and (c) cooling energy.

Figure 11 .
Environmental control of greenhouse in summer season: (a) temperature; (b) humidity; and (c) CO2 concentration.

Figure 13 .
Figure 13.Energy balance in winter: (a) power; and (b) heat energy.

Figure 13 .
Figure 13.Energy balance in winter: (a) power; and (b) heat energy.

Algorithm 1 .
Communication among BEMS agent and outer level agents using modified contract net protocol (MCNP).Communication among intermediate agents and local agents using MCNP.
) and temperature change at current time interval.Temperature change at current time interval is function of following parameters.SH a , ρ a , and V gh are specific heat of air, air density, and volume of the greenhouse in kJ/(kg K), kg/m 3 , and m 3 , respectively.
t : Heat absorbed due to operation of CO 2 generator (kJ/h) j dh t : Heat absorbed due to operation of dehumidifier (kJ/h) j ev t : Heat lost due to operation of fogging system (kJ/h)In Equation (1), ) and change in CO 2 concentration at the current time interval t (12).CO 2 concentration at t depends on the CO 2 injected by the CO 2 generator (CO 2 gen ), natural and forced ventilation, respiration, and photosynthesis.The amount of CO 2 injected by the CO 2 generator depends on its efficiency (CO 2 The amount of heat generated by CHP was modeled considering the heat to power ratio of CHP.Heat from EHP was modeled considering the coefficient of performance (COP) of EHP.Heat load is the sum of heat load of greenhouse (H t ) at interval t. .

Table 1 .
Input parameters for energy supply facilities.

Table 1 .
Input parameters for energy supply facilities.

Table 2 .
Battery energy storage system (BESS) and thermal energy storage system (TESS) parameters.

Table 2 .
Battery energy storage system (BESS) and thermal energy storage system (TESS) parameters.

Table 3 .
Control parameters in greenhouse.

Table 4 .
Temperature control of each household in building.

Table 1 .
Input parameters for energy supply facilities.

Table 2 .
Battery energy storage system (BESS) and thermal energy storage system (TESS) parameters.

Table 3 .
Control parameters in greenhouse.

Table 5 .
Equipment usage for environment control during summer season in greenhouse.

Table 6 .
Equipment usage for environment control during winter season in greenhouse.

Table 6 .
Equipment usage for environment control during winter season in greenhouse.