text:
# Finding sphere-like topologies in a nonplanar granular graph (help with problem definition)

Update/clarification: I'm looking for an elegant problem definition, not necessarily a solution, so please feel free to answer in that vein. (also check the end for additional clarifications)

NOTE: I am trying to solve a granular physics problem which is fundamentally topological, and should be simple in graph theory if I can get the jargon terms right. However, as it has a geometrical starting point and I am a physicist not a mathematician, I don't even know how to state the problem succinctly. Thus, I am asking for either help stating the problem, in order to be able to research it properly, or known solutions to the problem, if they already exist.

Imagine a pile of spherical grains stacked in a disordered arrangement (in mechanical equilibrium in both force and torque). Which grains are touching which others is a sparse non-planar connectivity graph.

Now imagine being inside this granular structure, but not inside one of the spheres, and looking around. You will be in a cavity (call it a "cell") which is bounded by some grains, but you can see through the gaps in the grains to the adjacent cells. If we replace the grains by their vertices, and contacts points by edges, you can see that you are inside a topologically spherical planar subgraph, and by looking through the loops on the sphere-like surface you can see through to the adjacent cells, which are topologically similar.

Now, what I want to be able to do is to find all such cells from the granular connectivity graph computationally. I can handle defining my graph from a sparse adjacency matrix, and I can handle everything else I need to do once I have the cells as subgraphs, but I need to know what the mathematical names for my cells are ("the set of maximal planar subgraphs" would be a guess, but these wouldn't all be topologically spherical surely?) so that I can find algorithms to compute them, or existing implementations in something like sage.graphs.

This could also be described as a 3D analogue of a dual (the dual graph being the cell centres connected through the grain network's edge loops), although since neither graph is planar this is emphatically not a proper dual; it's just a bit like one conceptually.

I would be grateful for clarification questions in the comments, if you need more information to understand the problem.

UPDATE 2:

I was half way through writing my own answer to this along the lines of 'give up', having concluded that the problem is irreducibly geometrical, and very slow to compute, when I had a revelation which may help reclassify the problem.

Compare a valid granular graph to a random sparse graph with the same average number of edges per vertex (coordination number). If we compute a depth-first search from a random grain $g_i$ along the graphs, and limited the depth of our search to 4 or 5, we would get very different results. In general, the random graph would yield some potentially high fraction of the vertices (this fraction could be estimated, and would presumably be a function of the depth limit and the coordination number) but the granular graph would give us a very small and specific subset of vertices; the ones that were spatially correlated${}^\dagger$.

If the granular graph has some simplifying property, call it spatial correlation, does this simplify the problem for non-spatial analysis? Does this type of graph have a name, and it's own set of simplified results and algorithms? Either would be helpful; intuitively I could see this this helping to simplify the problem algorithmically, and possibly even mathematically.

${}^\dagger$ NOTE: This correlation assumes only small polydispersity; that is, it assumes the grains are of the same order of magnitude of size. Ideally, this would not be a constraint on the analysis, but if it helps make a worse-than-NP-complete problem easier, then it's worth it (finding the cells, or say even the loops on the surface of cells, involves finding all loops and then filtering them in some additional non-trivial calculation.)

Further note, much later:

I am still working on this problem, although it's looking a lot more like a computational hack than a nice piece of mathematics. Even so, I'll post an update answer when I have something to say.

-
I have a feeling this is going to take more than graph theory. For example, if you take a long chain of these cells and consider the corresponding subgraph, it will still be planar. Perhaps what might work better is considering the points that locally maximize the distance to the nearest grain as the centers of the cells. –  Rahul Jul 29 '12 at 11:09
@RahulNarain Lots of irrelevant subgraphs will be planar, it is true, and these multi-cell surfaces will be topologically spherical too. But we should be able to test if they are subdivisible, or something. I appreciate that geometry may have to be reintroduced in order to solve the problem, although we'd have to add 'lengths' to the edges rather than label the cells in advance, as the point of the computation is to discover the cells. Thanks for your comments, they are helpful! PS is 'topologically spherical' the right term to use here? –  tehwalrus Jul 29 '12 at 12:54
So, I'm not sure what exactly is meant by a "cell". Where does one region of space stop being in one cell and start being in another cell? –  Nick Alger Jul 30 '12 at 8:26
My suggestion does attempt to discover the cells. More precisely, I'm proposing to take as input only a set of points in $\mathbb R^3$ (the grain locations), and then "discover" potential cells as the locally largest spheres that do not contain any of the points. But then again, this ignores the connectivity of the graph entirely, so it's probably not what you want. –  Rahul Jul 30 '12 at 8:58
@RahulNarain Ah, I see - sorry, I misunderstood. A colleague actually tried that approach before (or something similar) and it leads to errors and edge cases. –  tehwalrus Jul 30 '12 at 9:44

Approximately, it involves finding the 3D Voronoi and Delaunay tessellations of the pore space (a subspace of $\mathbb{R}^3$,) which is possible only under some constraints, and from there it is possible to deduce (from edge/face intersection between these two dual networks) which are the 'throats,' and by another geometrical test to collapse the tessellating elements into their parents to obtain volume-filling cells and polygonal surfaces representing the throats between them.


text:
Notice: Please give us important feedback on the future of SGN using this survey: https://www.surveymonkey.com/r/VJTRHVC

Clone hba-239g21

 Clone and library
Clone
Clone name
hba-239g21
LE_HBa0239G21
C08HBa0239G21
P239G21
Clone type
BAC
Contamination
none
Estimated length
112,626
Library
Name
Tomato HindIII BAC Library
Cloning host
E. coli
Organism
Solanum lycopersicum (formerly Lycopersicon esculentum)
Cloning vector
Accession
Heinz 1706
Restriction enzyme
HindIII
Ordering Information
BAC Clones
BAC clones can be ordered from the clone ordering page at TFGD
 Physical mapping
 Fingerprint Contig Builds (FPC)
Tomato FPC (AGI 2005)
ctg795 : [coherent], 6 members:
LE_HBa0048O11, C08HBa0152F23, C08HBa0174E16, C08HBa0178C10, C08HBa0198E21, C08HBa0239G21
 Marker matches - overgo what's this?
Conflicted matches
None

 Marker matches - BLAST None
 Marker matches - manual None
 Physical map (from marker matches)
 FISH map Not on FISH map
 FISH images None
 IL Mapping None
 Sequencing
This clone is being sequenced by the Chromosome 8 Sequencing Project. (View projects)
Log in as a curator or sequencer to edit this clone's registry information.
Sequencing Project
Chromosome 8
HTGS phase
none
Sequencing Status
complete
Sequencing Organization
not recorded
Full Sequence
End Sequences
Warnings
none
FTP
Chromosome Assembly
this clone is not part of a chromosome assembly

Restriction Fragments
 HindIII in vitro (31) 1054, 1153, 1315, 1363, 1501, 1549, 1549, 1597, 1673, 1803, 1936, 2046, 2358, 2652, 2853, 3334, 3471, 3631, 3631, 3946, 3946, 3946, 4159, 4565, 4977, 5256, 6948, 7645, 7645, 8337, 10787 HindIII in silico (37) 1052, 1052, 1137, 1137, 1150, 1173, 1254, 1315, 1357, 1498, 1535, 1556, 1602, 1678, 1785, 1922, 2038, 2366, 2665, 2873, 3366, 3490, 3613, 3636, 3692, 3899, 3997, 4008, 4141, 4489, 4792, 4979, 6950, 7649, 7656, 8274, 10452 Fragment Lengths Match Score 0.91
 Annotations
Browse
LE_HBa0239G21 has no browsable sequence annotations

format: plain


text:
# What is the square root of 0.0081?

$0.09$
$\text{note that } 0.0081 = \frac{81}{10000}$
$\sqrt{\frac{81}{10000}} = \frac{\sqrt{81}}{\sqrt{10000}} = \frac{9}{100} = 0.09$


text:
Level 1
Find the circumference of this circle. (Take π = 3.14)
1 m
Level 1
Find the circumference of this circle. (Take π = 3.14)
1 m
Level 1 PSLE
The shaded figure is a semicircle of diameter 40 cm. What is the perimeter of the shaded figure? Take π = 3.14
1 m
Level 1
Find the perimeter of this semicircle. (Take π = 227)
1 m
Level 1
Find the perimeter of this quadrant. Its radius is 4 cm. (Take π = 3.14)
1 m
Level 2
A chain is wrapped round two wheels which has a diameter of 8 m. Line AB is 12 m. Find the length of the chain. (Take π = 3.14)
2 m
Level 2
Find the perimeter of the shaded figure. (Take π = 227)
2 m
Level 2
The figure is made up of an equilateral triangle and a semi-circle of diameter 21 m. Find the perimeter of the figure. (Take π = 227)
2 m
Level 2
The figure is made up of 2 semicircles with diameters 8 cm and 16 cm respectively. What is the perimeter of the figure? (Take π = 227)
2 m
Level 2
The figure is made up of 2 quadrants with radii 16 cm and 8 cm respectively. Find the perimeter of the figure. (Take π = 3.14)
2 m


text:
Thank you for visiting nature.com. You are using a browser version with limited support for CSS. To obtain the best experience, we recommend you use a more up to date browser (or turn off compatibility mode in Internet Explorer). In the meantime, to ensure continued support, we are displaying the site without styles and JavaScript.

# Study on layout optimization of sewage outfalls: a case study of wastewater treatment plants in Xiamen

## Abstract

In order to protect the offshore environment and strengthen the comprehensive rectification of sewage outfalls, an evaluation method of regional sewage outfalls by combining the marine numerical simulation and comprehensive evaluation technology was constructed, considering the marine environmental capacity and the ecological impact of sewage discharge from outfalls on the marine eco-environment sensitive areas. Then the layout rationality of each outfall was evaluated and the discharge scale was optimized with a case study of existing sewage outfalls in Xiamen. The results show that, the comprehensive evaluation score of Yundang outfall was 3 points in 2025, evaluated as the outfall with irrational layout. In 2035, the comprehensive evaluation scores of Fenglin and Dalipu outfalls were 3 and 2 points respectively, evaluated as the outfall with irrational discharge scale. It is suggested to control the scale of expansion or increase the reclaimed water reuse rate in Jimei and Gaoqi Wastewater Treatment Plants. This method has enriched the evaluation system for layout optimization of sewage outfalls, providing scientific supports for comprehensive improvement of sewage outfalls and marine environmental management.

## Introduction

The ocean is the ultimate destination of terrigenous pollutants1. Discharging the domestic sewage and industrial wastewater meeting the discharge standards into the ocean after centralized treatment is an economical strategy to utilize the marine environment and relieve the offshore environmental pressure2,3, which is also one of the main ways of sewage discharge in the coastal areas4. The ocean can treat some pollutants through self-purification capacity. However, due to the constraints on objective factors such as the geographical position, hydrodynamic conditions and physicochemical characterization of pollutants, the marine environmental capacity is limited5, which cannot absorb all the pollutants dicharged into the ocean. The unreasonable layout of sewage outfalls can cause serious environmental problems in the surrounding sea areas4,6.

In recent years, with the acceleration of urbanization process and the rapid development of social economy in the coastal areas, the pollutants directly or indirectly discharged into the sea areas have been increasing. The coastal area has been suffering from the pollutants discharge intensity beyond its self-purification capacity for a long time, leading to the increasing environmental pollution7,8. According to the Report on the State of the Marine Ecological Environment in China in 2019, the environmental quality of the sea areas near the offshore outfalls in China was generally poor, and over 90% of the water quality failed to meet the standard of environmental protection in the marine functional zones. Marine environmental pollution is still the dominant factor that restricts the marine economic development and ecological security9,10.

The model is a useful tool to select and determine the optimal sewage outlet. Foreign scholars calculated the initial dilution ability mainly by adopting the far-field numerical circulation model11, Gaussian-vortex model12, VISFJET13 and near-field pollutant diffusion model CORMIX, which was used as the main reference index for the setting of outfalls. Later, with the development of computers, the three-dimentional models (Delft3D14, EFDC15, Plumes-UM3) were usually used for hydrodynamic coupling with plume models16 to simulate the initial dilution ability and transportation of pollutant discharged from outfalls and select the outfalls. In addition, Minjeong et al.4 predicted the spatiotemporal variation of Escherichia coli and antibiotic resistance genes with different locations based on the EFDC model, thereby determining the effective design of marine outfalls.

With the construction of the coastal city sewage discharge project, the research on the selection and planning of the sewage outfalls began in the mid-1990s in China. The research methods generally include the numerical simulation model and comprehensive index system. Firstly, the numerical calculation method is used to simulate the influence of hydrodynamic environment, and then select the best discharge scheme. For example, the particle movement trajectory was simulated by the Lagrange particle tracking model17,18. The influence range of pollutants was calculated by the pollutant diffusion model19,20. The optimization position was determined by comparing the distance of particle trajectory, the extent of pollutant diffusion and/or the environment capacity21,22,23. The marine hydrodynamic factors have been fully taken into consideration in the numerical method, which is in agreement with the actual situation of marine pollutant diffusion. However, other factors such as engineering cost were ignored in the selection of location. Secondly, the comprehensive index system was established to determine the best one by ranking the comprehensive score of different discharge outfalls. For example, the range of COD pollutant area, the sediment change and engineering cost were considered as the indicators in the study of Yangkou Port sewage site selection24. Additional indicator system also includes the aspects of environment (mixing zone area25, environmental capacity26, self-purification capacity27, the distance from marine eco-environment sensitive area), natural conditions (topographic slope, geomorphological features)28. The index system method considered comprehensive indictors to evaluate the sewage outfall. However, the obvious disadvantage of this method is high requirement for basic data and poor practicability due to the complexity of the evaluation system29.

In the whole, the previous studies mainly focused on the selection and planning sewage outfalls for a new specific sewage discharge project to determine the best one. There is a lack of research on the resonable evaluation of the existing outfalls and optimization of the future discharge scale from the regional perspective30. In order to fully promote the construction of marine ecological civilization demonstration zone31,32, advance the rational utilization of sea area environmental capacity and the harmonious development of marine economy, a optimization evaluation method of regional sewage outfalls by combining the marine numerical simulation and comprehensive evaluation technology was constructed to evaluate the reasonableness location and optimize discharge scale of the existing outfalls. This study not only can effectively deal with terrigenous pollutants and reduce environmental pollution, but also can effectively reduce the risk of marine ecological environment33, which can provide decision support for the management of sewage outlet into the sea and Marine environmental protection.

## Study areas and methods

### Study areas

Located in the southeast of Fujian Province, Xiamen Bay (XMB) is surrounded by islands such as Jinmen, Dadan, Erdan and Wuyu islands, all of which form into a natural barrier (Figs. 1, 2). XMB has a tortuous coastline with a total length of 194 km and a sea area of 390 km2. As a major Rare Marine Species National Nature Reserve with the Chinese White Dolphin, Lancelet and Egret wild animals, XMB is a semi-closed bay of great conservation value.

By 2020, there have been 5 wastewater treatment plants in Xiamen that directly discharged waster water into the sea, with a total discharge scale of 7.0 × 105 t/d. The scale and discharge area of each wastewater plant are shown in Table 1 and Fig. 2. According to Study on Layout of Wastewater Treatment Plants and Treatment System Planning in Xiamen, Haicang, Qianpu, Jimei and Aotou wastewater plants will be expanded respectively. Meanwhile, Gaoqi plant is under construction. In the future, the total discharge scale will be increased from 1.43 × 106 t/d in 2025 to 2.50 × 106 t/d in 2035. With the development of Xiamen economy and the gradual improvement of sewage collection system, the amount of sewage entering the wastewater treatment plant has been increasing. Meanwhile, the remediation and management of sewage outlet into the sea has become the focus of environmental protection work at present in Xiamen. Therefore, the rationality of existing sewage outfalls layout and the optimization of the future discharge scale have become an urgent problem for each wastewater treatment plant in Xiamen.

### Evaluation methods

#### Principles of the evaluation system construction

It is important to establish a set of scientific and feasible evaluation index system for optimization of sewage outfalls. It is clearly stated in the Article 30 of the Marine Environment Protection Law of the People's Republic of China that, “the location of sewage outfalls shall be selected according to the marine functional zoning, seawater hydrodynamic conditions and relevant regulations”; “no new sewage outfalls shall be built in special protection areas such as the marine nature reserves, key fisheries areas and seaside scenic areas.” The principles of evaluation system construction should include:

1. (1)

Conform with the regulations, laws and the marine function zoning;

2. (2)

Good hydrodynamic conditions and strong self-cleaning ability;

3. (3)

The ecological impact of the sea area near the sewage outfalls should be reduced as far as possible;

4. (4)

Engineering feasibility and low construction cost.

Based on the above four principles and the objective of this study, we built in the optimization evaluation index system from the aspect of the hydrodynamic conditions and the ecological impact on the marine environment.

#### Selection of evaluation indicators

The evalation indicators were divided into two dimensions, which concluded the hydrodynamic conditions indicator and the ecological impact indicator on the marine environment.

1. (1)

Hydrodynamic conditions indicator

Terrigenous pollutants will transport and diffuse with the movement of seawater after being discharged into the sea. The diffusion mainly depends on the hydrodynamic conditions of the sea area near the sewage outfall. If the sea area near the sewage outfall has poor hydrodynamic conditions and water exchange capacity, pollutants will accumulate near the outfall, aggravating the pollution of the local sea areas and causing a series of marine ecological security problems33. Environmental capacity is a quantitative description of the comprehensive self-purification capacity of the sea area34. Rational use of environmental capacity not only can effectively protect the water quality, but also can make the utmost of the dilution and self-purification capacity of the sea area. Therefore, the environmental capacity utilization was selected as the indictor to judge the hydrodynamic environment of the sea area.

1. (2)

Ecological impact indicator

Marine eco-environmental sensitive area refers to the high value sea areas that are difficult to restore after the ecological service function are damaged. They mainly include special protection areas such as the natural reserves, natural concentrated distribution areas for rare and endangered marine life and key fisheries areas, which are relatively sensitive to pollutants discharged. The location of outfalls must be away from the marine ecological sensitive areas. The ecological impact index was selected to evaluate the impact on marine eco-environmental sensitive areas.

#### Calculation and criteria of evaluation indicators

The evaluation indicators were compluted by the hydrodynamics-water quality model.

1. (1)

Environmental capacity utilization

Environmental capacity defines as the maximum pollutant load that can be received under the requirements of the water quality standards near the sewage outfall. With the water quality control objective as constraints, the environmental capacity of each outfall was calculated based on the water quality model and response coefficient linear programming method.

The 3D convection–diffusion transport equation of pollutants (Eq. 1) is a linear equation, which makes the pollutant concentration field in the target sea area meet the superposition principle.

$$\frac{\partial C}{\partial t}+\frac{\partial }{\partial x}(uc)+\frac{\partial }{\partial y}(vc)+\frac{\partial }{\partial z}(wc)=\frac{\partial }{\partial x}({D}_{x}\frac{\partial C}{\partial x})+\frac{\partial }{\partial y}({D}_{y}\frac{\partial C}{\partial y})+\frac{\partial }{\partial z}({D}_{z}\frac{\partial C}{\partial z})+Q$$
(1)

where C is the concentration of a dissolved pollutant, u, v, and w are velocity components, Dx, Dy, and Dz are the diffusion coefficients in the x-, y-, and z-directions, respectively, Q is a source or sink term; and t represents time.

Therefore, in the seawater of the target sea area, it is assumed that the background concentration field formed by the non-point source pollutants and the pollutants input from outside the bay is $$C_{0} (x,y,z)$$, the pollutant concentration distribution field formed due to the combined action of multiple pollution sources $$C(x,y,z)$$ shall be equal to the linear superposition of the concentration distribution field formed due to the single action of each pollution source $${C}_{i}(x,y,z)$$:

$$C(x,y,z)={C}_{0}(x,y,z)+{\sum }_{i=1}^{n}{C}_{i}(x,y,z)$$
(2)

The concentration field formed due to the single action of the i pollution source meets:

$${C}_{i}(x,y,z)={\alpha }_{i}(x,y,z)\cdot {Q}_{i}$$
(3)

where $${Q}_{i}$$ is the intensity of i pollution source; $${\alpha }_{i}(x,y,z)$$ is a response coefficient field, associated with hydrodynamic condition, topography, etc. The response coefficient is equivalent to the equilibrium concentration field formed by unit source intensity5.

The calculation of the maximum allowable quantity of pollutant discharged from outfall can be expressed as the following linear programming problems35:

$${Q}_{i}=({C}_{i}^{s}-{C}_{i}^{0})/{\alpha }_{i}$$
(4)

where $${Q}_{i}$$ is the maximum allowable quantity of i pollution source, that is the environmental capacity of i pollution source; $${C}_{i}^{0}$$ is the background concentration at the control point, $${C}_{i}^{s}$$ is the target concentration of water quality at the control point, and $${\alpha }_{i}$$ is the response coefficient.

The environmental capacity utilization (E) was defined as the ratio of the current discharge scale to the environmental capacity of sewage outlet, which can better sort and class the utilization characteristics of marine environmental capacity of each outfall. The formula is calculated as follow:

$$E=\frac{{Q}_{i}^{s}}{{Q}_{i}}\times 100\%$$
(5)

where $${Q}_{i}$$ is the environmental capacity of i pollution source ; $${Q}_{i}^{s}$$ is discharge quantity of i pollution source .

The environmental capacity represents the maximum allowable quantity of pollutant discharged from outfall. E is greater than 100%, indicating that the excess pollutants were not accommodated in the area surrounding discharge outfall. At this time, the hydrodynamics condition grade is defined as weak and the score ($${E}_{s}$$) is assigned to 1. At E was less than 100%, it can be divided into three grades in each partition, namely strong, relatively strong and relatively weak. The hydrodynamic conditions indicator and scoring criteria was shown in Table 2.

1. (2)

Ecological impact index

The ecological impact index (R) was defined as the ratio of the simulation concentration to the target concentration of water quality at the marine eco-environment sensitive area. The formula is calculated as follow:

$$R=\frac{{C}^{p}}{{C}^{s}}\times 100\%$$
(6)

where $${C}^{p}$$ is the simulation concentration on the marine eco-environment sensitive area based on the 3D water quality model, $${C}^{s}$$ is the target concentration of water quality at the marine eco-environment sensitive area.

The discharge pollutants should not damage the Marine eco-environmental sensitive area. R is greater than 100%, suggesting that impact is very large and the ecological impact score ($${R}_{s}$$) is assigned to 1. In order to sort the impact of each sewage, the ecological impact index was divided into four grades ranked from strong to weak according to the percentage. The indicator and criteria of ecological impact on marine eco-environmental sensitive areas are shown in Table 3.

#### Comprehensive evaluation

The hydrodynamic condition is as important as the ecological impact from the perspective of marine environmental protection and pollution control. Therefore, two indicators have the same weight when evaluating the layout optimization of sewage outfalls. The comprehensive score (S) was defined as the sum with the score of environmental capacity utilization and ecological impact index in order to evaluate the layout and optimize discharge scale of sewage outfalls. The formula is calculated as follow:

$$S = E_{s} + R_{s}$$
(7)

The optimization objectives are to ensure that there is enough environmental capacity near the outfall to contain pollutants and the discharged sewage should not affect the water quality of the surrounding ecologically sensitive areas. Both of these conditions are indispensable, the comprehensive evaluation scoring criteria for the layout optimization of sewage outfalls was determined. When S ≤ 3, the discharge outlet is defined as irrational. In contrary, when S > 3, the discharge outlet is defined as rational. The comprehensive evaluation criteria is shown in Table 4.

### Hydrodynamic-water quality model

In this paper, a 3D hydrodynmic-water quality model for XMB was established by adopting the MIKE3 hydrodynamic module and water quality module. MIKE3 is professional engineering software used to simulate hydrodynamics, water quality and sediment. With advanced pre-processing and post-processing functions and friendly user interface, MIKE3 has been widely applied in studies on estuary, coast and marine36. The unstructured triangular mesh was used in XMB model and the mesh was encrypted near the outfall. The number of horizontal meshes was 7,002 and the total number of mesh points was 12,412. The maximum resolution of the mesh was 1.5 km, and the minimum resolution near the outfall was 30 m. The XMB model was divided into five layers by a vertical sigma coordinate system, while the bottom friction coefficient was set 0.01. According the CFL condition and the topography, the time step and the dry–wet critical depth was choose 10 s and 0.1 m, respectively. The XMB topography was shown in Fig. 1.

The model has two open boundaries, the southern boundary and the eastern boundary,which were controlled with the predicted tidal elevation calculated by 11 tidal components (M2、S2、N2、K2、K1、O1、Q1、P1、M4、MS4 and M6). The data of Jiulong River and other rivers were obtained from the average monthly flow rate in 2018 as the runoff boundary conditions.

In the water quality model, the pollution sources discharged into the sea were generally divided into 17 direct point sources and 11 river pollution sources. The sources locations were shown in Fig. 1. The pollutant loads data were obtained from the 2018 monitoring land-based pollutant sources into the sea measured by the Ocean and Fisheries Bureau of Xiamen (http://www.hyj.xm.gov.cn/Ocean/Index.aspx). Biochemical reaction process of pollutants was not considered in water quality model.

## Results

### Model verification

The model verification data are obtained from the hydrodynamic monitoring conducted by the Third Institute of Oceanography during the spring tide from November 24 to 25 in 2018, with one tidal elevation station and six tidal current stations (see Fig. 1 for location). Figure 3 shows a verification curve for the tide gauge station of Xiamen Wutong Port. The root mean square error (RMSE) was used for model performance. The comparison between the calculated and the measured tidal level shows that the calculated level agreed with the measured level well. The RMSE of the tidal elevation was 0.17 m, which can better reflect the changing process of the tidal level in XMB. Figure 4 shows the verification results of velocity and direction during the spring tide. The RMSE of the current and direction ranged 0.05–0.07 m and 7.57°–9.52°, respectively. As we seen from the figure that the simulation results of most observation station agreed with the measured values, and the flow regime of each station shows obvious rectilinear current, indicating that the model can better simulate the change of tidal current movement in this area and provide hydrodynamic driving conditions for the water quality model.

The 2018 survey data from the monitoring report on trend of marine environment quality in coastal area Xiamen measured by the Ocean and Fisheries Bureau of Xiamen was used to validated the water quality model. The duration time running the model is about one year. Chemical oxygen demand (COD), dissolved inorganic nitrogen (DIN) and active phosphate (AP) were simulated as independent components in the water quality model. The comparsion between the model results and the observation values was shown in Table 5 (the stations see Fig. 1). The relative error (RE) of COD, DIN and AP ranged from 2.83–10.91%, 3.85–16.18%, 3.70–17.86%. Their average relative error is 6.72%, 10.44% and 9.68%, respectively. The model error is mainly caused by the inaccuracy of pollution load and the model coefficient. Although there are some errors in the model, the observed values are overall in good agreement with the simulated values.

### Results of environmental capacity utilization

According to 2020 Xiamen Ecological Enviromental Quality Bulletin37, the compliance rate of the functional areas was 70.0%, suggesting slightly eutrophicated in this area. The major pollutants in seawater were AP and DIN, which exceeded the second degree of Sea Water Quality Standards. Therefore, COD was selected as the calculation index of environmental capacity in this study. The water quality target value was constrained by the standard value given in the Environmental Function Zoning in Offshore Areas in Fujian Province (Revised) (2011–2020). The environmental capacity utilization (E) of each sewage outfalls was calculated with the model and Eqs. (2)–(5), and the results were shown in Table 6. As we can be seen from Table 6 that:

1. (1)

Shizhoutou outfall faces the open sea and has the best hydrodynamic conditions with the maximum COD environmental capacity of 16.4 t/d. Located at the mouth of the bay, Aotou, Chakouyang and Houyu outfalls have good hydrodynamic conditions and large environmental capacity. Due to the location in Tong’an Bay interior, Fenglin outfall has the weakest hydrodynamic condition with the minimum environmental capacity of 2.16 t/d.

2. (2)

In 2025, the environmental capacity utilization of Yundang, Shizhoutou, Fenglin and Dalipu outfalls were 61.22%, 60.98%, 83.33% and 66.67% respectively, indicating that there is still a certain pollutant carrying space in these areas. The environmental capacity utilization of Chakouyang and Aotou outfalls was 35.71% and 10.53% respectively, indicating that there is still a large pollutant carrying space in these areas.

3. (3)

In 2035, the discharge scale of Haicang and Aotou Wastewater Treatment Plants were expanded, and the environmental capacity utilization was 71.43% and 72.37% respectively. There is still certain pollutant carrying space in the sea areas near the two outfalls. With the expansion of Jimei and Gaoqi Wastewater Treatment Plants, the environmental capacity utilization was 138.89% and 166.67% respectively, exceeding the pollutant carrying capacity of the sea areas. Pollutants will gather near the two outfalls, causing some pollution to these sea areas.

### Results of ecological impact index

The ecological sensitive areas of marine environment in Xiamen include the Chinese White Dolphin Nature Reserve (CWDNR) in West Sea and Tong’an Bay estuary, the Egret Nature Reserve (ENR) in Jiyu and Dayu, the Lancelet Nature Reserve (LNR) in Huangcuo area (see Fig. 2 for location ). The water quality target in marine ecological sensitive area implement the first degree of Sea Water Quality Standards according the Environmental Function Zoning in Offshore Areas in Fujian Province (Revised) (2011–2020). The maximum concentration and the ecological impact index were calculated by the water quality model for XMB. The results are shown in Table 7.

The sewage discharged from Houyu outfall would affect the CWDNR in West Sea area. In 2025 and 2035, the ecological impact index will be 125%, which is very significant. This is mainly caused by that the outfall is located in the CWDNR (West Sea).

The sewage discharged from Chakouyang outfall would affect the ENR in Jiyu. In 2025 and 2035, the discharge scale of Yundang plant will be expanded from 20 × 104 to 40 × 104 t/d, and the ecological impact index will be from 68.5 to 72%, with a relatively large impact on the environment.

The sewage discharged from Shizhoutou outfall would affect LNR of Huangcuo sea area. In 2025 and 2035, the discharge scale of Qianpu plant will be expanded to 50 × 104 t/d, and the ecological impact index will be 95.5%. As the distance between the outfall and Lancelet Nature Reserve is about 200 m, with a relatively large impact on the ecological environment.

The sewage discharged from Aotou outfall would affect CWDNR in Tong’an Bay estuary. In 2025, the discharge sacle of Aoto plant will be expanded from 8 × 104 to 55 × 104 t/d, and the ecological impact index will increase from 48 to 74.5%, with a relatively impact on the environment.

The sewage discharged from Dalipu outfall would affect CWDNR in Tong’an Bay estuary. In 2025 and 2035, the discharge scale will be expanded from 20 × 104 to 50 × 104 t/d, and the ecological impact index will be increase from 86.5 to 112%. In 2035, it will have a relatively large ecological impact on the marine environment sensitive area.

### Results of comprehensive evaluation

According to the resuls of environmental capacity utilization and ecological impact index, the comprehensive evaluation results of each sewage outfalls in 2025 and 2035 were calculated, which showed in Tables 8 and 9.

As can be seen from Table 8, in 2025, Yundang outfall is located in the middle of Xiamen’s West Sea area, Es is assigned to 2 points when E is 61.22%. Rs is assigned to 1 point when R is 125%. The comprehensive evaluation score is calculated to 3 points, evaluated as the sewage outfall with irrational layout. In 2025, the comprehensive score is 5 points for Chakouyang outfall, 4 points for the comprehensive score of Shizhoutou, Fenglin and Dalipu outfalls, and 7 points for Aotou outfall. They are all evaluated as the outfalls with relatively rational layout.

As can be seen from Table 9, in 2035, Es of Shizhoutou outfall is assigned to 2 points when E reaches 60.98%, and Rs is assigned to 2 points when R is 95.5%, then the comprehensive evaluation score is 4 points, evaluated as the outfall with relatively rational layout. The discharge scale from Fenglin outfall will be increased to 25 × 104 t/d, and E will reach 138.89%, which will exceed its environmental capacity. The comprehensive evaluation score of the Fenglin outfall is 3 points, evaluated as the outfall with irrational outlay. According to the value of E and R, Es and Rs of Dalipu outfall were assigned to 1 point, indicating that the discharge scale would far exceed its environmental capacity and have a large impact on the environment of CWDNR at Tong’an Bay estuary. The comprehensive evaluation score of the Dalipu outfall is 2 points, evaluated as the irrational outfall. In 2035, the comprehensive score of Chakouyang and Aotou outfalls will be 4 points, evaluated as the outfalls with relatively rational layout.

## Discussion and optimization scheme

### Optimization scheme

According to the evaluation results of the layout of sewage outfalls in Xiamen, the following optimization conclusions are proposed:

1. (1)

Houyu outfall was evaluated as the outfall with irrational layout comprehensively because it is located in the CWDNR of West Sea area with a relatively large impact on the marine sensitive area. Houyu outfall built in 1997 before the establishment of the marine nature reserve. Considering the hydrodynamic conditions and the ecological sensitivity characteristics of the area, Yundang Wastewater Treatment Plant will remain its treatment capacity unchanged, 30 × 104 t/d. It is suggested to increase the reclaimed water reuse rate or improve the standard in order to reduce the total quantity of pollutant discharged into the West Sea.

2. (2)

The Fenglin outfall of Jimei Wastewater Treatment Plant is shallow in depth and has poor hydrodynamic conditions, which can accommodate the maximum sewage discharge scale of 18 × 104 t/d. When the discharge scale will increase to 25 × 104 t/d in 2035, it will exceed its environmental capacity and affect the environmental quality of surrounding sea areas. It is comprehensively evaluated as the irrational outfall due to the large discharge scale, suggesting to control the discharge scale at 18 × 104 t/d in 2035 or improve the reclaimed water reuse rate.

3. (3)

The maximum allowable discharge scale of Dalipu outfall of Gaoqi Wastewater Treatment Plant is 30 × 104 t/d. The discharge scale in 2035 will increase to 50 × 104 t/d, which will exceed its environmental capacity and affect the CWDNR of Tong’an Bay estuary. It is proposed that the discharge scale should be controlled at 30 × 104 t/d in 2035, or the discharge standard should be improved, or the reclaimed water reuse rate should be improve by adopting the reconstruction scheme.

### The indicator system

The location of sewage plant outfalls in coastal area is related to the environmental and economic factors according to the actual situation. It is very challenge to construct a comprehensive indicator system that can reflect the current conditions of the optimization selection model. Considering the principle of covering major factors, the construction of the index system focuses on the environmental condition and impact convenience in data availability and in operation. Due to the optimization of existing sewage outfall, the economic conditions were ignored. Through comparing the comprehensive index scores of different sewage outlets, the reasonableness and discharge scale of the sewage outlet were evaluated and optimized, which can provide the guidelines for management decision makers.

It is most important to determine the evaluation criteria and quantify the weight for the indicators in the optimization process after construction of evaluation indicator system. The hydrodynamic condition and the impact on the marine eco-environment sensitive are the same weight, and regarding the same importance of the optimization model. The environmental capacity and the ecological impact are considered the most important standards for the pollution management of sewage outlets into the sea, which is consistent with previous studies8,23.

At present, the pollution of China's coastal waters is serious, and the improvement and protection of the sewage outlet into the sea has become a key point of the environmental protection work. The research hot is how to select the appropriate scheme and optimize the existing sewage outlet from a regional perspective. The optimization of sewage outlet involves environmental management issues of environmental, social, economic and other factors. How to make a decision among these often-conflicting attributes is a difficult process. In this study, the evaluation index system is constructed based on the most important Hydrodynamic index and environmental impact factors of the existing sewage outlet. And the optimization of the sewage outlet is carried out by combining with the mathematical model. Although there are some limitations in index selection and index classification in this study, it provides scientific support for the improvement and optimization of the existing sewage outlet.

### The simulation model

A 3D model of hydrodynamics and water quality in XMB was built to calculate the evaluation index values and optimize the sewage outfalls. The time-series observed data of surface elevation and current were compared and analyzed. The water quality state variables such as COD, DIN and AP were also validated in the water quality model.

The environmental capacity utilization and ecological impact index were calculated based on the validated model. The results show that the model can well simulate the transport and diffusion of pollutants in XMB and provide data support for the evaluation system of sewage outlet.

The water quality model in this study simulates COD, DIN and AP as separate variables without considering the biochemical reaction process to evaluate the impact of hydrodynamic conditions and pollutant diffusion on the ecological environment. In subsequent studies, a three-dimensional eutrophication model will be established to simulate the change process among various elements and improve the simulation accuracy. Because the current situation of nitrogen and phosphorus pollutants in XMB exceeds the standard seriously, the environmental capacity of COD was only considered in this study. Indeed, the multiple pollutants should be selected as far as possible for evaluation when this model applied in other marine areas.

## Conclusions

In this paper, from the perspective of marine environmental protection and pollution control in offshore areas, an evaluation method for the layout optimization of sewage outfalls was established. Based on the marine numerical simulation and comprehensive evaluation technology, the rationality of the layout of sewage outfalls was comprehensively evaluated by considering the hydrodynamic conditions and the ecological impact on the marine eco-environment sensitive area.

The layout rationality was evaluated and the discharge scale was optimized with a case study of existing sewage outfalls in Xiamen based on the established method. The results show that, the comprehensive evaluation score of Yundang outfall in 2025 is 3 points, evaluated as the outfall with irrational layout. The comprehensive evaluation scores of Fenglin and Dalipu outfalls are 3 and 2 points respectively in 2035, evaluated as the outfalls with irrational discharge scale. It is suggested to control the discharge scale or increase the reclaimed water reuse rate.

The method for evaluation of layout rationality of sewage outfalls established in this paper takes improvement and protection of the marine environment as its primary objective. Based on the numerical simulation and comprehensive evaluation method, an outfall layout optimization scheme was proposed by combining the local improvement of sewage outfalls layout and the regional sewage discharge scale optimization, providing scientific supports for marine environment management and layout optimization of outfalls. This method focuses on the factors affecting the marine environment. However, it ignores the impact of other factors such as the biological effects (for example, Escherichia coli) and project risk of engineering construction, which has certain limitations. In order to meet the requirements of marine governance and management of outfalls in the future, it is necessary to improve the index system and evaluation method established in this paper, so as to make them more operable in practice.

## References

1. 1.

Muhammetoglu, A., Yalcin, O. B. & Ozcan, T. Prediction of wastewater dilution and indicator bacteria concentrations for marine outfall systems. Mar. Environ. Res. 78, 53–63 (2012).

2. 2.

Bedri, Z. et al. Assessing the water quality response to an alternative sewage disposal strategy at bathing sites on the east coast of Ireland. Mar. Pollut. Bull. 91, 330–346 (2015).

3. 3.

Law, A. W. K. & Tang, C. Industrial water treatment and industrial marine outfalls: Achieving the right balance. Front. Chem. Sci. Eng. 10, 472–479 (2016).

4. 4.

Minjeong, K. et al. Designing a marine outfall to reduce microbial risk on a recreational beach: Field experiment and modeling. J. Hazard. Mater. 409, 124587 (2021).

5. 5.

Xia, H. Y., Li, X. L. & Han, K. Studies on the environmental capacity of the Dapeng Bay, Part II: Total load allocation and water quality planning. China Environ. Sci. 31(12), 2039–2045 (2011).

6. 6.

Roth, F., Lessa, G. C., Wild, C., Kikuchi, R. K. P. & Naumann, M. S. Impacts of a high-discharge submarine sewage outfall on water quality in the Coastal Zone of Salvador (Bahia, Brazil). Mar. Pollut. Bull. 106(1), 43–48 (2016).

7. 7.

Liu, W. C., Kuo, J. T., Young, C. C. & Wu, M. C. Evaluation of marine outfall with three-dimensional hydrodynamic and water quality modeling. Environ. Model. Assess. 12, 201–211 (2007).

8. 8.

Li, Y. et al. Multi-criteria evaluation method for site selection of industrial wastewater discharge in coastal regions. J. Clean. Prod. 161, 1143–1152 (2017).

9. 9.

Vikas, M. & Dwarakish, G. S. Coastal pollution: A review. Aquat. Procedia 4, 381–388 (2015).

10. 10.

Jiang, S. S. & Li, J. M. Do political promotion incentive and fiscal incentive of local governments matter for the marine environmental pollution? Evidence from China’s coastal areas. Mar. Policy 128, 104505 (2021).

11. 11.

Blumberg, A. F., Ji, Z. G. & Ziegler, C. K. Modeling outfall plume behavior using far field circulation model. J. Hydraul. Eng. 112(11), 610–616 (1996).

12. 12.

Lee, J. & Seo, I. W. Numerical simulation of advected thermal using Gaussian-vortex model. J. Eng. Mech. 126(10), 1098–1106 (2000).

13. 13.

Azimi, A. H. & Etemad-Shahidi, A. Testing the Cormix and Visjet models to predict the dilution of San Francisco outfall. In 7th IWA Conference on Diffuse Pollution and Basin Management (DIPCON) (2003).

14. 14.

Morelissen, R., Theo, V. D. K. & Bleninger, T. Dynamic coupling of near field and far field models for simulating effluent discharges. Water Sci. Technol. J. Int. Assoc. Water Pollut. Res. 67(10), 2210–2220 (2013).

15. 15.

Hunt, C. D. et al. Plume tracking and dilution of effluent from the Boston sewage outfall. Mar. Environ. Res. 70(2), 150–161 (2010).

16. 16.

Li, S. & Hodgins, D. O. A dynamically coupled outfall plume-circulation model for effluent dispersion in Burrard inlet, British Columbia. J. Environ. Eng. Sci. 3(5), 433–449 (2004).

17. 17.

Sun, Y. L., Sun, C. Q. & Zhao, K. S. Optimum location of pollution discharge in the development district of Qingdao. Period. Ocean Univ. Qingdao S1, 134–141 (1994).

18. 18.

Sun, C. Q., Zhao, K. S. & Sun, Y. L. Selection of pollutant discharge outlet and prediction of water quality in the offshore area of basuo. Period. Ocean Univ. Qingdao 8, 209–216 (1994).

19. 19.

Yin, Y. et al. Optimum of marine discharge of effluent from wastewater treatment plan in Yangpu development zone. Acta Sci. Circum. 17(1), 48–52 (1997).

20. 20.

Fan, Q. M. & Ding, Z. B. Effluent standards and sewerage outfalls selection of the wastewater treatment plants in harbour based on EFDC. Environ. Monit. Assess. 34(012), 147–152 (2016).

21. 21.

Sun, Y. L., Wang, L. X. & Shi, F. Y. The total discharging control at Yangpu economic development zone. Period. Ocean Univ. Qingdao 30(3), 383–389 (2000).

22. 22.

He, B. J. et al. Environmental capacity and selection of optimum location for sewage holes in Tieshan Bay of Guangxi. Guangxi Sci. 8, 232–235 (2001).

23. 23.

Shi, P., Peng, K. L., Xie, J. & He, G. F. Study on the selection of discharge outlet into the sea of pollutants from coastal industry: With example of Zhanjiang steel project. Trans. Oceanol. Limnol. 000(002), 159–166 (2011).

24. 24.

Wang, X. H., Zhan, S. F., Peng, S. T., & Yu, H. Research on discharge position selection of sewage marine disposal in Yangkou Port. J. Waterw. Harb. 032(002), 140–143 (2011).

25. 25.

Shi, H. et al. Ecology suitability evaluation and comparison for the location of marine outfalls—A case study of coastal areas in Shenzhen city. Saf. Environ. Eng. 23(3), 75–82 (2016).

26. 26.

Wan, S. S. & Hao, Y. Research on drain layout optimization using probability learning evolutionary algorithm. Comput. Eng. Appl. 45(15), 237–240 (2009).

27. 27.

Zhao, Y. W. et al. GIS-based optimization for the locations of sewage treatment plants and sewage outfalls—A case study of Nansha district in Guangzhou city, China. China Commun. Nonlinear Sci. Numer. Simul. 14(4), 1746–1757 (2009).

28. 28.

Wang, L. et al. Drain layout optimization model and dynamic complement based upon multi factors. J. Shenyang Agric. Univ. 43(3), 374–377 (2012).

29. 29.

Li, W., Ding, Z. B. & Lu, Y. F. Research progress on site selection of sewage outfall. Constr. Des. Proj. 416(18), 148–150 (2019).

30. 30.

Cui, J. X. Reconstruction and prospect of the supervision of marine sewage outfall under the land and sea overall planning. Environ. Sustain. Dev. 702(04), 101–107 (2020).

31. 31.

Liu, C. G. Strengthening marine ecological civilization and promoting sustainable development of Marine economy. Ocean Dev. Manag. 06, 16–18 (2012).

32. 32.

Zheng, M. Z. & Liu, Y. Discussion on establishing institutional framework of marine eco-civilization. Environ. Sustain. Dev. 041(005), 76–80 (2016).

33. 33.

Tate, P. M., Scaturr, S. & Cathers, B. Marine outfalls. In Springer Handbook of Ocean Engineering. Springer Handbooks (eds Dhanak, M. R. & Xiros, N. I.) (Springer, 2016).

34. 34.

Gu, J. et al. Study of COD environmental capacity in coastal waters of Beidaihe in summer. Mar. Environ. Sci. 36(5), 682–687 (2017).

35. 35.

Wang, J. N. & Pan, X. Z. Application of linear programming in the allocation of environmental capacity resources. Environ. Sci. 26(6), 195–198 (2005).

36. 36.

Ma, T., Liu, W. H., Song, C. & Cheng, W. Application of MIKE3 in prediction analysis of the water temperature of reservoir. Power Syst. Clean Energy 25(2), 68–71 (2009).

37. 37.

Xiamen Ecological Environment Bureau. 2020 Xiamen Ecological Environmental Quality Bulletin (2020). http://sthjj.xm.gov.cn/zwgk/zfxxgk/fdzdgknr/hjzl/hjzkgb/202106/P020210602394855794788.pdf.

## Acknowledgements

The author’s special thanks to Xiamen Municipal Ecological Environment Bureau and Xiamen Urban Planning and Design Institute for supplying the wastewater treatment plants data.

## Author information

Authors

### Contributions

C.W.: Conceptualization, Writing-original draft and editing. Z.G.: Collecting and analyzing the data. Q.L.: Analyzing the Data. J.F.: Review and editing.

### Corresponding author

Correspondence to Jing Fang.

## Ethics declarations

### Competing interests

The authors declare no competing interests.

### Publisher's note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Wang, C., Guo, Z., Li, Q. et al. Study on layout optimization of sewage outfalls: a case study of wastewater treatment plants in Xiamen. Sci Rep 11, 18326 (2021). https://doi.org/10.1038/s41598-021-97756-9

• Accepted:

• Published:


text:
Telescoping uniform continuity and need some help

If $f$ is a $C^1$ function of period $2\pi$ and $f(0)=0$, and $g(x) = f(x)/(e^{ix} -1)$,

then let $C_n$ be the complex fourier coefficients of $f(x)$ and $D_n$ the coefficients of $g(x)$. How can we show that $D_n \to 0$?

ii) And how can we show that $C_n = D_{n-1} - D_n$, so that the series $\sum C_n$ is telescoping.

So, for the first one, I'm thinking of uniform continuity and how to show that $g(x)$ is continuous in it.

-
$D_n \to 0$ looks like the Riemann-Lebesgue lemma... – Siminore Oct 28 '12 at 9:50

For ii), write $g(x)=f(x)/(\def\eix{\mathrm e^{\mathrm ix}}\eix-1)$ as $f(x)=g(x)(\eix-1)$. Now if you compute the Fourier coefficients on both sides, the factor $\eix$ shifts the coefficients of $g$ by $1$, yielding $C_n=D_{n-1}-D_n$.
For the first question, you can conclude from $C_n=D_{n-1}-D_n$ that $\sum_{k=j}^nC_k=D_j-D_n$ by induction, then let $j\to-\infty$ and $n\to\infty$ to get $\lim_{n\to\infty}(D_{-n}-D_n)=\sum_{k=-\infty}^\infty C_k=f(0)=0$. Contrary to what I wrote in the first version of this answer, that only establishes that the imaginary part of $D_n$, which is odd, goes to $0$. To conclude that all of $D_n$ goes to $0$, either note that $g$ is continuous at $0$ (and thus everywhere), and conclude that $\sum_{k=-\infty}^\infty D_k=g(0)$, so $D_n$ must go to zero for the series to converge; or invoke the Riemann-Lebesgue lemma, as Siminore suggested in a comment under the question.
@mary: Could you please a) use $\TeX$ in the comments, too, to make them readable, and b) explain how your comment relates to my answer? Neither of those, as far as I can decypher them, seems to be related to what I wrote. – joriki Oct 28 '12 at 21:44


