{'fraction_non_alphanumeric': 0.026412213740458015, 'fraction_numerical': 0.013587786259541984, 'mean_word_length': 4.449528563505269, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Minimizing Electricity Cost through Smart Lighting Control for Indoor Plant Factories

Smart plant factories incorporate sensing technology, actuators and control algorithms to automate processes, reducing the cost of production while improving crop yield many times over that of traditional farms. This paper investigates the growth of lettuce (Lactuca Sativa) in a smart farming setup when exposed to red and blue light-emitting diode (LED) horticulture lighting. An image segmentation method based on K-means clustering is used to identify the size of the plant at each stage of growth, and the growth of the plant modelled in a feed forward network. Finally, an optimization algorithm based on the plant growth model is proposed to find the optimal lighting schedule for growing lettuce with respect to dynamic electricity pricing. Genetic algorithm was utilized to find solutions to the optimization problem. When compared to a baseline in a simulation setting, the schedules proposed by the genetic algorithm can achieved between 40-52% savings in energy costs, and up to a 6% increase in leaf area.


I. INTRODUCTION
Traditional agriculture across the world is challenged by population pressure, land scarcity, as well as abnormal weather conditions [1]. One of the more important agricultural advancements in the last 50 years is the concept of the plant factory. Plant factories can be built anywhere, and by stacking upwards, increases the agricultural output of a plot of land many times over traditional farms. Carefully controlled environments through the use of artificial lighting and airconditioning allow crop production to thrive all year round, with reduced reliance on the outdoors climate when compared to traditional farming methods [2].
Smart sensors and machines are increasingly being integrated into plant factories with the development of Internetof-Things technology. Through analysing the data collected from sensors, control algorithms can be implemented to automate processes and ultimately reduce the cost of production and to improve yield. Control algorithms for plant factories depend on the type of crops being grown and can range from simple rule-based control to the more complex optimization algorithms for decision making. [3] utilized humidity sensors and the NodeMCU microcontroller to track and control the humidity in a Lingzhi farm according to a rule-based flow chart. [4] developed a system to optimize the water and electrical resources of a aquaculture setup based on fuzzy logic control over a wireless sensor network with water level, pH and EC sensors.
A major challenge of growing leafy vegetables in plant factories will be to manage the quantity and quality of artificial lighting to the crops [5], while balancing electricity cost. To optimize both plant growth and electricity cost, knowledge of how a plant develop with respect to different lighting or environmental conditions, as well as the power requirements of the artificial lighting, are required. Experiments will have to be conducted to collect such information if they are unavailable beforehand. An example is [6], where the authors collected data on different tomato plants grown under different conditions, before compressing the information in a feed-forward neural network and optimizing for nutrient delivery schedule using a genetic algorithm.
Also, in recent years, countries like the US [7] and Japan [8] are introducing dynamic electricity pricing to the electricity grid in an attempt to smooth out electricity demand, adding complexity to the electrical cost optimization problem for smart plant factories.
As seen in the literature reviewed, deployment of sensing technology and control algorithms are conditional on the optimization objectives, crop grown, and farming setup. In this paper, we would like to explore the effects of red and blue LED lighting on lettuce (Latuca Sativa) grown in a Nutrient Film Technique (NFT) [9] hydroponics setup. Ultimately, we would also like to optimize the electrical cost of operating a lettuce farm subjected to the plant model and dynamic electrical pricing. Our methodology is summarized in three steps: raw plant growth data collection, plant growth modelling, and finally lighting cost optimization.
The paper made the following contributions: • For plant growth data collection, we proposed an experimental IOT setup and image processing framework to monitor the leaf area growth of lettuce • For plant growth modelling, we modelled the effects of LED lightning on lettuce in a neural network • For lighting cost optimization, we optimized the lighting schedule for operation based on plant model and dynamic electricity pricing While the this paper focuses on optimizing the lightning control of indoor plant factories, the same methodology can be applied to other operational factors like temperature, humidity, and nutrients control. The rest of the paper is organized as such: Section II discusses the experimental setup and data processing methodology, Section III introduces the plant growth model, Section IV describes the lighting cost optimization algorithm and presents the outcome of the optimization. Finally Section V is the conclusion and discusses future work.

II. SETUP AND IMAGE PROCESSING FRAMEWORK A. Experimental Setup
The experimental setup shown in Fig. 1 is housed in an air conditioned room where the temperature is kept at 25 • deg Celsius. It consists of three levels of NFT hydroponics growbed, with the lighting conditions of each level individually controlled with a Raspberry Pi 3 micro-controller. The light source for each level is a dimmable panel with integrated red (650-670nm) and blue (450-465nm) LEDs mounted at 40cm above the grow-bed. Each grow-bed can support up to 20 lettuce plants, sharing the same nutrient solution with the other levels. The nutrient solution is circulated through the grow-beds with a pump from a 120 litre tank. The aim of the experiment is to collect information on how the lettuce plants will react to changes in lighting conditions. Hence, the values for nutrient concentration as well as the pH, as measured by the electro-conductivity (EC) sensor and pH sensor sourced from Atlas Scientific, are kept at consistent between 1600-2000 µS/cm and 6.4 − 6.7. Once the EC, pH, or water-level values dip below the desired threshold, a notification to top up the nutrient solution will be sent out by the micro-controller. Lighting, temperature and humidity conditions on each test bed are monitored by an array of sensors placed on each test bed. The raw values for the ISL29125 lux sensors used to monitor lighting were calibrated to the standard µmol/m 2 s units used to measure photosynthetic flux density (PPFD). Temperature and humidity under each were measured by DHT22 sensors. Data from the experimental setup are uploaded to a web server hourly. Prior to seeding of the lettuce plants, the power requirement of the LED panel at each red and blue PPFD settings were quantified in Watts using a power meter. The power requirements are shown in Fig. 2.   [10]. Pictures on the growth of the plant were also sent to a web server hourly and the images batch-processed at the end of the experiment. However, it is a challenge for computers to recognize the leaf area for plants in an image. Leaf area segmentation techniques include simple thresholding like Otsu thresholding [11], to state of the art convolutional neural network (CNN) based approaches [12]. In our use case, simple thresholding does not work well with our images as they have too much variations in color, while CNN based techniques require too much effort to retrain the network for our setup. To avoid the time consuming task of manually labelling each image, we modified the K-means algorithm in [13] to come up with a helper algorithm in Algorithm 1 for plant segmentation.
Algorithm 1: Batch Image Segmentation of Leaf Area 1 Undistort raw images via homography estimation [14] 2 Cluster images using K-means algorithm via their pixel brightness and distance from center of each pot 3 Estimate the threshold to determine which clusters are plant clusters and which are non-plant clusters (I) Sample a few images in chronological order from a experimental sequence (II) Manually determine which clusters are part of the plant and find the centroid of the cluster which can still be classified as a plant cluster (III) (Assuming plant grow exponentially) Fit an exponential rule to predict the growth of the maximum centroid from data gather in (I) and (II) 4 Apply the exponential rule to all images in the growth stage to obtain segmented images. Final results are shown in Fig. 3 In Fig. 3, under step 2 to step 3, we show the results of applying Algorithm 1 to images taken from day 3 to day 13 after the lettuce plants are transplants into the setup.

A. Plant Growth Equation
The relative growth rate (RGR) of a plant's biomass typically follows an exponential relationship [15], as in Eq. 1.
where M 2 is the final dry mass, M 1 is the initial dry mass and t is the change in time in days. In our experiment, we assumed that the increase in leaf area of a plant is related exponentially to a non-linear function that is dependent on the averaged light energy given to the plant over t, and external variables like EC and pH. The initial leaf area L 1 and final leaf area L 2 takes the place of M 1 and M 2 , resulting in Eq. 2. t is the time in days since transplanting.
f (P P F D redavg , P P F D blueavg , EC, pH, t)

B. Plant Model
A neural network is a universal function approximator [16], and will allow us to approximate the relationship between variables in Eq. 2. Data from the 4 experiments are split into testing and training data. Data from experiments 1,2,4 goes into the training set, while data from experiment 3 are used for testing. The design of the neural network, as well as the variables used are shown in Fig. 4. Variables are min-maxed to 0-1 according to the range displayed, again in Fig. 4. The neural network is a two layer feed forward network with 'relu' neurons. Dropout of probability 0.5 is used for regularization to improve the accuracy of the network. The network was trained with back-propagation using the Adam optimizer with Mean Squared Error as the loss function for 2000 epochs. A simple linear regression is also used to approximate f (P P F D redavg , P P F D blueavg , EC, pH, t) for comparison with the neural network. The testing and training errors for both methods are summarized in Table II in terms of Mean Squared Error (MSE) and R 2 values to determine the goodness of fit of the model. The model is trained on the training data, and tested with either the training data or the testing data. The neural network model performed much better than that of the linear regression by having a lower MSE and high R 2 value on both the training and testing datasets. However the difference in accuracy is lesser in the testing dataset as compared to the training dataset due to a slight distribution shift in the testing dataset. Fig. 5 shows the shift in distribution and results of the eventual leaf area prediction. With more data, the neural network is expected to perform better than that of the linear regression, with its ability to model the non linear behaviour that may arise with lighting and plant growth interaction .

C. Sensitivity Analysis
Once we have the plant model, we can track the sensitivity of the increase in leaf area to changes in lighting conditions. Eq. 2 can be manipulated as such to Eq. 3: Assuming EC = 1800, pH = 6.5, and t = 1hr, we investigated the increase in leaf area (L 2 −L 1 ) when t= 1 st day, 5 th day, and 10 th day across the range of the light settings. The results are shown in Fig. 6. The brighter portions of the heatmap in Fig. 6 denotes the lighting settings with higher growth rates. As we see, at the early stages of lettuce growth, the plant prefers a mixture of red and blue lighting for best growth. After some time, the preference of the plant switches over to red light. This is consistent in the findings in [17], who recommends mixing red and blue light in the ratio of 2.2:1 for lettuce growth, in the case of non adjustable LEDs. This ratio might not be the most cost effective option as blue leds will require more energy to provide the same irradiance level as red leds (Fig. 2). For LEDs with adjustable levels, we could leverage on the natural preference of the plant and adjust the lighting conditions for maximum growth and savings at each stage. For best growth on the 5th and 10th day, the ideal red to blue ratio is 14:1 and 20:1 respectively, as suggested by the plant model.

IV. LIGHTING COST OPTIMIZATION
One of the concerns for indoor plant factories is electricity pricing, due to the reliance on artificial lighting to drive plant growth. In countries where there are dynamic electricity prices, this can be a bane or a boon. For the growth of vegetative plants which usually do well under a 24 hr lighting schedule, the lighting cycle will have to be planned away from periods when electricity cost are high to prevent huge running cost. At the same time if plant factories can take advantage of the periods of lower-ed electricity costs, they could experience savings in electricity bills. The problem will be even more interesting if solar photovoltics are involved, although this aspect is not investigated in this paper. Prerequisites to Fig. 6: Growth rate of lettuce with different lighting settings at different stages optimizing the cost of electricity in a plant factories while maximizing the biomass of the plant depends on three factors: knowledge of the electricity prices, knowledge of how plants react to lighting, and knowledge of the energy consumption of the lighting system. In our case study, we attempt to optimize the energy consumption and maximize the biomass of lettuces plants in our setup for a period of 15 days. The electricity price plan for reference is taken from the dynamic pricing scheme of Tokyo Electric Power Company [18] and listed in Table III. The plant model is described in Eq. 2 in Section. III and the operating characteristic of the LED lighting panel is illustrated in Fig. 2. This results in the following optimization problem to maximise the profit margin of operation for a single lighting panel and grow-bed: E(δ, P (s δ )) = Elec. cost in Table III P (s δ ) = LED power in Fig. 2 L 360 > 400 (4) In this problem, the time step δ represents 1 hr in a day, resulting in 360 total timesteps over a period of 15 days.The control sequence s is a 2 by 360 vector, representing the red and blue lighting level at each hour for a period of 15 days. L t is the average leaf area of a lettuce at time δ and n is the number of lettuce cultivated per panel, which is 20. P is the cost of lettuce per unit area per lettuce and will determine the output of the optimization. If P is very low, the optimal behavior of the system will be to not turn on any lights, which is detrimental to the growth of the plants. To prevent this, we also set a constraint on the size of the lettuce in the optimization problem to ensure it is at least 400 cm 2 at the end of the 15 days.

A. Genetic Algorithm
The optimization problem in Eq. 4 is a non-linear one due to the presence of non-linear constraints. Among the many other ways to solve non-linear optimization problems, Genetic Algorithm (GA) is reputed as a fast and efficient solver if the fitness function can be quickly evaluated, making it a great algorithm to solve Eq. 4. The first step in a genetic algorithm is to represent the solution of the problem in a chromosome. For our optimization problem, the chromosome is a 360 long vector with each bin taken up by a tuple, (r δ , b δ ). Both (r δ , b δ ) ∈ Z : {1...10}, with 1 representing 10% of maximum PPFD and 10 representing 100% of max PPFD. The maximum PPFD for red LEDs in our system is 200 µmol/m 2 s, while for the blue LEDs it is at 100 µmol/m 2 s. A (r δ = 3, b δ = 3) tuple will mean that the red LEDs are outputting PPFD at 60 µmol/m 2 s while the blue LEDs are outputting at 30 µmol/m 2 s. The fitness function is the objective function in Eq. 4. Beyond that, the steps in GA like population generation, crossover, and mutation follows that of the canonical version stated in [19]. Parameters relevant to GA are listed in Table IV.

B. Results and Discussions
Different values of P were tested, P = 0, P = 0.001, and P = 0.01. The generated control sequences from GA were also compared to a (r δ = 7, b δ = 7) 24hr always-on baseline sequence, as recommended by [17]. Fig. 7 shows the convergence of the fitness function in various cases of P . When P = 0, the fitness function is dominated by the cost of electricity over the period of 15 days. Hence, this will lead to the control sequences being optimized for a low electricity cost, subjected to constraint that the final leaf area of the plant must be more than 400 cm 2 . When P is low at 0.001, the revenue from selling the plant will be approximately equal to the cost of electricity, this will induce the GA to search for control sequences that balances the cost of electricity with the final leaf area. Finally when P is high at 0.01, the GA will tend to search for control sequence that favor a larger final leaf area over lowering the cost of electricity.
The control sequence for the 1 st 24 hour sequence in s for various P values are shown in Fig. 8. We see that when the P is highest, the GA optimizes the growth of the plant by offering more light even when the cost of electricity is high. When P is the lowest, the GA choose to only operate the lights at the portion when electricity prices are the lowest. For P = 0.001, the GA balances the growth of the plant with the cost of electricity.
The final leaf area and electricity cost are summarized in the Table. V. Profit is the objective function of the problem defined in Eq. 4. When compared to the baseline, the GA allows the system to achieve between 40-52% savings in electricity cost. Meanwhile, the leaf area output can be improve by up to 6%.

V. CONCLUSION AND FUTURE WORK
In all, we have observed the growth of lettuce (Latuca Sativa) in our IOT-based experimental setup, and collected the data for analysis. A image processing framework based on the K-means method is used to extract the leaf area information from images captured during the experimental phase. Using the leaf area information and sensor data from the experiments, we modelled the growth of the plant with respect to changes in lighting conditions, pH and EC factors. Finally, we proposed an optimization problem to find the best lighting schedule to reduce cost of production based on our plant growth model. Genetic Algorithm is used to find solutions to the optimization problem. The optimized lighting system is able to achieve between 40-52% savings in electricity cost while improving the leaf-area of the plants grown by 6%, in the simulation setting with the plant growth model. For future work, the optimization problem can be extended into a model-predictive-control problem in a real world experiment. Our framework of collecting data, modelling the phenomena, and optimizing the various factors based on the developed model is generally flexible. We hope to extend this framework into optimizing the other aspects of the plant factory, which includes air-conditioning and nutrient delivery.
It will also be interesting to consider other ancillary systems like solar PV or energy storage within the plant factory in the optimization problem.