Introduction

Water is one of the most important resources for the human life, which is used for industrial, agricultural and domestic activities. Recently, around the world sever water scarcity problems have been observed because of its intense use. Figure 1 shows the intense interactions between the activities involved for the use of water. In the recent past, the water was considered as a renewable resource because it belongs to a cycle; nevertheless, nowadays the situation has changed because of the pollution problems. Although that the planet has about 1400 million of km3 of water (SEMARNAT 2014), recently there has been observed an overexploitation of the freshwater bodies and this has promoted the water scarcity. In the industrial sector, the use of water networks through recycling, reusing and regeneration has been successfully applied. In this context, Foo (2009) presented an extensive review of pinch-based techniques for synthesizing water networks in continuous processes; it should be noticed that the pinch-based techniques represent the basis for the water integration in the industrial processes. Gows et al. (2010) presented a review for industrial water minimization involving batch processes. Jezowski (2010) presented a review regarding industrial water networks using graphical and mathematical programming techniques. The mathematical programming techniques are able to yield better solutions than other approaches. Ng et al. (2010) presented an optimization formulation to determine the target for the minimum water consumption in industrial processes. Fu et al. (2012) developed an approach for the water consumption in different processes. These previous reported approaches have identified significant reductions in the water consumption in the industrial processes; this has motivated the implementation of rigorous optimization formulations for the synthesis of water networks in other activities. In this context, Santos-Pereira et al. (2002) discussed some of the issues related to crop irrigation management focusing on management policies under water scarcity situations. Jhorar et al. (2009) proposed a water distribution model for irrigating under low precipitation conditions. Agrofioti and Diamadopoulos (2012) showed that adapting the existing wastewater plants to include tertiary treatment might help to satisfy up to 4.3 % of the irrigation requirements in the Greek island of Crete. Additionally, other studies have been proposed for water reclamation. This way, Hurimann (2011) reported that the use of reclaimed water in single households has potential to satisfy some of the demands mainly of irrigation. Zaneti et al. (2012) presented a study of the use of reclaimed water in washing vehicles. Al Khamisi et al. (2013) recommended the use of reclaimed water to satisfy crop water requirements.

Fig. 1
figure 1

Water distribution around the world (CONAGUA 2012)

Recently, some strategies have been proposed to consider the reuse of water in different human activities. For example, Chilton et al. (1999) implemented an analysis for a water collection system installed in a mall. Appan (2000) proposed the use of a rainwater collection system in the Nanyang Technological University in Singapore. Cheng et al. (2006) presented a quantitative evaluation method for rainwater harvesting. Besides, rainwater harvesting has been explored as a viable alternative. In this context, Eroksuz and Rahman (2010) proposed the use of rainwater tanks in multi-unit buildings. Domènech and Saurí (2011) implemented a comparative study of the use of rainwater in single- and multi-family buildings. Domènech et al. (2012) studied the use of harvested rainwater in developing countries. Rahman et al. (2012) proposed the use of rainwater tanks in detached houses. Bocanegra-Martínez et al. (2014) presented an optimization formulation for rainwater harvesting and distribution in households. Garcia-Montoya et al. (2015a) proposed a mathematical model for synthesizing domestic water networks involving greywater recycling, and then, Garcia-Montoya et al. (2015b) incorporated the environmental impact assessment for this approach. Furthermore, Rojas-Torres et al. (2014) reported a multi-period mathematical programming model for the optimal planning of water storage and distribution in a macroscopic system. In addition, for agricultural water management, Raul et al. (2011) presented a simulation model to mitigate the irrigation water deficit in a rice crop system considering groundwater as an alternative source without compromising the resource. Additionally, Arredondo-Ramírez et al. (2015) presented an optimization approach for designing agricultural water networks involving recycling, reusing and regeneration. Previous approaches have identified that is possible to deduce significantly the freshwater consumption in different human activities through water integration techniques.

In addition, several strategies have been reported to solve the water distribution problem. In this context, Oliveira-Esquerre et al. (2011) proposed a method for minimizing the water use considering water reuse and involving geographical and hydrogeological information. Nápoles-Rivera et al. (2013) presented an optimization approach for the sustainable water management for macroscopic systems. Numerous methods for synthesizing interplant water networks based on heuristic rules have been reported. In this context, Foo (2008) implemented a numerical tool to calculate the minimum freshwater in inter-plant integration, and Rubio-Castro et al. (2010) reported a global mathematical programming approach for solving the same problem. Additionally, multi-objective optimization approaches have been proposed by Boix et al. (2012). Moreover, Lopez-Diaz et al. (2015) presented a mathematical model for water integration in eco-industrial parks with the purpose of mitigating the environmental impact of industrial effluents discharged into watersheds. Zhang et al. (2013) presented an approach for the solution of a macroscopic system under uncertainty using reclaimed water as alternative water source. Also, Alnouri et al. (2014) proposed an effective water integration and matching among available water streams using a spatially constrained approach that utilizes the shortest path options. Nevertheless, they did not include different users, water storage and the availability of natural resources. Then, Nápoles-Rivera et al. (2015) considered alternative water sources under parametric uncertainty for the optimal multi-annual water storage and distribution scheduling. It should be noted that the above-mentioned works have not considered the interaction with the surrounding watershed and involving multiple cities.

Furthermore, the proper water management in the watersheds has been recently accounting for. This way, the material flow analysis technique (MFA) has been used to track the chemical species through watersheds. In this context, Baccini and Brunner (1991) developed a MFA model to analyze ecosystems with human activities that exchange mass and energy with their surroundings. Lampert and Brunner (1999) proposed a MFA model to track the major nutrients in the Danube River. Lovelady et al. (2009) reformulated a MFA model to determine the maximum allowable discharges to ensure the sustainability of a watershed. Lira-Barragán et al. (2011) presented an optimization formulation for the proper facility sitting accounting for the water management in the surrounding watershed. Burgara-Montero et al. (2012) proposed an optimization approach to design distributed treatment systems for the effluents discharged to the rivers. In addition, Martinez-Gomez et al. (2013) incorporated safety issues to the industrial wastewater discharges during the synthesis of industrial water networks. López-Villarreal et al. (2014) included the pollution treading in the water management in watersheds.

It should be noted that the above-mentioned works have not considered the simultaneous interaction of the surrounding watershed in the optimization for the use of water in a macroscopic level (see Fig. 2). This interaction is very important because there are several water uses and wastewater discharges that interact with the surrounding watershed; in addition, the implementation of water recycling, reusing and regeneration, as well as storage and the incorporation of rainwater harvesting options affect the surrounding watershed. Furthermore, these aspects also interact with other uses and discharges as well as natural phenomena, which affect drastically the watershed and the final disposal for this water. Therefore, this paper proposes a general mathematical programming model for the sustainable water management in a macroscopic level, which considers the different water uses (industrial, agricultural and domestic) as well as the incorporation of water reusing, recycling, regeneration and rainwater harvesting to determine the effect in the surrounding watershed and in the final disposal. It should be noticed that the addressed problem is too complicated to formulate using the pinch analysis. The environmental assessment in this paper was considered through the pollutants constraints through the watershed, and a single period approach is used.

Fig. 2
figure 2

Problem statement

Problem statement