text:
# Which machine learning(recurrent/reinforcement learning) method/algorthim would suite this scenario

This application has it's roots in public transport, users opening the application and looking at the departure times of buses for specific stops (page 1) or planning a journey from location A to B with a journey planner(page 2). Two separate pages, two separate functions.

Page 1 you can say the user is familiar with the route, as they only need to know the departure and page 2 vice versa they do not know the route, and need a journey planner to assist them.

I am trying to make an application that displays one of the pages to the user depending on specific variables(which will make up a state). The page that the application shows to the user is dependent on former rewards on those specific states given the actions of the user; the user will either 1) stay on the page first shown, which will result in + reward or 2) navigate to the other page, which will result in - reward.

In simple terms, I would like to display the correct page to the user when the user enters the application, so the user does not have to navigate there themselves.

The features I get to play with include the following:

location
time of day
day of week
|----- monday
|----- tuesday
|----- wednesday
|----- thursday
|----- friday
|----- saturday
|----- sunday
week of month
|----- 1
|----- 2
|----- 3
|----- 4
month of year
|----- january
|----- february
|----- march
|----- april
|----- may
|----- june
|----- july
|----- august
|----- september
|----- october
|----- november
|----- december
action
|----- page 1
|----- page 2

An example of using this set would be the following:

The user enters the application and the application displays page 1 (default page). The user stays on the page, reward is given to the state.

