# A Digital Twin Architecture to Optimize Productivity within Controlled Environment Agriculture
## 3 Digital Twin Architecture
### Digital Twin and Intelligence Layer  
After the definition of the framework and its implementation technologies, the DT models and the intelligence layer are developed. The tuning of these elements is outside the scope of the article since the objective of this work is to build a DT architecture and not to optimize the productivity of the prototype greenhouse. The demonstration of the effectiveness of the built DT architecture in optimizing the productivity is left as future work. Therefore, this section illustrates the communication between the intelligent layer and the DTs--referred to as optimization workflow--for the optimization of the productivity.  
The optimization workflow is depicted in Figure 5 and consists in the following phases:  
1. Generation of climate control strategies: The intelligence layer receives from the cloud: (i) Microclimate historical data (internal temperature and relative humidity); (ii) environmental historical data (external temperature and relative humidity); (iii) previous climate control strategies and crop treatments. Starting from these data, different alternatives of climate control strategies (CCSs) are generated. In this work, a CCS is defined as a control sequence of the greenhouse actuators to achieve a desired crop microclimate. Then, a prediction of the future environmental conditions is performed since EnergyPlus needs this information to assess the different CCSs.
2. Assessment of climate control strategies: The historical microclimate data, and the historical and predicted environmental data are transmitted to EnergyPlus. Then, all the generated CCSs are input to the software, and the predicted energy consumption and microclimate are computed for each CCS using the historical and predicted climate data.  
Figure 4: Framework and technologies utilized within the DT architecture for CEA systems.  
Generation of crop treatments: The intelligence layer receives the predicted energy consumption and microclimate relative to each CCS. Then, different alternatives of crop treatments (TRTs) are generated, e.g., event to trigger the irrigation, volume delivered for irrigation, etc.
* Assessment of crop treatments: The historical and predicted microclimate data are transmitted to DSSAT. Then, all the generated TRTs are input to the software, and the predicted production and resource consumption (e.g., water, nutrients, etc.) are computed for each TRT using the historical and predicted microclimate data.
* Overall optimization: The intelligence layer receives the predicted production and resource consumption relative to each TRT. The productivity is computed for each pair of CCS and TRT--where the productivity is defined as the ratio between the production, and the sum of the energy and resource consumption. The best pair of climate control strategy (\(CCS^{*}\)) and crop treatment (\(TRT^{*}\)) is computed and transmitted to the gateway.  
Given the interdependence between EnergyPlus and DSSAT, an overall optimization must be implemented. Starting from the domain knowledge, optimization algorithms and/or heuristics should be studied as future work to identify optimal solutions in acceptable computation time.