The addressed problem in this work is described as follows. For a proper use of water in a macroscopic system, different sources of freshwater are given, including ponds and wells with different amounts of available water and changes through the year. Also, there are specific users with given water quality requirements and demands (i.e., residential, gardening, industrial and agriculture), also there are considered the water uses and discharges in the surrounding watershed, which affect specific points in the rivers. Also, the natural phenomena like precipitation, evapotranspiration, filtration and the chemical and biochemical reactions that take place in each section of the river are considered. With all this information, the problem consists in determining the optimum way to satisfy the water demands for agricultural, residential, industrial and gardening uses accounting for the sustainability constraints for the water bodies as well as for the watershed. In this way, several recycling, reusing and regeneration options are considered, in addition to incorporate the rainwater harvesting option. The problem then consists in determining the optimum water network in the macroscopic system to satisfy the water demands at the minimum cost and with the minimum environmental impact. The optimization approach determines the needed units (treatments, storages and pipes) as well as the involved flowrates. The proposed mathematical programming model is general, it is based on the proposed superstructure of Fig. 3, and this can be applied to different case studies with the corresponding data. The major benefits for the presented approach are that it includes the interactions between different water uses and discharges accounting for the surrounding watershed, and the model allows determining water targets before the detailed design. The major drawbacks of the presented model are that it is a steady-state approach and that it does not account for the involved uncertainty for different water sources (i.e., rain) and users. For a future work, it is recommended to propose a proper stochastic optimization approach for handling the involved uncertainty. Next section presents the mathematical model, and the application to a case study is presented in the Case Study section, where the used data are reported or referenced.

Fig. 3
figure 3

Proposed superstructure

Model formulation

This section presents the proposed model formulation, which is general and can be applied to different case studies. First, the used indices are described; hence, t represents the time periods in years, p is any available pond, w is any available well, r represents the reaches, c represents the pollutants in the river, trib represents the tributaries. The complete description of the used symbols is presented in the nomenclature section. The presented model is a similar representation of the typical sources–sinks industrial water networks; the main constraints are associated with the used data to characterize the different water sources and sinks; also in this case, there are several options for water sources (harvested rainwater and reclaimed water) and several forbidden recycling options because of the water quality needed in the sinks, another important point is to characterize the watershed and to model this as a set of reaches. Finally, natural phenomena must be included in the model. Figure 4 shows a general description to yield the mathematical formulation to address this problem. This figure indicates that first it is needed to identify the main water source and sinks. Then, the available treatment technologies are also identified. And the surrounding watershed is also identified and characterized to determine the needed reaches. Then, there are needed water balances for the identified sinks, sources, treatment technologies as well as for the reaches in the watershed. With this information, then the potential units are placed at the superstructure to determine their existence through binary variables. Then, the objective function is determined, and the problem is coded and solved. Then, the proposed model formulation is stated as follows.

Fig. 4
figure 4

Approach to yield the mathematical model

Mass balance for ponds

The used water from any pond p over the time period t (\(F_{p,t}^{\text{pond}}\)) is equal to the water sent for residential use (\(f_{p,t}^{\text{pond-residential}}\)), plus gardening use (\(f_{p,t}^{\text{pond-gardening}}\)), plus industrial use (\(f_{p,t}^{\text{pond-industry}}\)), plus agricultural use (\(f_{p,t}^{\text{pond-agriculture}}\)):

$$F_{p,t}^{\text{pond}} = f_{p,t}^{\text{pond-residential}} + f_{p,t}^{\text{pond-gardening}} + f_{p,t}^{\text{pond-industry}} + f_{p,t}^{\text{pond-agriculture}} ,\quad \forall p,\forall t$$
(1)

Mass balance for wells

The used water from any well w over the time period t (\(F_{w,t}^{\text{well}}\)) is equal to the water sent for residential use (\(f_{w,t}^{\text{well-residential}}\)), plus gardening use (\(f_{w,t}^{\text{well-gardening}}\)), industrial use (\(f_{w,t}^{\text{well-industry}}\)) and agricultural use (\(f_{w,t}^{\text{well-agriculture}}\)):

$$F_{w,t}^{\text{well}} = f_{w,t}^{\text{well-residential}} + f_{w,t}^{\text{well-gardening}} + f_{w,t}^{\text{well-industry}} + f_{w,t}^{\text{well-agriculture}} ,\quad \forall w,\forall t$$
(2)

Rainwater harvesting

There is considered the rainwater harvesting for different uses, including residential, gardening, industrial and agriculture. The mass balance for the rainwater harvesting for different activities is similar and only is presented as an example the one for the case of residential rainwater harvesting as follows. The harvested rainwater over the time period t (\(F_{t}^{\text{rainwater-residential-in}}\)) is equal to the precipitation in that time period (\(R_{t}\)) multiplied by the conditioned area in the residential sector (\(A^{\text{R}}\)):

$$R_{t} \cdot A^{\text{R}} = F_{t}^{\text{rainwater-residential-in}} ,\quad \forall t$$
(3)

Similar relationships are used for gardening (using \(F_{t}^{\text{rainwater-gardening-in}}\), \(R_{t}\) and \(A^{\text{G}}\)), industrial (\(F_{t}^{\text{rainwater-industry-in}}\), \(R_{t}\) and \(A^{\text{I}}\)) and agriculture (\(F_{t}^{\text{rainwater-agriculture-in}}\), \(R_{t}\) and \(A^{\text{A}}\)).

Rainwater storage

The harvested rainwater for the different uses can be stored. For example, the stored rainwater for residential use over a time period t (\(S_{t}^{\text{rainwater-residential}}\)) is equal to the stored rainwater at the end of the previous time period (\(S_{t-1}^{\text{rainwater-residential}}\)), plus the harvested rainwater over the current time period (\(F_{t}^{\text{rainwater-residential-in}}\)), minus the used water for residential purposes (\(F_{t}^{\text{rainwater-residential-out}}\)):

$$S_{t}^{\text{rainwater-residential}} = S_{t-1}^{\text{rainwater-residential}} + F_{t}^{\text{rainwater-residential-in}}-F_{t}^{\text{rainwater-residential-out}} ,\quad \forall t$$
(4)

Similar relationships are used for gardening (\(S_{t}^{\text{rainwater-gardening}}\),\(F_{t}^{\text{rainwater-gardening-in}}\) and \(F_{t}^{\text{rainwater-gardening-out}}\)), industry (\(S_{t}^{\text{rainwater-industry}}\),\(F_{t}^{\text{rainwater-industry-in}}\) and \(F_{t}^{\text{rainwater-industry-out}}\)) and agriculture (\(S_{t}^{\text{rainwater-agriculture}}\),\(F_{t}^{\text{rainwater-agriculture-in}}\) and \(F_{t}^{\text{rainwater-agriculture-out}}\)).

Water use

There are needed water balances for the different uses; for example, the balance for the residential use is stated as follows. The needed water for residential purposes over the time period t (\(F_{t}^{\text{residential}}\)) is satisfied with the one sent from any pond (\(f_{{{\text{p}},t}}^{\text{pond-residential}}\)), plus the one obtained from any well (\(f_{{{\text{w}},t}}^{\text{well-residential}}\)), plus the one obtained from harvested rainwater (\(F_{t}^{\text{rainwater-residential-out}}\)):

$$\sum\limits_{\text{p}} {f_{{{\text{p}},t}}^{\text{pond-residential}} } + \sum\limits_{\text{w}} {f_{{{\text{w}},t}}^{\text{well-residential}} } + F_{t}^{\text{rainwater-residential-out}} = {\text{F}}_{t}^{\text{residential}} ,\quad \forall t$$
(5)