{
location: '12th Example Street, Somecity',
timestamp: '2015-03-03 08:31:12', // <--- this includes day, week, month, year etc. as you can see
action: page1
}

As most commuters have 7-4 jobs it's very routine. Monday to Friday the user usually takes the bus to work every morning and then back at home. He knows his route so page 1 would be optimal to be displayed. This user on a non-specific Friday night however is out at a pub and has a pint too, ends up at an after party in the middle of who-knows-where resulting in trying to get home, page 2 would be optimal for him Saturday morning.

As learning goes, the application must learn before making assumptions, it must also respond to change in routine. A user might change job or move. It's safe to say that if the user does not know where they are that page 2 should be displayed, if the application is confident that the user knows where he is going page 1 is the better choice.

Now my question. Which algorithm/method would be best suited for this task, spending time on one just to realize that it was a complete waste is nothing but a total bummer. I've done supervised learning before however that won't cut it for obvious reasons.

Any comments on anything is welcome! I always like to better myself.


text:
# Is x/(1+e^(1/x)) differentiable at x=0

## Homework Statement

is x/(1+e1/x) differentiable at x =0

## The Attempt at a Solution

i calculated the right and left hand derivative and got them as 0 and 1 respectively , so it should not be differentiable, is it right my book says that it is differentiable ?

