Rule-Based Object-Oriented Water Resource System Simulation Model for Water Allocation

Simulation is a basic method to analyze water resources system and provide information for decision-making. In this study, a framework is presented that describes the basic elements in a water resource system and a modelling technique integrating conceptual simulation and rule control. To formulate the process of the water cycle and water exploitation with a mathematical model, the water system is described based on adjustable relevant rules and respective parameters with experiences and pragmatic demands in the framework. The rule set describes the principles required to design conceptual networks and control the concrete processes of movement and conversion of different water flows. Combined with object-oriented programming, different calculation functional modules are classified based on the characteristics of water source layers, and the processes that occur in the networks are realised in the computation. The influence of the South-to-North Water Diversion project on the Haihe River basin is analysed by the rule-based object-oriented water resource allocation simulation model. According to the simulation results, groundwater extraction will be reduced by 6,181 million m3. The relationship between water source replacement and water layer exchange in the Haihe River basin is analysed, and the feasibility of the model is verified. Based on the rule-based model, the user requirements can be taken into account conveniently, and the rules are flexible to adjust with experiences and real conditions. This model can be used to simulate complex water resource systems.


Introduction
Water allocation and effect evaluation are two major aspects of decision-making for water planning and management (Robert and Lynne 1997;Yin et al. 2011). Along with the rapidly increasing social-economic development, more water is abstracted from the natural water cycle, while an increased sewage discharged back to the river (Falkenmark 1997;Zhang et al. 2012). The water cycle system has been transformed from the unitary natural water cycle to the dual nature-social water cycle (Qin et al. 2014). This calls for a new conception to take into account the coupling process associated with the natural hydrological cycle and water movement by water utilization into account as a whole (Lu et al. 2018). Therefore, corresponding water resource system modelling with new conceptions and techniques is required, to simulate the reality of the complicated process of water movement and transformation integrally.
Decision-making on water allocation is mainly based on the optimization method or the optimization technology combined with the simulation technology (Dunia et al. 2017). Applications prove that satisfactory results could be calculated by the optimisation model when the scale of the studied area is limited and when there are definite objectives and constraints. However, owing to the complexity of the water resource system, it is difficult or even impossible to create an optimisation model based on reasonable objectives and constraints. In this way, simpler mathematical methods can be used to calculate the processes based on experience. Water resource system is naturally in accordance with characteristic of object-oriented programming (OOP), and the advantages of its application into simulation for water resources (Kheireldin and El-Dessouki 1998). Therefore, the work focus on the development of object-oriented simulation models with a computational framework is improved (Reitsma and John 1997;Alfieri et al. 2006). With OOP idea, the same category of elements in the system, can use unified parameters expressing its characteristics and behavior, thus to facilitate the division of the object-oriented method description water allocation system. The paper aims to propose a rule-based objected-oriented water resources allocation Simulation Model (ROWAS) and its application to realize the simulation of a complex system composed of natural and social water cycle. ROWAS is a simulation model with a framework, in which a river basin is modelled as a congregate of normalised objects that represent the physical entities or abstracted objects of the river basin (You et al. 2005). To describe the major processes the model is constructed based on a set of designed rules, which water the movement and conversion in the system are conceptualized and described clearly. To realize this goal, the system is divided into layers with water source, an idea of stratification applied in water-related simulation (Panagopoulos et al. 2012;Bathrellos et al. 2017). Calculation rules are determined based on the characteristics of water sources (Han et al. 2007) to reduce the calculation dimension. ROWAS can simply but entirely describe both natural and artificial water processes under reasonable assumptions, provide various resultsand information based on detailed the situation of water cycle. Ultimately, through an iterative use of the model, different scenarios can be simulated and refined with predefined input data.

System Elements and Framework
A framework is fundamental to the construction of a simulation model on a water resource system (Letcher et al. 2007). Effectively, this framework should reflect the basic relationship among these elements and the main processes of water movement, so as to be transferred into mathematic model (Leskens et al. 2014). ROWAS is a simulation model for water recourse system with a framework (Fig. 1) describing the basic elements and their mutual relations. There are both natural water cycle and artificial process caused by human activities in this framework, and the complex process of water system could be described by adjustable relevant rules and respective parameters with experiences and pragmatic demands. There are two types of basic elements in the conceptual system: one is the node, and the other is the line (Rosegrant et al. 2000). The node elements include water projects, water users, divarication nodes or confluent and other control sections in the watercourse. Line elements are linkages through which water moves between different nodes. Different water source types exist and move in or through these node and line elements and respectively transform into one or the other form. Therefore, there are several arcs that represent natural rivers, drainage of sewage, route of water supply and discharge respectively. The simulation model is created with these conceptual objects and corresponding rules. Table 1 lists the classification of the basic elements and respective physical prototype.