Similar relationships are stated for gardening (\(F_{t}^{\text{gardening}}\), \(f_{{{\text{p}},t}}^{\text{pond-gardening}}\), \(f_{{{\text{w}},t}}^{\text{well-gardening}}\), \({\text{tgw}}_{t}^{\text{gardening}}\), \({\text{TWW}}_{t}^{\text{stored-out}}\)), industrial (\(F_{t}^{\text{industry}}\), \(f_{{{\text{p}},t}}^{\text{pond-industry}}\), \(f_{{{\text{w}},t}}^{\text{well-industry}}\), \(F_{t}^{\text{rainwater-industry-out}}\)) and agricultural (\(F_{t}^{\text{agriculture}}\), \(f_{{{\text{p}},t}}^{\text{pond-agriculture}}\), \(f_{{{\text{w}},t}}^{\text{well-agriculture}}\), \(F_{t}^{\text{rainwater-agriculture-out}}\), \({\text{tgw}}_{t}^{\text{agriculture}}\)) uses.

It should be noticed that the interaction between industry and residential sectors is not allowed because the differences in the involved pollutants and the water quality required in each sector.

Processing of residential water

The used water in the residential sector over the time period t (\(F_{t}^{\text{residential}}\)) is processed in the residences, and part of this water is lost (in this case, the conversion factor \(\alpha^{\text{residential}}\) is used, which can be determined experimentally as was indicated by Garcia-Montoya et al. 2015a), then this used residential water is discharged after a processing time rt as greywater (\({\text{GW}}_{{t + {\text{r}}t}}^{\text{residential}}\)) and black water (\({\text{BW}}_{{t + {\text{r}}t}}^{\text{residential}}\)):

$$F_{t}^{\text{residential}} \cdot \alpha^{\text{residential}} = {\text{GW}}_{{t + {\text{r}}t}}^{\text{residential}} + {\text{BW}}_{{t + {\text{r}}t}}^{\text{residential}} ,\quad \forall t$$
(6)
$${\text{BW}}_{t}^{\text{residential}} = \sigma^{\text{bw-residential}} \cdot {\text{GW}}_{t}^{\text{residential}} ,\quad \forall t$$
(7)

Treating residential greywater

The discharged greywater from residential use over the time period t (\({\text{GW}}_{t}^{\text{residential}}\)) is treated, and part of this water will be available for a further use after the greywater processing time gwt (\({\text{TGW}}_{{t + {\text{gwt}}}}^{\text{residential}}\)) accounting for the conversion factor (\(\beta^{\text{residential-gw}}\)) (see Garcia-Montoya et al. 2015b):

$${\text{GW}}_{t}^{\text{residential}} \cdot \beta^{\text{residential-gw}} = {\text{TGW}}_{{t + {\text{gwt}}}}^{\text{residential}} ,\quad \forall t$$
(8)

It should be noted that the conversion factor \(\beta^{\text{residential-gw}}\) can be determined from experimental reports (see Garcia-Montoya et al. 2015b).

Treating residential black water

The black water discharged from the residential use over the time period t (\({\text{BW}}_{t}^{\text{residential}}\)) is treated accounting for a conversion factor (\(\beta^{\text{residential-bw}}\)), and the treated black water (\({\text{TBW}}_{{t + {\text{bwt}}}}^{\text{residential}}\)) will be available after the black water processing time bwt:

$${\text{BW}}_{t}^{\text{residential}} \cdot \beta^{\text{residential-bw}} = {\text{TBW}}_{{t + {\text{bwt}}}}^{\text{residential}} ,\quad \forall t$$
(9)

The conversion factor for treating black water \(\beta^{\text{residential-bw}}\) can be determined experimentally (Garcia-Montoya et al. 2015b).

Greywater distribution

The treated greywater from residential use over the time period t (\({\text{TGW}}_{t}^{\text{residential}}\)) can be stored for a future use (\({\text{TGW}}_{t}^{\text{stored-in}}\)) or this can be discharged to the environment (\({\text{TGW}}_{t}^{\text{discharge}}\)):

$${\text{TGW}}_{t}^{\text{residential}} = {\text{TGW}}_{t}^{\text{stored-in}} + {\text{TGW}}_{t}^{\text{discharge}} ,\quad \forall t$$
(10)

Storing greywater

The stored greywater at the end of the time period t (\(S_{t}^{\text{GW}}\)) is equal to the stored greywater at the end of the previous time period (\(S_{t-1}^{\text{GW}}\)), plus the treated greywater sent to the storages over the time period (\({\text{TGW}}_{t}^{\text{stored-in}}\)), minus the treated greywater distributed to different uses over the time period (\({\text{TGW}}_{t}^{\text{stored-out}}\)):

$$S_{t}^{\text{GW}} = S_{t-1}^{\text{GW}} + {\text{TGW}}_{t}^{\text{stored-in}}-{\text{TGW}}_{t}^{\text{stored-out}} ,\quad \forall t$$
(11)

Distribution of treated greywater

The treated greywater over the time period t (\({\text{TGW}}_{t}^{\text{stored-out}}\)) can be distributed for gardening (\({\text{tgw}}_{t}^{\text{gardening}}\)) and for agriculture (\({\text{tgw}}_{t}^{\text{agriculture}}\)) as follows:

$${\text{TGW}}_{t}^{\text{stored-out}} = {\text{tgw}}_{t}^{\text{gardening}} + {\text{tgw}}_{t}^{\text{agriculture}} ,\quad \forall t$$
(12)

It should be noticed that the treated greywater must satisfy the environmental norms to use it in gardening and agriculture and to avoid human health problems. This is ensured through the used treatment technologies.

Using industrial water

The industrial water used over the time period t (\(F_{t}^{\text{industry}}\)) is discharged as wastewater (\({\text{WW}}_{t + it}^{\text{industry}}\)) after a processing time it accounting for a conversion factor (\(\alpha^{\text{industry}}\)) as follows:

$$F_{t}^{\text{industry}} \cdot \alpha^{\text{industry}} = WW_{t + it}^{\text{industry}} ,\quad \forall t$$
(13)

Treating industrial wastewater

The industrial wastewater discharged over the time period t (\({\text{WW}}_{t}^{\text{industry}}\)) must be treated accounting for a conversion factor (\(\beta^{\text{industry}}\)) and the corresponding treated industrial wastewater (\({\text{TWW}}_{{t + {\text{wwt}}}}^{\text{industry}}\)) is available after a time period wwt:

$${\text{WW}}_{t}^{\text{industry}} \cdot \beta^{\text{industry}} = {\text{TWW}}_{{t + {\text{wwt}}}}^{\text{industry}} ,\quad \forall t$$
(14)

Distribution of treated industrial wastewater

The treated industrial wastewater can be distributed over the time period t (\({\text{TWW}}_{t}^{\text{industry}}\)) to the storage units (\({\text{TWW}}_{t}^{\text{stored-in}}\)) and discharged to the environment (\({\text{TWW}}_{t}^{\text{industry-discharge}}\)):

$${\text{TWW}}_{t}^{\text{industry}} = {\text{TWW}}_{t}^{\text{stored-in}} + {\text{TWW}}_{t}^{\text{industry-discharge}} ,\quad \forall t$$
(15)

Storing treated industrial wastewater