## Answers and Replies

SammyS
Staff Emeritus
Homework Helper
Gold Member

Show what went into your results.

WolframAlpha says that you're correct!

Last edited:

Show what went into your results.

WolframAlpha says that you're correct!

my book says that i am wrong , but i think iam convinced that i am right , thanks!!

HallsofIvy
Homework Helper

The function you give is not differentiable at x= 0 because it is not even defined at x= 0. What is the function value at x= 0?

Assuming that you also have f(0)= 0, then the difference quotient is
$$\frac{f(h)- f(0)}{h}= \frac{h}{1+ e^{1/h}}\frac{1}{h}= \frac{1}{1+ e^{1/h}}$$
which goes to 1 as h goes to either $\infty$ or $-\infty$.

You are wrong and your book is right.

Last edited by a moderator:
Char. Limit
Gold Member

The function you give is not differentiable at x= 0 because it is not even defined at x= 0. What is the function value at x= 0?

Assuming that you also have f(0)= 0, then the difference quotient is
$$\frac{f(h)- f(0)}{h}= \frac{h}{1+ e^{1/h}}\frac{1}{h}= \frac{1}{1+ e^{1/h}}$$
which goes to 0 as x goes to either $\infty$ or $-\infty$.

You are wrong and your book is right.

How can the book be right when the book says that it is differentiable, and you clearly say that it isn't?