Rule Set
The framework only provides possible routines of movements and conversions of water. The methodology of ROWAS is integrated by conceptual simulation and rule-based control. The rules set gives principles to design conceptual network of simulated area and control the concrete processes of movement and conversion of different water flow, including water allocation among various areas and different water users.
More instructions are necessary to control the processes of simulation in detail, e.g. projects operation and water distribution under different conditions. Besides, factors like small-scale waterexploitation projects are also necessary to be normalized as basic elements through reasonable conversion and abstraction. For example, the calculating unit is an aggregate which represent different physical entities in a specific region, including different water users, small-scale water projects, sewage treatment plants etc.. Such small-scale water projects are represented by assumed local catchments with respective parameters as a reservoir, to simulate its real function.
To define and control different problems, the rules set comprises of three types of rules: basic rules set, conceptual rules set and operational rules set. The basic rules are the necessary principles that must be adhered to in simulation. Conceptual rules are the foundations of the implementation of system conceptualisation, and they also include some necessary and logical assumptions to reduce the scale or facilitate computation. The operational rules are the basic algorithms used to realise the calculation regarding to water projects and water users, e.g. water allocation between various users, operation of reservoirs etc. Table 2 lists the classification of the rules and respective purposes.
Rules provide respective constraints for system simulation to meet predefined conditions, so the detailed process is controllable. Meanwhile, the operational rules provide the framework that allows the execution of the projects in the system. Furthermore, designers can add or modify these actual according to the real condition and demands to reflect studied system more accurately.

Functional Modules
Generally, water sources are divided into surface water (including diverted water), groundwater (including shallow and deep groundwater) and others (including sewage and desalinated seawater). Based on the water flow characteristics of different water sources, the water resource allocation system is divided in different network layers, and special rules are set for different water sources so as to reduce the complexity of the allocation system (Song et al. 2016). Considering the relative independence of allocation of the different types of water sources, the main process is subdivided into eight functional modules. Each module is aiming at one type of water source allocation and the effect for or from other modules. Based on this module division, the complex process can be simulated clearly and easily.
(1) Utilisation of irregular water resources Irregular water sources are lack and its users are specific (Wang et al. 2010), thus, it is allocated top priority. For example, the collection of rainfall gathering and desalted seawater respectively supply urban and rural lives. Unsettled seawater is directly supplied for industry. Brackish water is supplied for agriculture. To divide the studied area into subregions according to the basin's hydrological traits and administrative boundaries. the sub region will be considered uniform to implement conceptualisation Water users and priorities To ascertain users needed to consider and the sequences to get water resources. The requirement for water quality from different water users is also defined. Water sources and consequence to be used Classification of water source according to sources, quality. To define the sequence of various water sources to meet water demand Time interval To ascertain the length of the time interval in computation based on the user requirement and the available data information.

Conceptual rules
Local surface water To define the water exploitation by small-scale water projects that are not listed on the system network separately.

Treatment and reclamations of waste water
There is a suppositional sewage treatment plant in each calculation unit to represent the capability of treatment and reclamation with corresponding parameters. Both the treated sewage and unsettled sewage drainage along with given routines are defined by the network.

Operational rules
Surface water projects To provide arithmetic for surface water projects listed separately in the network. Local water projects To provide arithmetic for conceptual surface water projects which are not listed separately in the network.