The stored industrial wastewater at the end of the time period t (\(S_{t}^{\text{industry}}\)) is equal to the one at the end of previous period (\(S_{t-1}^{\text{industry}}\)), plus the inlet treated industrial wastewater (\({\text{TWW}}_{t}^{\text{stored-in}}\)) minus the one distributed (\({\text{TWW}}_{t}^{\text{stored-out}}\)):

$$S_{t}^{\text{industry}} = S_{t-1}^{\text{industry}} + {\text{TWW}}_{t}^{\text{stored-in}}-{\text{TWW}}_{t}^{\text{stored-out}} ,\quad \forall t$$
(16)

Distribution of treated greywater

The total greywater discharged to the environment over the time period t (\({\text{TGW}}_{t}^{\text{discharge}}\)) can be distributed to any reach r (\(\sum\limits_{\text{r}} {{\text{tgw}}_{{{\text{r}},t}}^{\text{discharge-reach}} }\)):

$${\text{TGW}}_{t}^{\text{discharge}} = \sum\limits_{\text{r}} {{\text{tgw}}_{{{\text{r}},t}}^{\text{discharge-reach}} } ,\quad \forall t$$
(17)

It should be noticed that the leakages for the water distribution have not been considered.

Distribution of treated black water

The black water discharged to the environment over the time period t (\({\text{TBW}}_{t}^{\text{discharge}}\)) can be distributed to any reach r (\(\sum\limits_{\text{r}} {{\text{tbw}}_{{{\text{r}},t}}^{\text{discharge-reach}} }\)):

$$TBW_{t}^{residential} = \sum\limits_{r} {tbw_{r,t}^{discharge-reach} } ,\quad \forall t$$
(18)

Distribution of treated industrial wastewater

The treated industrial wastewater that is discharged to the environment over the time period t (\({\text{TWW}}_{t}^{\text{industry-discharge}}\)) can be distributed to any reach (\(\sum\limits_{\text{r}} {{\text{tww}}_{{{\text{r}},t}}^{\text{discharge-reach}} }\)):

$${\text{TWW}}_{t}^{\text{industry-discharge}} = \sum\limits_{\text{r}} {{\text{tww}}_{{{\text{r}},t}}^{\text{discharge-reach}} } ,\quad \forall t$$
(19)

Overall balance for any reach

The watershed is divided in several reaches, accounting for the different water inputs and outputs. The outlet water from the reach r over the time period t (Q r,t ) is equal to the inlet water to this reach (Q r−1,t ), plus precipitation (P r,t ), discharges from tributaries (FTr,trib,t ), direct discharges (D r,t ), residential discharges (H r,t ), additional discharges for treated greywater (\({\text{tgw}}_{{{\text{r}},t}}^{\text{discharge-reach}}\)), treated black water (\({\text{tww}}_{{{\text{r}},t}}^{\text{discharge-reach}}\)), treated industrial discharges minus losses (\(L_{{{\text{r}},t}}\)) and uses (\(V_{{{\text{r}},t}}\)):

$$\begin{aligned} Q_{{{\text{r}},t}} & = Q_{{{\text{r}}-1,t}} + P_{{{\text{r,}}t}} + \sum\limits_{\text{trib}} {{\text{FT}}_{{{\text{r,trib,}}t}} } + D_{{{\text{r,}}t}} + H_{{{\text{r,}}t}} + {\text{tgw}}_{{{\text{r}},t}}^{\text{discharge-reach}} + {\text{tbw}}_{{{\text{r}},t}}^{\text{discharge-reach}} \\ & \quad + {\text{tww}}_{{{\text{r}},t}}^{\text{discharge-reach}}-L_{{{\text{r,}}t}}-V_{{{\text{r}},t}} ,\quad \forall r,\forall t \\ \end{aligned}$$
(20)

Component balance for each reach

The component balance for each reach is determined multiplying the flowrates of Eq. (20) times the corresponding compositions, and including the reactive term (\(k_{c} (X_{{c,{\text{r}},t}}^{\text{reach}} )^{{\sigma_{c} }}\)) to account for the chemical and biochemical reactions that take place in the reach:

$$\begin{aligned} Q_{{{\text{r}},t}} \cdot X_{{c,{\text{r}},t}}^{\text{reach}} & = Q_{{{\text{r}}-1,t}} \cdot X_{{c,{\text{r}}-1,t}}^{\text{reach}} + P_{{{\text{r,}}t}} \cdot X_{{c,{\text{r}},t}}^{\text{p}} + \sum\limits_{\text{trib}} {{\text{FT}}_{{{\text{r,trib,}}t}} \cdot X_{{c , {\text{r,trib,}}t}}^{\text{trib}} } \\ & \quad + D_{{{\text{r}},t}} \cdot X_{{c,{\text{r}},t}}^{D} + H_{{{\text{r}},t}} \cdot X_{{c,{\text{r}},t}}^{H} + {\text{tgw}}_{{{\text{r}},t}}^{\text{discharge-reach}} \cdot X_{{c,{\text{r}},t}}^{\text{tgw}} + {\text{tbw}}_{{{\text{r}},t}}^{\text{discharge-reach}} \cdot X_{{c,{\text{r}},t}}^{\text{tbw}} \\ & \quad + {\text{tww}}_{{{\text{r}},t}}^{\text{discharge-reach}} \cdot X_{{c,{\text{r}},t}}^{\text{tww}}-L_{{{\text{r}},t}} \cdot X_{{c,{\text{r}},t}}^{\text{L}}-V_{{{\text{r}},t}} \cdot X_{{c,{\text{r}},t}}^{\text{V}}-k_{c} (X_{{c,{\text{r}},t}}^{\text{reach}} )^{{\sigma_{c} }} ,\quad \forall c,\forall r,\forall t \\ \end{aligned}$$
(21)

Overall balance for each tributary

The balance for each tributary states that the discharged flowrate from each tributary to the reach r (\({\text{FT}}_{{{\text{r,trib,}}t}}\)) is equal to the one discharged from untreated (\(S_{{{\text{r,trib,}}t}}^{\text{untreated}}\)), treated (\(S_{{{\text{r,trib,}}t}}^{\text{treated}}\)), industrial (\(I_{{{\text{r,trib,}}t}}\)), precipitation (\(P_{{{\text{r,trib,}}t}}\)) and direct discharges (\(D_{{{\text{r,trib,}}t}}\)), minus losses (\(L_{{{\text{r,trib,}}t}}\)) and uses (\(U_{{{\text{r,trib,}}t}}\)) over a given time period:

$${\text{FT}}_{{{\text{r,trib,}}t}} = S_{{{\text{r,trib,}}t}}^{\text{untreated}} + S_{{{\text{r,trib,}}t}}^{\text{treated}} + I_{{{\text{r,trib,}}t}} + P_{{{\text{r,trib,}}t}} + D_{{{\text{r,trib,}}t}}-L_{{{\text{r,trib,}}t}}-U_{{{\text{r,trib,}}t}} ,\quad \forall r,\forall {\text{trib}},\forall t$$
(22)

Component balance for each tributary

The component balance for each tributary accounts for each term of previous relationship multiplying by the corresponding composition and the reactive term for the chemical and biochemical reactions (\(k_{c} (X_{{c,{\text{r}},{\text{trib}},t}}^{T} )^{{\sigma_{c} }}\)) as follow:

$$\begin{aligned} {\text{FT}}_{{{\text{r,trib,}}t}} \cdot X_{{c , {\text{r,trib,}}t}}^{T} & = S_{{{\text{r,trib,}}t}}^{\text{untreated}} \cdot X_{{c , {\text{r,trib,}}t}}^{{{\text{S}}^{\text{u}} }} + S_{{{\text{r,trib,}}t}}^{\text{treated}} \cdot X_{{c , {\text{r,trib,}}t}}^{t} + I_{{{\text{r,trib,}}t}} \cdot X_{{c , {\text{r,trib,}}t}}^{\text{I}} + P_{{{\text{r,trib,}}t}} \cdot X_{{c , {\text{r,trib,}}t}}^{\text{P}} \\ & \quad + D_{{{\text{r,trib,}}t}} \cdot X_{{c , {\text{r,trib,}}t}}^{\text{D}}-{\text{L}}_{{{\text{r,trib,}}t}} \cdot {\text{X}}_{{c , {\text{r,trib,}}t}}^{\text{L}}-U_{{{\text{r,trib}},t}} \cdot X_{{c,{\text{r,trib}},t}}^{\text{U}}-k_{c} (X_{{c , {\text{r,trib,}}t}}^{\text{T}} )^{{\sigma_{c} }} ,\quad \forall c,\forall {\text{trib}},\forall r,\forall t \\ \end{aligned}$$
(23)

Environmental constraints

The pollutant concentrations should be restricted depending on the reach as follows:

$$X_{{c,{\text{r}},t}}^{\text{reach}} \le X_{c}^{\text{reach-mx}} ,\quad \forall c,\forall r,\forall t$$
(24)

Freshwater cost

The freshwater cost (\({\text{Cost}}^{\text{Freshwater}}\)) is equal to the sum of freshwater from any pond (\({\text{UC}}_{{{\text{p,}}t}}^{\text{Fresh-pond}}\) \(F_{{{\text{p}},t}}\)) plus the sum of freshwater from any well (\({\text{UC}}_{{{\text{w,}}t}}^{\text{Fresh-well}}\) \(F_{w,t}\)):

$${\text{Cost}}^{\text{Freshwater}} = \sum\limits_{\text{p}} {\sum\limits_{t} {{\text{UC}}_{{{\text{p,}}t}}^{\text{Fresh-pond}} \cdot F_{{{\text{p}},t}} } + } \sum\limits_{\text{w}} {\sum\limits_{t} {{\text{UC}}_{{{\text{w,}}t}}^{\text{Fresh-well}} \cdot F_{w,t} } }$$
(25)

Rainwater harvesting cost

The rainwater harvesting cost (\({\text{Cost}}^{\text{Rainwater-harvesting}}\)) first accounts for the factor used to annualize the inversion (\(k_{\text{F}}\)), which multiplies the capital costs for conditioning the areas for rainwater harvesting associated with residential (\(a^{\text{AR}} \cdot y^{\text{AR}} + b^{\text{AR}} \cdot (A^{\text{R}} )^{{C^{\text{AR}} }}\)), gardening (\(a^{\text{AG}} \cdot y^{\text{AG}} + b^{\text{AG}} \cdot (A^{\text{G}} )^{{C^{\text{AG}} }}\)), industrial (\(a^{\text{AI}} \cdot y^{\text{AI}} + b^{\text{AI}} \cdot (A^{\text{I}} )^{{C^{\text{AI}} }}\)) and agricultural (\(a^{\text{AA}} \cdot y^{\text{AA}} + b^{\text{AA}} \cdot (A^{\text{A}} )^{{C^{\text{AA}} }}\)) uses:

$$\begin{aligned} {\text{Cost}}^{\text{Rainwater-harvesting}} & = k_{\text{F}} \cdot [a^{\text{AR}} \cdot y^{\text{AR}} + b^{\text{AR}} \cdot (A^{\text{R}} )^{{C^{\text{AR}} }} ] + k_{\text{F}} \cdot [a^{\text{AG}} \cdot y^{\text{AG}} + b^{\text{AG}} \cdot (A^{\text{G}} )^{{C^{\text{AG}} }} ] \\ & \quad + k_{\text{F}} \cdot [a^{\text{AI}} \cdot y^{\text{AI}} + b^{\text{AI}} \cdot (A^{\text{I}} )^{{C^{\text{AI}} }} ] + k_{\text{F}} \cdot [a^{\text{AA}} \cdot y^{\text{AA}} + b^{\text{AA}} \cdot (A^{\text{A}} )^{{C^{\text{AA}} }} ] \\ \end{aligned}$$
(26)

In previous relationship, y corresponds to a binary variable associated with the existence of the required area, whereas a, b and c are unit factors used to account for the capital costs.

Activation of binary variables associated with rainwater harvesting areas

There is needed a constraint to activate the binary variables (y) for conditioning the rainwater harvesting area (A), when this is required, using the maximum available area (\(A^{\text{MAX}}\)) for the different types of uses. For example, for the residential sector this relationship is stated as follows:

$$A^{\text{R}} \le {\text{A}}^{\text{R-MAX}} \cdot y^{\text{AR}}$$
(27)

Similar relationships are needed for gardening, industry and agriculture. It should be noticed that these uses are the ones recommended by the norms for the direct use of harvested rainwater avoiding health problems (SEMARNAT 2014).

Storing rainwater harvesting cost

The capital cost for storing rainwater accounts for the factor used to annualize the inversion (\(k_{\text{F}}\)) multiplied by the cost for storing rainwater for residential (\(a^{\text{SR}} \cdot y^{\text{SR}} + b^{\text{SR}} \cdot (S^{\text{SR}} )^{{C^{\text{SR}} }}\)), gardening (\(a^{\text{SG}} \cdot y^{\text{SG}} + b^{\text{SG}} \cdot (S^{\text{SG}} )^{{C^{\text{SG}} }}\)), industrial (\(a^{\text{SI}} \cdot y^{\text{SI}} + b^{\text{SI}} \cdot (S^{\text{SI}} )^{{C^{\text{SI}} }}\)) and agricultural (\(a^{\text{SA}} \cdot y^{\text{SA}} + b^{\text{SA}} \cdot (S^{\text{SA}} )^{{C^{\text{SA}} }}\)) uses:

$$\begin{aligned} {\text{Cost}}^{\text{Rainwater-storing}} & = k_{\text{F}} \cdot [a^{\text{SR}} \cdot y^{\text{SR}} + b^{\text{SR}} \cdot (S^{\text{SR}} )^{{C^{\text{SR}} }} ] + k_{\text{F}} \cdot [a^{\text{SG}} \cdot y^{\text{SG}} + b^{\text{SG}} \cdot (S^{\text{SG}} )^{{C^{\text{SG}} }} ] \\ & \quad + k_{\text{F}} \cdot [a^{\text{SI}} \cdot y^{\text{SI}} + b^{\text{SI}} \cdot (S^{\text{SI}} )^{{C^{\text{SI}} }} ] + k_{\text{F}} \cdot [a^{\text{SA}} \cdot y^{\text{SA}} + b^{\text{SA}} \cdot (S^{\text{SA}} )^{{C^{\text{SA}} }} ] \\ \end{aligned}$$
(28)

In previous relationship, the constants a, b and c are parameters used in the corresponding capital cost functions (see Bocanegra-Martínez et al. 2014).

Capacity for storing rainwater tanks

There is needed to determine the capacity for the rainwater storage tanks. For example, the capacity for the storage devices for rainwater for residential use (\(S^{\text{SR}}\)) must be greater than the one required in any time period (\(S_{t}^{\text{rainwater-residential}}\)):