How can the book be right when the book says that it is differentiable, and you clearly say that it isn't?

Because it is differentiable. I don't think he means what you think he means by non existent at 0 at least I hope so or I am confused.

Easiest way to solve this argument is to graph it.

At x=0, y = "0" though just plugging in the numbers, that should tell you something division by what is what?

This is differentiable because of the asymptote I think not despite it. To put what he said in words rather than latex, maybe that will help?

Last edited:

The function you give is not differentiable at x= 0 because it is not even defined at x= 0. What is the function value at x= 0?

Assuming that you also have f(0)= 0, then the difference quotient is
$$\frac{f(h)- f(0)}{h}= \frac{h}{1+ e^{1/h}}\frac{1}{h}= \frac{1}{1+ e^{1/h}}$$
which goes to 0 as x goes to either $\infty$ or $-\infty$.

You are wrong and your book is right.

i guess by x you mean 1/h , but when 1/h goes to -infinity , e1/h goes to 0 , this means the last expression 1/(1+e1/h) becomes 1
and yes f(0)=0

HallsofIvy
Homework Helper

Because it is differentiable. I don't think he means what you think he means by non existent at 0 at least I hope so or I am confused.
If you are referring to my post, yes, I did mean that- in the first post, we were told that the function was $f(x)= x/(1+ e^{1/x})$ which is NOT defined at x= 0. If we assume that f(0)= 0, then the derivative does exist.