Inter-basin diversion projects
To provide arithmetic of the inter-basin water resources diverted out of the studied region Groundwater projects To provide the strategy of exploitation of groundwater and the relation between the utilisation of surface water and groundwater. Exploitation of other water resources Computational principles for unconventional water resources, e.g. seawater, exploitation of rainfall.
(2) Utilisation of local surface water Local surface water is supplied by small-scale withdraw projects and is mainly used for irrigation purposes. According to the allocated proportions and priorities, the local surface water is allocated to different users. Finally, the surplus flows into local catchments or downstream nodes according to the network.
To simulate the water utilisation by local small-scale reservoirs or catchments the conceptual reservoir is designed in ROWAS (for convenience it is called local catchments). The local catchments, including small reservoirs and other water-exploitation projects which are not taken into account in the network separately, can store and supply water. In term of the system design, only one local catchment can be conceptualized in one unit. Local catchments can receive unused local surface water, sewage from urban area, return water after irrigation, discharged floods of upper stream units or nodes. The controllable water is distributed to various users in term of proportions and priorities. Except the exploited and evaporated water, the overstored part is discharged to other unit local catchments, nodes, and outlets. The water source movements in the local unit catchment module are shown in Fig. 2. (3) Utilisation of shallow groundwater resources To realize the joint operation of groundwater, surface and inter-basin diverted water, the simulations for shallow groundwater resources utilisation was divided into three stages. At the first stage, it is supplied for household, industry with an adjustable necessary amount before surface water supply. The second stage is to allocate the remaining exploitable groundwater after surface water resources allocation. If the water requirements for domestic, industrial, and agriculture needs cannot be met after the second stage, the third stage allocation will be commenced. In this stage, a proper amount groundwater out of exploitable range will be supplied with control parameter. The exploiting strategy of different units and stages and allocation relations between users are guided by parameters of operational rules. Deep groundwater acts as a complementary and emergency source (Smakhtin et al. 2001). It is exploited when some user demands cannot be met after all other available water sources have been allocated. Deep groundwater resources are not only supplied for household, industry, but also for agriculture needs if the rule permits so.
To estimate the negative effects and harms of the exploitation of deep groundwater, the total amount and time series of exploited deep groundwater will be documented based on simulation.
(5) Surface water supply The surface water supply module deals with the operation of all separately selected nodes, including nodes as large-scale reservoirs, major extraction projects, or major cross-sections. The basic rules of simulation in this part are the water balance equitation and reservoirs joint operation algorithm. Generally, the objective of the joint operation is to maximise the water supply and minimise the discharge. Before the simulation of reservoirs joint operation, this module computes the inflow of each node. After the water supply simulation, overstored water is discharged to downstream projects, units and river outlets according to the network. The water source movement according to the surface water supply is shown in Fig. 3.
(6) Calculation of water consumption, drainage and reclamations For urban water users, the residual of consumed water is sewage source. The sewage sources can be divided into treated and untreated sewage based on the proportional parameters. Furthermore, part of the treated sewage can be recycled, the other part is discharged into the river or downstream nodes. Recycled sewage is supplied specific water users by parameters and network relations.
For rural household and agriculture, most of the water used will be consumed, including evaporation of taking away by products. The surplus water returns to the system in the same Fig. 3 Movements of water sources according to the surface water supply way as untreated sewage water from the urban system, then flow into local catchments, downriver nodes or outlets according to network. In the process of movement, the water loss is considered. The flowchart of production, drainage and reclamation of sewage and return water as shown in Fig. 4. (7) Inter-basin diversion water There are two stages for allocation of inter-basin diversion water. The first stage occurs before the surface water allocation, in which the preemptive part will be allocated. The second one is behind the surface water allocation to distribute the surplus of stage one. With the two-stage allocation, the priority of inter-basin diverted can be set flexibly.
The diverted water allocation in different units is controlled by its proportion in the corresponding canal. Similarly, the distribution of the allocated water in the specific unit is decided by the users' water allocation parameters. The surplus water in certain time interval can be stored in conceptual reservoirs next time.

(8) Statistic of outflow into outlets
After all the water allocation in one time interval, the last module involves the calculation of the water flowing out of the system. According to the framework, there are three types of water sources discharged into the outlets. The first one is the over-stored discharge flood from the separately listed water projects, the second one is the disposed water from the unit, the third one is overstored water from local catchments. The statistic of the total water quantity at the river outlet is performed at every time step.
Given that the ROWAS is designed based on reality and experience, it is flexible and appropriate to analyse the situations relevant to water allocation under different scenarios. In Fig. 4 Flowchart of production, drainage and reclamation of sewage and return water addition, it is easy for to be customized with users' needs by adjusting rules and parameters e.g. to meet the future conditions.

Implementation of ROWAS
Since the conceptual framework is in accordance with the basic thoughts of OOP is adopted to realize implementation of ROWAS model. With the rule-based model, the user requirements can be taken into account conveniently, and the rules are flexible to adjust with experiences and real conditions. Application proves that it is feasible to apply this model type to simulate complex water resource system.
According to the systematic framework, four basic classes are defined to represent the major elements, including calculating units, catchment nodes, canals and outlets (Table 3). There are two types of catchment nodes, one for control cross-sectional nodes and the other for water projects. For each class, there is definition of attributes and methods to represent its realistic characteristics and relevant water movement.
Through the individual objects, the model provides comprehensive simulation results, including the detailed course of water allocation, composition of water supply, situation of major water projects and rivers' control section. Through the instantiation of the classes, a river basin is delineated with a specific number of objects. Using the instantiated objects, the complete process is simulated based on the water movement and conversion to each object and their relations. According to the definition of classes, the individual object can deal with the basic calculation regarding the object. The main program provides the required data for the objects and implements the peripheral computation by receiving the returned value from the objects. Based on the processes defined for each object by rules, the movement and conversion of different water sources are calculated from the objects in upstream to ones in downstream.