$$S^{\text{SR}} \ge S_{t}^{\text{rainwater-residential}} ,\quad \forall t$$
(29)

Similar relationships are needed for the storage devices of harvested rainwater for gardening, industrial and agricultural uses.

Activation of binary variables for storage devices for harvested rainwater

When the capacity of the storage device for harvested rainwater for residential use (\(S^{\text{SR}}\)) is greater than zero, the associated binary variable (\(y^{\text{SR}}\)) must be one, otherwise this binary variable should be zero. This is modeled through the maximum available capacity for the storage device (\({\text{S}}^{\text{SR-MAX}}\)) as follows:

$$S^{\text{SR}} \le {\text{S}}^{\text{SR-MAX}} \cdot y^{\text{SR}}$$
(30)

Similar relationships are needed for the binary variables associated with the existence of the storage devices for harvested rainwater for gardening (\(y^{\text{SG}}\)), industrial (\(y^{\text{SI}}\)) and agricultural (\(y^{\text{SA}}\)) uses.

Wastewater treatment costs

The annual wastewater treatment cost (\({\text{Cost}}^{\text{Treatment}}\)) accounts for the operating cost for treating greywater (\({\text{VC}}^{\text{gwt}} \cdot \sum\limits_{t} {{\text{GW}}_{t}^{\text{residential}} }\)), plus the annualized capital cost for the treatment unit for greywater (\(k_{\text{F}} \cdot [a^{\text{gwt}} \cdot y^{\text{gwt}} + b^{\text{gwt}} \cdot ({\text{GW}}^{\text{res}} )^{{C^{\text{gwt}} }} ]\)), plus the operating costs for treating black water (\({\text{VC}}^{\text{bwt}} \cdot \sum\limits_{t} {{\text{BW}}_{t}^{\text{residential}} }\)) as well as the corresponding capital cost (\(k_{\text{F}} \cdot [a^{\text{bwt}} \cdot y^{\text{bwt}} + b^{\text{bwt}} \cdot ({\text{BW}}^{\text{res}} )^{{C^{\text{bwt}} }} ]\)) and the operating cost for treating industrial wastewater (\({\text{VC}}^{\text{wwt}} \cdot \sum\limits_{t} {{\text{WW}}_{t}^{\text{industry}} }\)) and the corresponding capital cost for the needed units (\(k_{\text{F}} \cdot [a^{\text{wwt}} \cdot y^{\text{wwt}} + b^{\text{wwt}} \cdot ({\text{WW}}^{\text{ind}} )^{{C^{\text{wwt}} }} ]\)):

$$\begin{aligned} {\text{Cost}}^{\text{Treatment}} & = {\text{VC}}^{\text{gwt}} \cdot \sum\limits_{t} {{\text{GW}}_{t}^{\text{residential}} } + k_{\text{F}} \cdot [a^{\text{gwt}} \cdot y^{\text{gwt}} + b^{\text{gwt}} \cdot ({\text{GW}}^{\text{res}} )^{{C^{\text{gwt}} }} ] \\ & \quad + {\text{VC}}^{\text{bwt}} \cdot \sum\limits_{t} {{\text{BW}}_{t}^{\text{residential}} } + k_{\text{F}} \cdot [a^{\text{bwt}} \cdot y^{\text{bwt}} + b^{\text{bwt}} \cdot ({\text{BW}}^{\text{res}} )^{{C^{\text{bwt}} }} ] \\ & \quad + {\text{VC}}^{\text{wwt}} \cdot \sum\limits_{t} {{\text{WW}}_{t}^{\text{industry}} } + k_{\text{F}} \cdot [a^{\text{wwt}} \cdot y^{\text{wwt}} + b^{\text{wwt}} \cdot ({\text{WW}}^{\text{ind}} )^{{C^{\text{wwt}} }} ] \\ \end{aligned}$$
(31)

It should be noted that, in previous relationship, VC corresponds to the unit treatment cost and a, b and c correspond to the factors used to account for the capital costs (see Lira-Barragán et al. 2011). One limitation of the proposed approach is that it does not consider properties such as pH, BOD or toxicity as optimization variables; however, the model considers that the involved treatment technologies are able to satisfy the environmental regulations for these properties.

Capacity for treatment units

The capacity for the treatment unit for greywater (\({\text{GW}}^{\text{res}}\)) must be greater that the greywater processed over any time period (\({\text{GW}}_{t}^{\text{residential}}\)):

$${\text{GW}}^{\text{res}} \ge {\text{GW}}_{t}^{\text{residential}} ,\quad \forall t$$
(32)

which is similar for the capacity for the treatment units for black water (\({\text{BW}}^{\text{res}}\)) and industrial wastewater (\({\text{WW}}^{\text{ind}}\))

Activation of binary variables for treatment units

When the used capacity for the treatment unit is greater than the maximum one available, then the corresponding binary variable must be greater than zero. This way, the binary variable for the existence of the treatment units for greywater (\(y^{\text{gwt}}\)) is modeled as follows:

$${\text{GW}}^{\text{res}} \le {\text{GW}}^{\text{MAX}} \cdot y^{\text{gwt}}$$
(33)

Similar relationships are needed for the existence of the treatment units for treating black water (\(y^{\text{bwt}}\)) and industrial wastewater (\(y^{\text{wwt}}\)).

Cost for storing treated used water

The total cost for storing treated water (\({\text{Cost}}^{\text{Storing-treatedwater}}\)) accounts for the capital costs for storing greywater (\(a^{\text{stgw}} \cdot y^{\text{stgw}} + b^{\text{stgw}} (S^{\text{stgw}} )^{{C^{\text{stgw}} }}\)) and industrial wastewater (\(a^{\text{stww}} \cdot y^{\text{stww}} + b^{\text{stww}} (S^{\text{stww}} )^{{C^{\text{stww}} }}\)):

$${\text{Cost}}^{\text{Storing-treatedwater}} = k_{\text{F}} \cdot [a^{\text{stgw}} \cdot y^{\text{stgw}} + b^{\text{stgw}} (S^{\text{stgw}} )^{{C^{\text{stgw}} }} ] + k_{\text{F}} \cdot [a^{\text{stww}} \cdot y^{\text{stww}} + b^{\text{stww}} (S^{\text{stww}} )^{{C^{\text{stww}} }} ]$$
(34)

where \({\text{k}}_{F}\) corresponds to the annualization factor (see Nápoles-Rivera et al. 2015).

Capacity for storing treated water

The capacity for storing treated greywater (\(S^{\text{stgw}}\)) must be greater than the one needed over any time period (\(S_{t}^{GW}\)):

$$S^{\text{stgw}} \ge S_{t}^{\text{GW}} ,\quad \forall t$$
(35)

Similar relationships are needed for the capacity for storing treated industrial wastewater (\(S^{\text{stww}}\)).

Activation of binary variables for storage devices for treated water

The binary variable associated with the existence of storage devices for treated greywater (\(y^{\text{stgw}}\)) must be activated when the capacity needed (\(S^{\text{stgw}}\)) is greater than zero:

$$S^{\text{stgw}} \le S^{\text{gwMAX}} \cdot y^{\text{stgw}}$$
(36)

The activation for the binary variable associated with the storage device for treated industrial wastewater (\(y^{\text{stww}}\)) is modeled in a similar way.

Piping costs