Easiest way to solve this argument is to graph it.

At x=0, y = "0" though just plugging in the numbers, that should tell you something division by what is what?
Plugging numbers into what? You cannot set x= 0 and get y. If you mean that values of x close to 0 give values of y close to 0, then to conclude that the value of f(0) is 0, you would have to know that the function is continuous at x= 0 and we were also not told that.

This is differentiable because of the asymptote I think not despite it. To put what he said in words rather than latex, maybe that will help?
There is no "asymptote". Assuming that f(0)= 0, this is just a basic differentiable function.

Last edited by a moderator:

$$f(x)= x/(1+ e^{1/x})$$ and

$$g(x) = \left\{ \begin{array}{lr} x/(1+ e^{1/x}),~ x \neq 0\\ 0,~ x = 0 \end{array} \right.$$

are different functions. If you calculate the corresponding limit of the first function as x approaches 0 and then define the value of said function as the limit, you'll have made the function continuous and then and only then does it make sense to calculate the derivative via the limit definition, as HallsofIvy has pointed out.

However, as the original function was given to us, I have to say it is not differentiable as it's not even defined for x = 0. It is indeed natural to "fill in" the removable discontinuity, but the author of the problem has to give us the precise definition of a function if he expects us to give precise answers.

SammyS
Staff Emeritus
Homework Helper
Gold Member

The function you give is not differentiable at x= 0 because it is not even defined at x= 0. What is the function value at x= 0?

Assuming that you also have f(0)= 0, then the difference quotient is
$$\frac{f(h)- f(0)}{h}= \frac{h}{1+ e^{1/h}}\frac{1}{h}= \frac{1}{1+ e^{1/h}}$$
which goes to 1 as h goes to either $\infty$ or $-\infty$.

You are wrong and your book is right.
@ HallsofIvy, (assuming that the removable discontinuity has been removed.)

Why did you take the limits as h → +∞ & h → ‒∞, rather than h → 0+ & h → 0 ?

If you are referring to my post, yes, I did mean that- in the first post, we were told that the function was $f(x)= x/(1+ e^{1/x})$ which is NOT defined at x= 0. If we assume that f(0)= 0, then the derivative does exist.

Plugging numbers into what? You cannot set x= 0 and get y. If you mean that values of x close to 0 give values of y close to 0, then to conclude that the value of f(0) is 0, you would have to know that the function is continuous at x= 0 and we were also not told that.

There is no "asymptote". Assuming that f(0)= 0, this is just a basic differentiable function.

My bad obviously I typed the wrong function into a grapher. Or the grapher was ****.

Either way ignore me. :D

obviously put a bracket in the wrong place and it all went pear shaped. :D

Not literally obv. :)

@ HallsofIvy, (assuming that the removable discontinuity has been removed.)

Why did you take the limits as h → +∞ & h → ‒∞, rather than h → 0+ & h → 0 ?

Reviewing this message, I have to say, my thoughts exactly. If I'm not mistaken, on one side, the derivative is 1, and approaching from the other side, it's 0. Hence, even when the discontinuity has been dealt with, the function is not differentiable.


text:
## Jørgen Bang-Jensen ; Jonas Costa Ferreira da Silva ; Frédéric Havet - On the inversion number of oriented graphs

dmtcs:7474 - Discrete Mathematics & Theoretical Computer Science, December 21, 2022, vol. 23 no. 2, special issue in honour of Maurice Pouzet - https://doi.org/10.46298/dmtcs.7474
On the inversion number of oriented graphs

Authors: Jørgen Bang-Jensen ; Jonas Costa Ferreira da Silva ; Frédéric Havet

Let $D$ be an oriented graph. The inversion of a set $X$ of vertices in $D$ consists in reversing the direction of all arcs with both ends in $X$. The inversion number of $D$, denoted by ${\rm inv}(D)$, is the minimum number of inversions needed to make $D$ acyclic. Denoting by $\tau(D)$, $\tau' (D)$, and $\nu(D)$ the cycle transversal number, the cycle arc-transversal number and the cycle packing number of $D$ respectively, one shows that ${\rm inv}(D) \leq \tau' (D)$, ${\rm inv}(D) \leq 2\tau(D)$ and there exists a function $g$ such that ${\rm inv}(D)\leq g(\nu(D))$. We conjecture that for any two oriented graphs $L$ and $R$, ${\rm inv}(L\rightarrow R) ={\rm inv}(L) +{\rm inv}(R)$ where $L\rightarrow R$ is the dijoin of $L$ and $R$. This would imply that the first two inequalities are tight. We prove this conjecture when ${\rm inv}(L)\leq 1$ and ${\rm inv}(R)\leq 2$ and when ${\rm inv}(L) ={\rm inv}(R)=2$ and $L$ and $R$ are strongly connected. We also show that the function $g$ of the third inequality satisfies $g(1)\leq 4$. We then consider the complexity of deciding whether ${\rm inv}(D)\leq k$ for a given oriented graph $D$. We show that it is NP-complete for $k=1$, which together with the above conjecture would imply that it is NP-complete for every $k$. This contrasts with a result of Belkhechine et al. which states that deciding whether ${\rm inv}(T)\leq k$ for a given tournament $T$ is polynomial-time solvable.

Volume: vol. 23 no. 2, special issue in honour of Maurice Pouzet
Section: Special issues
Published on: December 21, 2022
Accepted on: December 21, 2022
Submitted on: May 11, 2021
Keywords: Mathematics - Combinatorics,Computer Science - Discrete Mathematics

## Consultation statistics

This page has been seen 68 times.


text:
Q.4 Given $$\overline{AB}$$ of length 3.9 cm. Construct (\overline{PQ} \) such that the length of (\overline{PQ} \) is twice that of (\overline{AB} \) . Verify by measurement.