Study Area
Haihe River basin is located in North-China (Fig. 5), and covers an area of 320,000 km 2 , with 60% mountain and 40% plain areas. The total population is approximately 130 million, and is most concentrated in the plain area, including the mega cities of Beijing and Tianjin. The annual average precipitation (539 mm) of Haihe River basin is lower than the national average Fig. 5 Haihe River basin water system map (628 mm). Obviously, water shortage and related eco-environmental issues in North China have become the substantial threat to impact sustainable development. Furthermore, this region is very important as the political, cultural and economic center of China. The SNWD project is presented as a strategic work to solve the water scarcity in the region after long-time research. There are 2 routes (Middle Route and East Route) supply water.

Data Preparation
(1) Inflow and characteristics of system elements. Water resources system network is the fundamental work of simulation, which describes the major relations of water movement in system. There are 125 calculating units and 64 nodes, including large-scale water projects and important a provincial boundary cross the major rivers. The other middle and small large-scale projects are conceptualised into the local catchments of the units. For each large-scale project, there is a set of regulation rule curves to control its operation.
(2) Water demand and its processing. A water demand of six sectors, including urban domestic, rural domestic, industry, agriculture, urban ecosystem and rural ecosystem. According to the forecast, the total water demand in 2030 will be 50.1 billion m 3 .
(3) Hydrological data: 50-year long monthly series from 1956 to 2005, runoff of each calculating units and reservoir.

Water Balance of Supply and Demand
Two scenarios are simulated and the results in Table 4. Scenario 1 follows the current pattern of water supply without the SNWD project and perimts groundwater over pumping. Scenario 2 considers the SNWD project and restrictions on control on groundwater pumping. By comparison, the results show that the local water resources are insufficient in the future, and inter-basin diversion is necessary for demand and supply balance in 2030 accompanying the rapid increase of water demand and reduction of groundwater pumping.

Analysis of Water Source Structure
Despite of minor gap in water shortage, supply proportion of different water sources of the two schemes is obviously different (Table 5). In scenario 1 the groundwater exploitation is 30.9 billion m 3 , which seriously exceeds the groundwater exploitable of the Haihe River basin. Compared with scenario 1, the underground water supply by 6.18 billion m 3 lower, the result show SNWD project can effectively replace the underground water quantity and support sustainable water use in Haihe River basin.

Relationship of Different Water Sources
The displacement of water source can be further analyzed with the ROWAS model. Although the groundwater decreases and externally diverted water increases with the SNWD, it is not a direct substitute because their water users are different. Figure 6 shows that the displacements of externally diverted water and groundwater are implemented indirectly, and the additional externally diverted water is mainly supplied to domestic and industrial users, thus replacing local surface water. Local surface water supplies more for agriculture, thereby enabling groundwater replacement. Relationship between water sources and water user is critical and complex for water allocation simulation. Such relationship can be precisely illustrated by ROWAS model through multi-layers network. Both the summarised results and the detailed information in concrete objects can be evaluated conveniently. When there is no mutual restriction on the priority of water sources, the order of utilisation can be adjusted according to the actual situation. Based on parameter control, the priority order of the use of water can be adjusted, and the decision maker flexibly adjusts different water source order as the design condition of the scheme, this reflects the simulation effects at different decision-making modes.

Analysis of Water Exchange in Water Source Network Layer
According to the stratified network division of water sources, the same water sources can be reduced owing to the loss of evaporation and leakage in the vertical direction during a YR for diversion water from yellow river the movement of their own network, but they cannot be converted into other water sources, and can only be converted into other water sources at system nodes such as units. Table 6 shows the water conversion relationship of different water source network layers in scheme 2. According to the simulation results, the most frequent water exchange is between the local surface water layer and surface water supply layer. 10.5 billion m 3 of water from the local surface water layer to surface water supply layer, meant the reality of water exploitation from the natural water cycle. According to the topological relation of the network, there are many transformation relations of the partial water amount in the same calculation period. The more complex the system structure is, the more common these transformation relationships are, and closer they are to the actual processes. Based on parameter control, ROWAS model can control and realise the exchange of water in different network layers, and is conducive to the analysis of water balance in complex basins.

Conclusion
Human activities affect natural water cycle and form new processes, which co-exist with natural water cycle but have relatively independent processes. The increasing scale of the water resource system and the increasing influence factors have led to more complex structure and higher requirements for decision-making of water allocation. ROWAS provides an idea and method to solve the simulation of water allocation in macroscopic and realistic process. Under general design, it can be modified to adapt the condition of specific area. The application in Haihe River basin show its flexibility and controllability. It can assist the planners to handle planning of a water resources system in accordance with different water utilisation level and natural hydrological condition.
This simulation model is still needed to be improved. It is necessary and promising to continue this work thanks to the complexity of the water resources system. One aspect is to improve the conceptual framework to be compatible for more water related processes. In addition, the optimisation method for calibration of the parameters in model is also important for applications, which can improve the efficiency, since there are too many parameters to implement manual adjustment, while analysing large-scale systems.

Compliance with Ethical Standards
Conflict of Interest The authors declare no conflicts of interest.
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.