The total piping cost (\({\text{Cost}}^{\text{piping}}\)) accounts for the pumping costs (\({\text{UPC}} \cdot f\)) and the capital costs (\({\text{ap}} \cdot y + {\text{bp}} \cdot (f^{\text{cap}} )^{C}\)) for the different pipe sections considered, which is modeled as follows:

$$\begin{aligned} {\text{Cost}}^{\text{piping}} & = \sum\limits_{\text{source}} {\sum\limits_{\text{sink}} {\sum\limits_{t} {{\text{UPC}}_{t}^{\text{source-sink}} \cdot f_{t}^{\text{souce-sink}} } } } \\ & \quad + k_{\text{F}} \cdot \sum\limits_{\text{source}} {\sum\limits_{\text{sink}} {[ap^{\text{source-sink}} \cdot y^{\text{source-sink}} + bp^{\text{source-sink}} \cdot (f^{\text{source-sink}} )^{{C^{\text{source-sink}} }} ]} } \\ \end{aligned}$$
(37)

It should be noticed that there are considered the different pipes for the different types of streams considered. Also, the detailed piping network can be designed after the targets can be identified with the proposed approach.

Capacity for pipes

The capacity for the pipe between any pond for residential use (\(f_{\text{p}}^{\text{cap-pond-residential}}\)) must be greater than the one needed over any time period (\(f_{{{\text{p}},t}}^{\text{pond-residential}}\)), which is stated as follow:

$$f_{\text{p}}^{\text{cap-pond-residential}} \ge f_{{{\text{p}},t}}^{\text{pond-residential}} ,\quad \forall p,\forall t$$
(38)

Similar relationships are needed for the other pipe segments.

Activation of binary variables associated with the pipe segments

The binary variable associated with the pipe for the segment pond-residential use (\(y_{\text{p}}^{\text{p-pond-residential}}\)) must be activated when the needed capacity (\(f_{\text{p}}^{\text{cap-pond-residential}}\)) is greater than zero and lower than the maximum available (\(f_{\text{p}}^{\text{pond-res-MAX}}\)):

$$f_{\text{p}}^{\text{cap-pond-residential}} \le f_{\text{p}}^{\text{pond-res-MAX}} \cdot y_{\text{p}}^{\text{p-pond-residential}} ,\quad \forall p$$
(39)

Similar relationships are needed for the other pipe segments.

Total annual cost

The total annual cost (\({\text{TAC}}\)) is equal to the freshwater cost (\({\text{Cost}}^{\text{FreshWater}}\)), plus the rainwater harvesting cost (\({\text{Cost}}^{\text{Rainwater-harvesting}}\)), plus the rainwater storing cost (\({\text{Cost}}^{\text{Rainwater-storing}}\)), plus the treatment cost (\({\text{Cost}}^{\text{Treatment}}\)), plus the piping cost (\({\text{Cost}}^{\text{Piping}}\)), which is stated as follow:

$${\text{TAC}} = {\text{Cost}}^{\text{FreshWater}} + {\text{Cost}}^{\text{Rainwater-harvesting}} + {\text{Cost}}^{\text{Rainwater-storing}} + {\text{Cost}}^{\text{Treatment}} + {\text{Cost}}^{\text{Piping}}$$
(40)

Total freshwater consumption

Total freshwater consumption (\({\text{TotFresh}}\)) is equal to the sum of the used water from any pond p over any time period t (\(F_{p,t}^{\text{pond}}\)), plus the sum of the used water from any well w over any time period t (\(F_{w,t}^{\text{well}}\)):

$${\text{TotFresh}} = \sum\limits_{\text{p}} {\sum\limits_{t} {F_{{{\text{p}},t}}^{\text{pond}} } + } \sum\limits_{\text{w}} {\sum\limits_{t} {F_{{{\text{w,}}t}}^{\text{well}} } }$$
(41)

Objective function

The optimization formulation is stated as a multi-objective mixed-integer nonlinear programming (mo-MINLP) problem, where one objective is the minimization of the total annual cost and the other one is the minimization of the total freshwater consumption subject to the relationships (1–41), which is stated as follows:

$$\begin{aligned} {\text{Objective}}\,{\text{Function}} & = {\text{Min}}\,{\text{TAC}};{\text{Min}}\,{\text{TotFresh}} \\ & \quad {\text{Subject}}\,{\text{to}}\,(1 \text{--} 41) \\ \end{aligned}$$
(42)

Case study

In this paper is considered a case study from the west-central part of Mexico, this corresponds to the Balsas watershed, which is shown in Fig. 5a. This watershed has 770 km of length and 16,587 hm3/year (CONAGUA 2012). The considered watershed discharges to the Lazaro Cardenas region, which is one of the municipalities of the state of Michoacan that is located near to the Pacific Ocean (see Fig. 5b). For the rainfall data, the statistical reports of previous years in the region are considered (CONAGUA 2012).

Fig. 5
figure 5

a Location of the hydrologic region, Balsas River, b Lazaro Cardenas, which is the final discharge for the balsas watershed

The problem consists in finding the optimal distribution of the water management in the macroscopic system that satisfies the water consumption of 5,000,000 m3/year, and the water demands are 83 % for agriculture, 12 % for residential use, 3 % for industrial use and 2 % for gardening. Ponds and wells are used to meet the demands of freshwater in the mentioned scheme; also rainwater harvesting is used, which is distributed to different destinations. The water demand and use in the residential area is divided into greywater and black water, where one part of the greywater is reused for gardening and agricultural use, and the other part is discharged to the river. On the other hand, the treated black water is discharged to the river. The treated industrial wastewater is reused in gardening, and some is discharged to the river. The conversion factor of residential water for losses in the pipeline, evaporation, leaks, etc. is \(\alpha^{\text{residential}}\) = 0.6, and the one for black water from residential use is \(\sigma^{\text{bw-residential}}\) = 0.3. For treating greywater and black water from residential use, the conversion factors are \(\beta^{\text{residential-gw}}\) = 0.7 and \(\beta^{\text{residential-bw}}\) = 0.4, respectively. In the case of wastewater from industrial use, the conversion factor is \(\alpha^{\text{industry}}\) = 0.8 and for treating this water the conversion factor is \(\beta^{\text{industry}}\) = 0.9. For rainwater, it is considered the total area available for collecting. For the case study, the river is divided in 23 reaches, and then, the river flows into a lake. In this case, the time periods are years, and fluctuations through a year are not considered. For the case study, the horizon time is of 20 years and this is used for annualizing the inversion and for the predicted demands and rainfall. The problem to use smaller discretized time periods is associated with the complexity of the model and the probability to find an optimal solution. Additional data used are presented in Table 4 in Appendix. The schematic representation of the addressed problem is shown in Fig. 3. The model was coded in the software GAMS (Brooke et al. 2016), and this consists of 129 binary variables, 4165 continuous variables, 11,940 constraints, and each point of the Pareto curve was solved in a computer with an i7 processor at 3.2 GHz and 12 GB of RAM in 600 s, where the epsilon constraint method was implemented to obtain a set of Pareto solutions. The model corresponds to a Multi-Objective Mixed-Integer Nonlinear Programming problem (mo-MINLP), and the solvers DICOPT with CONOPT and CPLEX were used.

Results