(Hint : Construct $$\overline{PX}$$ such that the length of $$\overline{PX}$$ = length of $$\overline{AB}$$ then cut off $$\overline{XQ}$$ such that $$\overline{XQ}$$ also has the length of $$\overline{AB}$$ .


text:
# Circuit to construct a $n$-qubit state which is a superposition of states with only a single qubit being $\lvert1\rangle$ [duplicate]

So the question came up in a book I am working through. Given a circuit with $$n$$ qubits, construct a state with only $$n$$ possible measurement results, each of which has only $$1$$ of $$n$$ qubits as $$1$$, such as $$|0001\rangle$$, $$|0010\rangle$$, $$|0100\rangle$$, $$|1000\rangle$$, obviously normalized.

The only way I can think to do this is to take the all $$|0\rangle$$ input state, apply $$\operatorname{H}$$ to each qubit and then used multiple-controlled $$\operatorname{CNOT}$$ gates to affect the change on each qubit, but I feel like this won't lead to the desired end state.

To be clear, I am enquiring how to create a $$W_n$$ state can be arbitrarily prepared, given $$n$$ qubits.

• I'm not sure what you mean by "n possible measurement results" here. If you have $n$ qubits then there are $2^n$ possible measurement results. The rest of the question is fine and interesting though. I edited the title to better reflect what I think you are asking. Feel free to revert the edit if I misunderstood you – glS Nov 2 '18 at 13:39
• also, just for reference, states such as the one you refer to are often referred to as W states, and a similar question was also asked on physics.SE, see physics.stackexchange.com/q/311743/58382. Finally, as pointed out in that question, you should really specify the set of gates that you want to use – glS Nov 2 '18 at 13:40
• @glS It appears the actual term for the state I was looking for is the W state, which has only n measurements. – GaussStrife Nov 2 '18 at 14:31
• again, I don't know what you mean by "has only n measurements". A state of $n$ qubits can have $2^n$ possible measurement results, it doesn't matter which particular state it is – glS Nov 2 '18 at 14:33
• @gIS: for what it's worth, I find luminalQubit's terminology fairly clear. A $W$ state does only have $n$ possible measurement results, because none of the other $2^n - n$ bit strings are 'possible measurement results' of the $W$ state. – Niel de Beaudrap Nov 2 '18 at 16:01


text:
# How do you factor 15y^3-19y^2-30y+7 ?

May 20, 2017

#### Answer:

$15 {y}^{3} - 19 {y}^{2} - 30 y + 7$ has no factorisation with rational coefficients.

It is "possible" to find a factorisation of the form:

$15 {y}^{3} - 19 {y}^{2} - 30 y + 7 = 15 \left(y - {y}_{1}\right) \left(y - {y}_{2}\right) \left(y - {y}_{3}\right)$

#### Explanation:

Given (rearranged into standard order):

$f \left(y\right) = 15 {y}^{3} - 19 {y}^{2} - 30 y + 7$

$\textcolor{w h i t e}{}$
Rational Roots Theorem

By the rational roots theorem, any rational zeros of $f \left(y\right)$ are expressible in the form $\frac{p}{q}$ for integers $p , q$ with $p$ a divisor of the constant term $7$ and $q$ a divisor of the coefficient $15$ of the leading term.

That means that the only possible rational zeros are:

$\pm \frac{1}{15} , \pm \frac{1}{5} , \pm \frac{1}{3} , \pm 1 , \pm \frac{19}{15} , \pm \frac{19}{5} , \pm \frac{19}{3} , \pm 19$

We find:

$f \left(- \frac{19}{15}\right) = - \frac{3593}{225}$

$f \left(- 1\right) = 3$

$f \left(\frac{1}{5}\right) = \frac{9}{25}$

$f \left(\frac{1}{3}\right) = - \frac{41}{9}$

$f \left(\frac{19}{15}\right) = - 31$

$f \left(\frac{19}{5}\right) = \frac{7951}{18}$

$f \left(y\right)$ is not zero at any of the possible rational values, but changes sign between them as we have found.

So $f \left(y\right)$ has no rational roots, but it has $3$ irrational roots, in:

$\left(- \frac{19}{15} , - 1\right)$, $\left(\frac{1}{5} , \frac{1}{3}\right)$ and $\left(\frac{19}{15} , \frac{19}{5}\right)$

$\textcolor{w h i t e}{}$
Where do we go from here?

If we can find the zeros ${y}_{1}$, ${y}_{2}$ and ${y}_{3}$ then the given polynomial factors as:

$15 {y}^{3} - 19 {y}^{2} - 30 y + 7 = 15 \left(y - {y}_{1}\right) \left(y - {y}_{2}\right) \left(y - {y}_{3}\right)$

Since all three zeros are real but irrational, it falls into Cardano's "casus irreducibilis". His method will involve taking cube roots of non-real complex numbers.

A better option for an "algebraic" solution is a probably a trigonometric one, using the fact that:

$\cos 3 \theta = 4 {\cos}^{3} \theta - 3 \cos \theta$

and the substitution:

$y = \frac{19}{45} + k \cos \theta$

for some $k$ chosen to cause the terms in ${\cos}^{3} \theta$ and $\cos \theta$ to match the $\cos 3 \theta$ formula.

This probably gets messier than you would like.


text:
# Maximal Skittle Enjoyment

You've been given a bag of Skittles. Everybody knows that in order to appreciate the different flavors the most, you need to rotate between the flavors.

## Basics:

1. You can only eat 1 skittle at a time
2. The order that you eat your skittles must be periodic.
3. Each period cannot contain a particular flavor more than once.
4. Your bag only has so many skittles. You cannot eat more of a particular flavor of skittle than appears in your bag.
5. You want to eat as many skittles as you can (it may not always be possible)

## Examples:

Lets say you start with 3 Red, 2 Blue, and 3 Green skittles:

R B G R B G R G       Invalid:  The last R must be followed by a B, not a G
R B G R B G R         Valid, but sub-optimal
R R R                 Valid, but sub-optimal
R G B R G B R G       Valid and optimal
G R B G R B G R       Also valid and optimal (there are multiple good solutions)

# Input/Output

• You are passed a non-empty list of positive integers for the color counts. (The above example would be [3,2,3]).
• You need to return a list containing valid and optimal ordering.
• Instead of using colors, you will use the indices from input list. (The last example output above would be [2,0,1,2,0,1,2,0]).
• Your output may be 0-indexed or 1-indexed. My examples will be 0-indexed

# Test Cases

1                          0
4                          0 0 0 0
4 1                        0 0 0 0
3 1                        0 1 0                   or  0 0 0
5 2 2                      0 1 2 0 1 2 0
2 3 5                      2 1 0 2 1 0 2 1         or  1 2 0 1 2 0 1 2
2 4 5                      2 1 2 1 2 1 2 1 2
3 4 5                      2 1 0 2 1 0 2 1 0 2 1   or  1 2 0 1 2 0 1 2 0 1 2
1 1 1 1 1 6                5 0 1 2 3 4 5           (lots of other solutions)
1 1 1 1 1 8                5 5 5 5 5 5 5 5
2 4 6 8                    3 2 1 3 2 1 3 2 1 3 2 1 3 2

This is a , so make your solutions as short as possible in your favorite language!

• May as well be linked to this – Jonathan Allan Mar 7 '17 at 4:34
• @JonathanAllan and that is why I need a computer to ensure my skittle enjoyment :) – Nathan Merrill Mar 7 '17 at 4:55

## JavaScript (ES6), 177 175 bytes

a=>a.map((n,i)=>[n,l=i]).sort((a,b)=>a[0]-b[0]).reduce((P,x,i,a)=>(v=a.reduce((p,c,j)=>j<i?p:p+Math.min(c[0],x[0]+1),0))>m?[...Array(m=v)].map((_,k)=>a[l-k%(l+1-i)][1]):P,m=0)

### Formatted and commented

a => a                              // given an array a:
.map((n, i) => [n, l = i])          // map it to [value, index] arrays / set l = length - 1
.sort((a, b) => a[0] - b[0])        // sort it by values in ascending order
.reduce((P, x, i, a) =>             // for each reference entry x at position i:
(v = a.reduce((p, c, j) =>        //   for each entry c at position j:
j < i ?                         //     if c is before x:
p                             //       keep the previous sum (which is 0)
:                               //     else:
p + Math.min(c[0], x[0] + 1), //       add minimum(value[j], value[i] + 1)
0                               //   initialize the sum at 0
)) > m ?                          //   if the new sum v is better than our current best m:
[...Array(m = v)].map((_, k) => //     update m to v and update the result to an array
a[l - k % (l + 1 - i)][1]     //     of length m filled with indices picked repeatedly
)                               //     between i and l
:                                 //   else:
P,                              //     keep the previous result
)                                   // the final result is returned by the outer reduce()

### Used formula

Below is a table showing how the formula F(i, j) = minimum(value[j], value[i] + 1) is working, here with i = 0 and the input [ 5, 2, 2 ].

This formula can be interpreted as follows: for each Skittle type, we can select no more than the number of the least available type plus one.

 j | Sorted    | value[j] | F(0, j) | Selected        | Output
| input     |          |         | Skittles        | (starting from bottom left)
---+-----------+----------+---------+-----------------+-----------------------------
0 | 2 2       |     2    |    2    | [2] [2]         | \
1 | 1 1       |     2    |    2    | [1] [1]         |  > 0 1 2 0 1 2 0
2 | 0 0 0 0 0 |     5    |    3    | [0] [0] [0] 0 0 | /

### Test cases

let f =

a=>a.map((n,i)=>[n,l=i]).sort((a,b)=>a[0]-b[0]).reduce((P,x,i,a)=>(v=a.reduce((p,c,j)=>j<i?p:p+Math.min(c[0],x[0]+1),0))>m?[...Array(m=v)].map((_,k)=>a[l-k%(l+1-i)][1]):P,m=0)

console.log(JSON.stringify(f([ 1                ]))); // 0
console.log(JSON.stringify(f([ 4                ]))); // 0 0 0 0
console.log(JSON.stringify(f([ 4, 1             ]))); // 0 0 0 0
console.log(JSON.stringify(f([ 3, 1             ]))); // 0 1 0
console.log(JSON.stringify(f([ 5, 2, 2          ]))); // 0 2 1 0 2 1 0
console.log(JSON.stringify(f([ 2, 3, 5          ]))); // 2 1 0 2 1 0 2 1
console.log(JSON.stringify(f([ 2, 4, 5          ]))); // 2 1 2 1 2 1 2 1 2
console.log(JSON.stringify(f([ 3, 4, 5          ]))); // 2 1 0 2 1 0 2 1 0 2 1
console.log(JSON.stringify(f([ 1, 1, 1, 1, 1, 6 ]))); // 5 4 3 2 1 0 5
console.log(JSON.stringify(f([ 1, 1, 1, 1, 1, 8 ]))); // 5 5 5 5 5 5 5 5
console.log(JSON.stringify(f([ 2, 4, 6, 8       ]))); // 3 2 1 3 2 1 3 2 1 3 2 1 3 2

• Are the reduce initialisations of the sum (0) and m being at the end of the "loops" golf-induced or is it just how JS is? – Jonathan Allan Mar 7 '17 at 21:33
• @JonathanAllan That's the JS way: the initial value of reduce() is located after the callback. Putting m=0 here is golf-induced, however, because I don't care about the initial value of this loop (it's going to be overwritten anyway). Initializing m there is convenient. – Arnauld Mar 7 '17 at 21:45
• Ah I see it's more like a function call than a loop (like Python's reduce function has an optional initial value). – Jonathan Allan Mar 7 '17 at 21:47
• @JonathanAllan Yes, exactly. [1,2,3].reduce((x, y) => x+y, 10) in JS would be reduce(lambda x,y: x+y, [1,2,3], 10) in Python (I think), both resulting in 16. – Arnauld Mar 7 '17 at 22:01

# Jelly, 22 bytes

ċÐ€ṢN
ỤṚ;\Ṛẋ"‘Ṣ$ḣ"ÇLÞṪ  1-based indexing. Try it online! ### How? Repeats each prefix of the indexes sorted by value descending one more time than would be achievable with the given bag of skittles, then removes the final skittle or skittles from each of these as necessary to make them achievable, and returns the one with the most skittles. The number that should be removed from one extra periodic repetition is just the number with the minimum count across that prefix. ỤṚ;\Ṛẋ"‘Ṣ$ḣ"ÇLÞṪ - Main link                   e.g. [6,4,2,8]
Ụ                - grade up: sort indices by value  [3,2,1,4]
Ṛ               - reverse                          [4,1,2,3]
\             - cumulative reduce with
;              -     concatenation (get prefixes) [[4],[4,1],[4,1,2],[4,1,2,3]]
Ṛ            - reverse                          [[4,1,2,3],[4,1,2],[4,1],[4]]
‘         -     increment                    [7,5,3,9]
Ṣ        -     sort                         [3,5,7,9]
"          - zip with
ẋ           -     list repetition              [[4,1,2,3,4,1,2,3,4,1,2,3],[4,1,2,4,1,2,4,1,2,4,1,2,4,1,2],[4,1,4,1,4,1,4,1,4,1,4,1,4,1],[4,4,4,4,4,4,4,4,4]]
"      - zip with
ḣ     - head list to (remove excess)     [[4,1,2,3,4,1,2,3,4,1,2],[4,1,2,4,1,2,4,1,2,4,1,2,4,1],[4,1,4,1,4,1,4,1,4,1,4,1,4],[4,4,4,4,4,4,4,4]]
Þ  - sort by
L   -     length                       [[4,4,4,4,4,4,4,4],[4,1,2,3,4,1,2,3,4,1,2],[4,1,4,1,4,1,4,1,4,1,4,1,4],[4,1,2,4,1,2,4,1,2,4,1,2,4,1]]
Ṫ - tail                             [4,1,2,4,1,2,4,1,2,4,1,2,4,1]

ċÐ€ṢN - Link 1: head amounts (negative of skittle excess of each N+1 repeated period)
Ṣ  - sort                                        [2,4,6,8]
Ð€   - for each mapped over right argument
ċ     - count                                       [1,1,1,1]
N - negate                                      [-1,-1,-1,-1]

# Python3, 174172 167 Bytes

## Idea

Given e.g. 3 Red, 2 Blue, and 3 Green skittles one can arrange them in a grid, sorted by color and amount:

r g
r g b
r g b

If one tries to eat exactly i skittles, one can at least eat i*c skittles in total, where c is the number of skittles in the r-th column, e.g. for i=2 one can at least eat 6 skittles.

r g
# # #
# # #

The only thing left to do is count how many additional skittles can be eaten by an incomplete period.

## Golfed

def f(a):
r=range;f=m=0;s=r(len(a));b=sorted(zip(a,s))[::-1]
for i in s:
c=b[i][0];n=-~i*c+sum(c<e[0]for e in b)
if n>m:f,m=i+1,n
return[b[j%f][1]for j in r(m)]

## Commented

def f(a):
r = range;
f = m = 0;                          - Some variables we need later on
s = r(len(a));                      - Integers from 0 to (num_skittles - 1)
b = sorted(zip(a,s))[::-1]          - Zip with s to remember initial order,
then sort and reverse
for i in s:
c = b[i][0]
n = (i+1)*c                     - If we attempt to eat i different skittles,
we can surely eat (i+1)*c skittles.
+ sum(1 for e in b if e[0]>c) - The additional sum corresponds to an incomplete period.
if n>m:                         - If a better way of eating skittles is found:
f,m = i+1,n                 - update variables
return [b[j%f][1] for j in r(m)]

Try it online!

Edit: Replaced (i+1) with -~i to save 2 bytes.

Edit: -5 bytes thanks to Dead Possum

• You can change sum(1for e in b if e[0]>c) to sum(c<e[0]for e in b). It would convert True to 1 implicitly and save you 5 bytes – Dead Possum Mar 22 '17 at 22:19


text:
# Assessment of kidney function

(Redirected from Kidney function)
Diagram showing a schematic nephron and its blood supply. The basic physiologic mechanisms of handling fluid and electrolytes by the nephron - filtration, secretion, reabsorption, and excretion - are labelled.

Assessment of kidney function occurs in different ways, using the presence of symptoms and signs, as well as measurements using urine tests, blood tests, and medical imaging.

Functions of a healthy kidney include maintaining a person's fluid balance, maintaining an acid-base balance; regulating electrolytes including sodium, potassium, and other electrolytes; clearing toxins; regulating blood pressure; and regulating hormones, such as erythropoietin; and activation of vitamin D.

## Introduction

The functions of the kidney include maintenance of acid-base balance; regulation of fluid balance; regulation of sodium, potassium, and other electrolytes; clearance of toxins; absorption of glucose, amino acids, and other small molecules; regulation of blood pressure; production of various hormones, such as erythropoietin; and activation of vitamin D.

Much of renal physiology is studied at the level of the nephron, the smallest functional unit of the kidney. Each nephron begins with a filtration component that filters the blood entering the kidney. This filtrate then flows along the length of the nephron, which is a tubular structure lined by a single layer of specialized cells and surrounded by capillaries. The major functions of these lining cells are the reabsorption of water and small molecules from the filtrate into the blood, and the secretion of wastes from the blood into the urine.

Proper function of the kidney requires that it receives and adequately filters blood. This is performed at the microscopic level by many hundreds of thousands of filtration units called renal corpuscles, each of which is composed of a glomerulus and a Bowman's capsule. A global assessment of renal function is often ascertained by estimating the rate of filtration, called the glomerular filtration rate (GFR).

## Clinical assessment

Clinical assessment can be used to assess the function of the kidneys. This is because a person with abnormally functioning kidneys may have symptoms that develop. For example, a person with chronic kidney disease may develop oedema due to failure of the kidneys to regulate water balance. They may develop evidence of chronic kidney disease, that can be used to assess its severity, for example high blood pressure, osteoporosis or anaemia. If the kidneys are unable to excrete urea, a person may develop a widespread itch or confusion.[citation needed]

## Urine tests

Part of the assessment of kidney function includes the measurement of urine and its contents. Abnormal kidney function may cause too much or too little urine to be produced. The ability of the kidneys to filter protein is often measured, as urine albumin or urine protein levels,[1] measured either at a single instance or, because of variation throughout the day, as 24-hour urine tests.[citation needed]

## Blood tests

Blood tests are also used to assess kidney function. These include tests that are intended to directly measure the function of the kidneys, as well as tests that assess the function of the kidneys by looking for evidence of problems associated with abnormal function. One of the measures of kidney function is the glomerular filtration rate (GFR). Other tests that can assess the function of the kidneys include assessment of electrolyte levels such as potassium and phosphate, assessment of acid-base status by the measurement of bicarbonate levels from a vein, and assessment of the full blood count for anaemia.[citation needed]

### Glomerular filtration rate

The glomerular filtration rate (GFR) describes the volume of fluid filtered from the renal (kidney) glomerular capillaries into the Bowman's capsule per unit time.[2] Creatinine clearance is the volume of blood plasma that is cleared of creatinine per unit time and is a useful measure for approximating the GFR. Creatinine clearance exceeds GFR due to creatinine secretion,[3] which can be blocked by cimetidine. Both GFR and CCr may be accurately calculated by comparative measurements of substances in the blood and urine, or estimated by formulas using just a blood test result (eGFR and eCCr) The results of these tests are used to assess the excretory function of the kidneys. Staging of chronic kidney disease is based on categories of GFR as well as albuminuria and cause of kidney disease.[1]

Central to the physiologic maintenance of GFR is the differential basal tone of the afferent and efferent arterioles (see diagram). In other words, the filtration rate is dependent on the difference between the higher blood pressure created by vasoconstriction of the input or afferent arteriole versus the lower blood pressure created by lesser vasoconstriction of the output or efferent arteriole.

GFR is equal to the renal clearance ratio when any solute is freely filtered and is neither reabsorbed nor secreted by the kidneys. The rate therefore measured is the quantity of the substance in the urine that originated from a calculable volume of blood. Relating this principle to the below equation – for the substance used, the product of urine concentration and urine flow equals the mass of substance excreted during the time that urine has been collected. This mass equals the mass filtered at the glomerulus as nothing is added or removed in the nephron. Dividing this mass by the plasma concentration gives the volume of plasma which the mass must have originally come from, and thus the volume of plasma fluid that has entered Bowman's capsule within the aforementioned period of time. The GFR is typically recorded in units of volume per time, e.g., milliliters per minute (mL/min). Compare to filtration fraction.[citation needed]

${\displaystyle GFR={\frac {{\mbox{Urine Concentration}}\times {\mbox{Urine Flow}}}{\mbox{Plasma Concentration}}}}$

There are several different techniques used to calculate or estimate the glomerular filtration rate (GFR or eGFR). The above formula only applies for GFR calculation when it is equal to the Clearance Rate.

The normal range of GFR, adjusted for body surface area, is 100–130 average 125 (mL/min)/(1.73 m2) in men and 90–120 (mL/min)/(1.73 m2) in women younger than the age of 40. In children, GFR measured by inulin clearance is 110 (mL/min)/(1.73 m2) until 2 years of age in both sexes, and then it progressively decreases. After age 40, GFR decreases progressively with age, by 0.4–1.2 mL/min per year.[citation needed]

Estimated GFR (eGFR) is now recommended by clinical practice guidelines and regulatory agencies for routine evaluation of GFR whereas measured GFR (mGFR) is recommended as a confirmatory test when more accurate assessment is required.[4]

## Medical imaging

The kidney function can also be assessed with medical imaging. Some forms of imaging, such as kidney ultrasound or CT scans, may assess kidney function by indicating chronic disease that can impact function, by showing a small or shrivelled kidney.[citation needed]. Other tests, such as nuclear medicine tests, directly assess the function of the kidney by measuring the perfusion and excretion of radioactive substances through the kidneys.[citation needed]

## Kidney function in disease

A decreased renal function can be caused by many types of kidney disease. Upon presentation of decreased renal function, it is recommended to perform a history and physical examination, as well as performing a renal ultrasound and a urinalysis.[citation needed] The most relevant items in the history are medications, edema, nocturia, gross hematuria, family history of kidney disease, diabetes and polyuria. The most important items in a physical examination are signs of vasculitis, lupus erythematosus, diabetes, endocarditis and hypertension.[citation needed]

A urinalysis is helpful even when not showing any pathology, as this finding suggests an extrarenal etiology. Proteinuria and/or urinary sediment usually indicates the presence of glomerular disease. Hematuria may be caused by glomerular disease or by a disease along the urinary tract.[citation needed]

The most relevant assessments in a renal ultrasound are renal sizes, echogenicity and any signs of hydronephrosis. Renal enlargement usually indicates diabetic nephropathy, focal segmental glomerular sclerosis or myeloma. Renal atrophy suggests longstanding chronic renal disease.[citation needed]

### Chronic kidney disease stages

Risk factors for kidney disease include diabetes, high blood pressure, family history, older age, ethnic group and smoking. For most patients, a GFR over 60 (mL/min)/(1.73 m2) is adequate. But significant decline of the GFR from a previous test result can be an early indicator of kidney disease requiring medical intervention. The sooner kidney dysfunction is diagnosed and treated the greater odds of preserving remaining nephrons, and preventing the need for dialysis.

CKD stage GFR level ((mL/min)/(1.73 m2))
Stage 1 ≥ 90
Stage 2 60–89
Stage 3 30–59
Stage 4 15–29
Stage 5 < 15

The severity of chronic kidney disease (CKD) is described by six stages; the most severe three are defined by the MDRD-eGFR value, and first three also depend on whether there is other evidence of kidney disease (e.g., proteinuria):

0) Normal kidney function – GFR above 90 (mL/min)/(1.73 m2) and no proteinuria
1) CKD1 – GFR above 90 (mL/min)/(1.73 m2) with evidence of kidney damage
2) CKD2 (mild) – GFR of 60 to 89 (mL/min)/(1.73 m2) with evidence of kidney damage
3) CKD3 (moderate) – GFR of 30 to 59 (mL/min)/(1.73 m2)
4) CKD4 (severe) – GFR of 15 to 29 (mL/min)/(1.73 m2)
5) CKD5 kidney failure – GFR less than 15 (mL/min)/(1.73 m2) Some people add CKD5D for those stage 5 patients requiring dialysis; many patients in CKD5 are not yet on dialysis.

Note: others add a "T" to patients who have had a transplant regardless of stage.

Not all clinicians agree with the above classification, suggesting that it may mislabel patients with mildly reduced kidney function, especially the elderly, as having a disease.[5][6] A conference was held in 2009 regarding these controversies by Kidney Disease: Improving Global Outcomes (KDIGO) on CKD: Definition, Classification and Prognosis, gathering data on CKD prognosis to refine the definition and staging of CKD.[7]