Firstly, the solution for the minimum TAC was obtained (this solution provides the highest freshwater consumption in the Pareto front); then, there is obtained the solution for the minimum freshwater consumption (this solution provides the highest TAC in the Pareto front). Then, a set of constrained solutions for different upper values of the freshwater consumption (between the limits obtained before) and minimizing the TAC are obtained. This approach allows obtaining the Pareto curve shown in Fig. 6. It should be noted that the solutions above this Pareto curve correspond to suboptimal solutions, whereas the solutions below this Pareto curve correspond to infeasible solutions, and the solutions of the Pareto curve are optimal solutions that compensate these two contradicting objectives. Notice in Fig. 7 that the solution of Scenario A corresponds to the minimum TAC, which corresponds to US $686,510,000/year and the costs are primarily associated with pumping costs and the cost of water treatment, as it is shown in Table 1. As an example, for this case is presented in detail the analysis of the economic objective function. First, there are consumed 3952.23 × 103 m3/year of freshwater at a unit cost of $0.6530/m3 for ponds and $0.7314/m3 for wells to yield a freshwater cost of $2,580,806/year. The total harvested rainwater is 754 × 103 m3/year; then, the reclaimed water is 294 × 103 m3/year. There are generated 276.923 × 103 m3/year of greywater, 83.077 × 103 m3/year of black water and 120 × 103 m3/year of wastewater with a unit cost of $176, $180 and $3.5/m3, respectively. Additional results for the Scenario A of the case study are presented in Table 5 in Appendix.

Fig. 6
figure 6

Optimal Pareto solutions for the case study

Fig. 7
figure 7

Solution of Scenario A

Table 1 Results for different Pareto solutions for the case study

The network distribution for the solution of Scenario A is shown in Fig. 7. It should be noticed in this figure that there is used freshwater from pond 1. The total used water comes from ponds (83.9 %) and rainwater harvesting (16.1 %), whereas the total harvested rainwater for this Scenario A is 753.92 × 103 m3 (19.9 % for industrial use, and 80.1 % for agricultural use). Furthermore, the total reused greywater is 193.846 × 103 m3, which is reused mainly for agricultural uses. Furthermore, the treated industrial wastewater is 108 × 103 m3, and 92.6 % of this is reused for gardening. One important point of the proposed approach is that it allows interacting with the surrounding watershed; this is, the solution determines the optimal reach to discharge the different types of wastewater to satisfy the environmental constraints and the interaction with the natural phenomena of filtration, precipitation and chemical and biochemical reactions that take pace in the watershed. In this case, the treated greywater is segregated to discharge to different reaches; similarly the treated black water and industrial wastewater are discharged to different reaches of the watershed. This increases the piping and pumping costs, but it allows a better interaction of the discharges with the phenomena that appear in the watershed to satisfy the environmental constraints.

The solution for the minimum freshwater consumption is shown in Fig. 8; this solution corresponds to Scenario E of Fig. 6. It should be noticed that this solution presents the total used water coming only from ponds (72.5 %), and the rest is from harvested rainwater (27.5 %) While, the harvested rainwater for this Scenario E is 1320.334 × 103 m3 (35.7 % for residential use, 7.2 % for gardening, 11.4 % for industrial use and 45.7 % for agricultural use). Moreover, the total reused greywater is 193.846 × 103 m3 and it is reused for agricultural (100 %) uses. Additionally, the treated industrial wastewater is 108 × 103 m3, where 4.9 % is reused for gardening.

Fig. 8
figure 8

Solution of Scenario E

Comparing the solutions of Scenarios A and E, solution A consumes 13.6 % more freshwater than solution of Scenario E; however, the cost increases 95.6 % from solution A to solution E. On the other hand, the harvested rainwater in Scenario A is 42.9 % lower than the one of Scenario E; however, the reused industrial treated wastewater is 1752.54 % greater in Scenario A with respect to Scenario E.

Furthermore, there are identified attractive solutions such as the ones of Scenarios B, C and D (Figs. 9, 10, 11, respectively). These solutions present a slight difference in the TAC and similar to the solution of Scenario A. The main difference with respect to the solution A is in the harvested rainwater. It should be noted that in all scenarios all the treated greywater is reused. Furthermore, in Scenarios A, B, C and D, the concentration of the different pollutants (nitrogen, sulfur, arsenic) in the flowrate leaving the last reach (i.e., reach 23) is lower than Scenario E.

Fig. 9
figure 9

Solution of Scenario B

Fig. 10
figure 10

Solution of Scenario C

Fig. 11
figure 11

Solution of Scenario D

The results show different concentrations for the pollutants (i.e., nitrogen, sulfur and arsenic) in the flowrate in the final disposal, which corresponds the reach number 23 of the watershed. Noticed that scenarios A to D have the same concentration (1.362 ppm for nitrogen, 0.808 ppm for sulfur and 0.0360 for arsenic); the mean difference is between Scenario A (minimizing TAC) and Scenario E (minimizing TFW). In Scenario E, the pollutant concentrations at the end of the watershed are 1.472 ppm for nitrogen, 0.880 ppm for sulfur and 0.035 for arsenic. For the case when the TAC is minimized, the water consumption is higher and therefore the concentrations of the pollutants nitrogen and sulfur are lower than for the case of minimum TFW. For arsenic, the behavior is different; in this case, the concentration for the minimum TAC is higher than for the case of the minimum TFW.

Furthermore, the proposed approach allows analyzing the concentration of the pollutants through the different sections of the river. In this case, for the case of the minimum TAC, all the treated greywater is reused, whereas the treated black water and industrial wastewater are discharged to a specific reach of the river to save this way in cost associated with pumping (see Table 2). In the case for the minimum TFW, all the treated greywater is also reused, whereas the treated black water remains the same flowrate (32.231 m3 × 103/year), but the distribution is over different reaches of the river. However, treated industrial wastewater is higher (102.650 m3 × 103/year), and it is discharged to different reaches (see Table 3).

Table 2 Results for the distribution of different flowrates of treated wastewater for the case of minimum TAC
Table 3 Results for the distribution of different flowrates of treated wastewater for the case of minimum TFW

Finally, the current situation does not involve the rainwater harvesting and the use of reclaimed water; in this case, the total cost is $858,350,000/year, for Scenario A the cost is decreased 20.0 % but needing an investment of $686,510,000/year. In a similar way, for Scenario E, the total freshwater decreases 30.4 %, but the needed inversion is $14,061,000,000/year.

Conclusions

This paper has presented an optimization formulation for the proper use of water in a macroscopic systems accounting for the interactions with the surrounding watershed. The proposed model incorporates the optimal water management of existing resources and involves the incorporation of alternatives sources as reclaimed water and harvested rainwater. One of the most important contributions presented in the proposed approach is that it involves the interaction with the surrounding watershed through the water uses and discharges and incorporates environmental constraints through the watershed. This way, for a proper interaction of the water management system and the watershed, the proposed optimization formulation has been formulated as a multi-objective optimization approach, and a suited method is proposed to show the results through Pareto optimal solutions that compensate both objectives, allowing this way that the decision maker can take the solution that best satisfies the specific requirements.

A case study from Mexico has been considered for the application of the proposed approach. The results shown through Pareto curves have allowed identifying interesting solutions since the economic and environmental points of view. Also, the importance of considering simultaneously the interactions of the water management system together with the surrounding watershed has been highlighted. Furthermore, the importance to incorporate the pumping cost allows to identify the best compromise between the environmental impact and the total annual cost.

It should be noticed that a future work is needed to include a stochastic analysis for the involved uncertainty in the system. Furthermore, the dynamics about the system should be improved in a future study. Also, the water footprint and other environmental metrics can be included in the study.