{'fraction_non_alphanumeric': 0.03285367545076283, 'fraction_numerical': 0.013782940360610264, 'mean_word_length': 4.659308314937454, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On the Estimation and Control of Human Body Composition

Obesity is a chronic disease that can lead to an increased risk of other serious chronic diseases and even death. We present switching and time-delayed feedback-based model free control methods for the dynamic management of body mass and its major components. The estimation of body composition based on human body weight dynamics is proposed using a soft switching-based observer. Additionally, this paper addresses the control allocation problem for optimal body weight management using linear algebraic equivalence of the nonlinear controllers based on dynamic behavior of body composition described in literature. A control allocator system computes the required energy intake and energy expenditure from a controlling range of inputs to track a desired trajectory of body mass by optimizing a weighted quadratic function. Simulation results validate the performance of the proposed controllers and the observer under disturbances in recording energy intake and energy expenditure figures.


I. INTRODUCTION
Obesity, a serious social and public health problem, is increasing dramatically among the population not only in high-income and developed countries, but also in low-tomiddle-income and poor, developing countries, particularly in urban settings. Obesity and being overweight result from a variety of factors, such as physical inactivity, high level of stress, as well as inappropriate diet. Obesity and being overweight are also associated with heart disease, certain types of cancer, type 2 diabetes, stroke, arthritis, breathing problems, and psychological disorders, such as depression (Laila, 2010), (Sentocnik, AtanasijevicKunc, Drinovec and Pfeifer, 2013).
Many studies have been conducted to try and understand the etiology of weight gain and obesity. In (Chow and Hall, 2008), a model based on macronutrient and energy flux balance is presented. A computational model, presented in (Hall, 2010), shows how diet perturbations result in adaptations of fuel selection and energy expenditure that predict body weight and composition changes in both obese and non-obese individuals. In (NavarroBarrientos, Rivera and Collins, 2011), the authors incorporated both physiological and psychological factors in a dynamical model to help develop behavioral interventions.
Solving the obesity problem through healthy body weight management has been of interest in the control community (Karimi and Rao, 2015). In (Laila, 2010), closed loop control of body composition was done, and the energy intake into the body is regarded as the input control to the system. Clinical open-loop and closed-loop control efforts for various scenarios were studied in (Sentocnik et al., 2013), and the efficacy of the treatment can, in this way, be significantly improved.
Control of body mass or its major components may need daily body composition measurement. Several methods, such as air displacement plethysmography, dual-energy x-ray absorptiometry, bioimpedance spectroscopy, quantitative magnetic resonance and magnetic resonance imaging/spectroscopy, are presented in (Baracos and et al, 2012). These methods are expensive to administer and inconvenient to arrange for frequent measurements. To minimize the associated cost and inconvenience, we propose a technique for estimation of body composition using observer design based on daily measurements of total body weight alone.
Feedback linearization (FL) and sliding mode control (SMC) are two widely used control schemes for nonlinear systems. Despite their desirable features, the inability to handle explicit input constraints is a major drawback of using FL/SMC, while the body weight control system described in this research clearly has input constraint-limitations in energy intake and physical activity. To resolve this problem, (Gwak and Masada, 2008) proposed a constrained FL/SMC nonlinear optimal controller that can be represented in a simple constrained linear least-square problem. A precise dynamic model is difficult to build, and the identification of the model parameters has to be individualized and can vary over time. Therefore, a controller that does not require a dynamic model would be a useful and more robust tool than model-based controllers, especially when precise tracking is achievable with small control gains.
In addition, measurements of energy intake and energy expenditure are prone to errors and lead to huge disturbances to the system (Hall, 2015). Hence, the robustness of an observer to disturbances is essential for accurate prediction of body composition. This paper, partly presented in (Karimi and Rao, 2014), is based on the dynamic behavior of body weight based on macronutrient intake and the energy balance model. Here, two model-free control algorithms for body weight management using a priori knowledge of control input and a switchingbased PI controller are presented. The energy expenditure of the body is regarded as the input control to the system. Body components are estimated using a dynamic observer based on daily measurement of total body weight supplemented by periodic measurement of individual body components. Next, control allocation problems are formulated using FL/SMC as linear algebraic equations, and input constraints and optimization issues are addressed. Finally, effectiveness and robustness of the proposed algorithms are demonstrated through simulations.

II. PROBLEM DEFINITION
The major components of human body mass are fat and lean masses and both of these factors as well as total body mass need to be managed.
The goal of this work is to propose controllers that suggest daily energy intake or physical activity to track a preferred trajectory of weight/fat reduction or increase. It is suitable for professional athletes, the elderly individuals at risk of Sarcopenia, people with disabilities or sickness and those who need to precisely manage their weight/fat/lean due to medical reasons or less body weight fluctuation.
Since the controllers are robust enough, some deviation from their suggestions is tolerable, and good tracking can be still practically achieved. So, the human preference issue is considered implicitly.
When it is intended to control fat/lean mass, we need to have daily estimation of fat/lean mass to use in the controller whether the controller is model-free or model-based. Since measurement of fat/lean mass is hard and expensive to do every day, we design an observer to estimate the body compositions using daily total body weight measurement and periodic fat mass measurement. The dynamic model, which encompasses fat and lean masses as system states, is used for observer design.
It is assumed that the subject is able to follow the control suggestions and their moods, energy intake and physiological behavior are normal and not pathological. Also, it is assumed that energy intake and expenditure are reasonably precisely measurable.

III. BODY WEIGHT DYNAMICS BASED ON THE ENERGY BALANCE MODEL
To describe the energy balance in humans, different mathematical models have been developed. A comprehensive threecompartment model is presented in (Sentocnik et al., 2013) and (NavarroBarrientos et al., 2011).
The daily energy-balance (EB) equation is described as where EI represents the daily energy intake, EE represents the daily energy expenditure, and BM is the body mass of the person expressed in terms of fat (F), lean (L) and extracellular fluid (ECF).
The energy intake is based on the consumed food and its caloric value where ci indicates carbohydrate intake, f i and pi indicate the fat intake and the protein intake (all representing model inputs), respectively, and k i s are constant coefficients.
To track fat mass, lean mass and extracellular fluid, the following balance equations were used: where ρ F and ρ L are the energy density of the body fat and lean muscle mass respectively, ρ w is the density of water, ci b is the baseline carbohydrate intake, and the ratio r is the parameter describing the imbalance denoted by EB to the compartments fat mass and lean mass. This parameter, r, was defined in (Hall, 2007) based on the Forbes formula (Forbes, 1987), which was obtained after analyzing body composition data collected from many adults: Forbes found that this relationship was similar whether weight loss was due to diet or exercise. Prolonged exercise or a significant change in the protein intake may cause a different relationship for r. The daily energy expenditure is calculated as follows: where P A (input to the model) represents the energy spent on physical activity, T EF is the thermic effect of food, and RM R is the resting metabolic rate needed for basic physiological processes. Equation (8) can be also written as (9) where δ = P A BM represents the physical activity coefficient and the constant K depends on the initial conditions and is calculated using Equation (1) and Eqs. (4) -(6) in the steady state: EB =Ḟ =L =ĖCF = 0 Therefore, for the steady-state conditions, Eq. (9) can be rewritten as follows: where the bars over the variables indicate the steady state of the corresponding variables. The obtained model is used for an optimal controller, observer design, and simulations, which will be presented in the following sections.

CONTROLLER DESIGN
Let the control objective be steering any combination of body composition masses, including total body mass, to a desired reference value/trajectory without using the dynamic model in the controller. It is considered that physical activity is the only control input to the system and that it conforms to a desired shape. The body weight dynamics (4)-(6) can be formed asẋ Differentiating the output (12) with respect to t yieldṡ Introducing from (15) a constant,ḡ, representing the nominal value of g, we can rewrite (15) into the following equation: where H(t) denotes the total nonlinearity, which is expressed as The desired error dynamics is defined with an asymptotically stable linear time invariant system as in the following: The linearizing feedback control law results in Note in equation (19) that the time delayed estimation of the total sum of system nonlinearities is used in place of the total sum of system nonlinearities. Namely, Combining equations (19) and (20), the time delayed control law ( Fig. 1(a)) can be obtained as The stability condition was shown in (Youcef-Toumi and Wu, 1992). If a specific trajectory for weight loss is desired then, we can address the tracking problem. In this controller, not only the current and previous outputs are used, but the previous input is also considered, which could make it more efficient for tracking purposes. In many circumstances, a modest initial increase in physical activity is preferred at the beginning of the program. Switching-based set-point regulation is an alternative way to move the body weight to a desired value considering the The parameters δ 0 and y 0 are the initial values for the δ and y, respectively. To steer the human body to a particular weight, the following algorithm is proposed (see Fig. 1 where δ P I is a proportional-integral controller as The control parameters are chosen in such a way that δ P I is greater than δ IN C at the beginning. So, the control action is started with δ IN C and then switched to δ P I when it is less than δ IN C .

OBSERVER DESIGN
The state vector containing fat, lean and extra cellular fluid masses is not easy to measure directly every day. Therefore, because of the cost and inconvenience, it is desirable to estimate these from the system input and body weight.
The observer is designed to provide real-time estimates of inaccessible dynamical states that might be required for the implementation of control laws.
Substituting r from (7) into (4) and (5) leads to To cope with the non-linearity, the following linear approximation is made Constants a and b must be determined based on the regression. Then, Eqs. (24) and (25) are rewritten regarding the approximation as well as expansion of the EB components obtained from Eq. (1).
For observer design, we arrange the obtained system of differential equations of (27), (28) and (6) as the following class of nonlinear systems: and designing an observer for Eq. (29) is feasible if the pair (A,C) is observable.
The Luenberger observer is well-known and widely used for time-invariant linear systems in order to estimate the state vector when that is not directly measurable. Consider the following extended Luenberger observer for the system (29)-(30) (Pagilla and Zhu, 2004): where ǫ 0 ≥ −λ 2 and G 1 is chosen such that A − G 1 C is Hurwitz, and G is the observer gain matrix. Let the estimation errorx in which P 0 is positive definite matrix. Then, by considering the following Lyapunov function candidate the observer gain G is obtained as In reality, it may not be possible to measure precisely both energy intake and energy expenditure every day. To overcome this problem, it is assumed that the measurement of body components is performed periodically. Hence, in Eq. (34) with ǫ 0 = −λ 2 the following soft switching observer is presented (see Fig. 2 in which C 1 = [1 1 1], C 2 = 1, G i s are observer gain matrices, T is the period that measurement of components is performed, and 0 ≤ q ≤ 1 is a weighting factor for soft switching: k q is appropriately determined. Using intermittent measurement of full states in addition to daily body weight measurement, the degree of observability would be increased.
The influence of EI = 3492(1 + 0.02 * rand), δ = δ(1 − 0.2 * rand) disturbances on controllers and the soft switching observer are investigated in the following subsections. The variable rand is a MATLAB function that generates uniformly distributed pseudo-random numbers between 0 and 1. The coefficient of 0.2 for disturbance in the physical activity could Since EI is multiple times greater than physical activity (δ · BM ), the coefficient of rand in EI is chosen much less frequently than the coefficient of rand in δ.
For the observer (39), measurement of the body components is done every 90 days with the following parameters hereafter: Body mass controller Next, we address how to control body weight according to a desired cubic polynomial function using the controller (21) even in the presence of disturbances. The initial and final values of the body weight are 100 kg with slope -0.05 and 70 kg with slope 0, respectively. The control parameters considered in this simulation areḡ = 0.1 and Π = 10. Since the controlled output is body weight and it is measurable directly, controlling based on observer is not needed.
The results of the body weight control are shown in Figs. 3-4. The lean, fat and ECF masses are bounded without fluctuation while body weight is being controlled (Fig. 3). The controller error is small in the presence of disturbances, which implies good performance of the controller. The control input δ in Fig. 4 has a dome shape using a time-delayed controller for a cubic polynomial trajectory.
The results of the switching-based controller are presented in Figs. 5 through 6. The control parameters chosen for this controller are: It is seen that the desired body weight is achieved even in the presence of disturbances. The control input δ in Fig. 6 has a hat (ˆ) shape that is different from the dome shape of the time-delayed controller. We find that although the maximum of the dome shape is lower than the maximum of the hat shaped exercise profile, the desired weight can be achieved.

Fat mass controller
Here, the objective is to control fat mass to bring it to a desired cubic polynomial function using the time-delayed controller. The initial and final values of the fat mass are 30 kg with slope -0.02 and 15 kg with slope 0, respectively. All controller and observer parameters are the same as the 1st simulation for body mass control. Since the controlled output is fat mass and direct measurements are only available periodically, observer-based control is necessary. Simulation results of the controller and observer (39) are represented in Figs 7-9. In addition to the decreasing and bounded body composition masses in Fig. 7, small observer errors in Fig. 8 are achieved. There are some sharp changes in fat mass error and spikes in δ (see Fig. 9), which come from rapid observer corrections due to periodic measurement.
The last simulation shows the results of a switching-based controller for the regulation of fat mass using the observer of (39) depicted in Figs. 10-12. The initial and final values of the fat mass are 30 kg and 15 kg, respectively. All parameters are similar to the parameters of the same controller for body mass, but k 2 = 0.7.
In summary, observer-based time delayed control methods perform well in the trajectory tracking problem as shown in the results of the fat mass controller where at least one of the body component measurements is needed. In the case of total body mass control, the observer is not necessary in the time delayed controller because the body weight is directly measurable. Also, a switching-based controller works well for set-point regulation, and the same discussion is valid for requiring an observer for this controller.
V. CONTROL ALLOCATION CONSTRAINED OPTIMAL CONTROL DESIGN Let the control objective be steering any combination of body composition masses, such as body mass, to a desired trajectory. It is assumed that both energy intake and physical activity are the control inputs to the system. This shows overactuation and there are an infinite number of solutions. Hence, a control allocation procedure is required to find the best solution that fits within the objective and limitations of the problem.
The body weight dynamics (4)-(6) can be formed aṡ in which x = [F, L, ECF ], u = [EI, δ], y is a controlled output, C is a 1 × 3 matrix and It is presumed that the carbohydrate energy intake is proportional with total energy intake.
Differentiating the output (43) with respect to t yieldṡ Let the desired dynamics for the feedback linearization be defined asė y + λ f l e y = 0 orẏ =ẏ des − λ f l e y (48) Then, substituting (48) into (47) results in For sliding mode control (SMC), instead of setting the design surface temperature as the output, the sliding surfaces S = e y + λ sm e y dt are selected as the outputs. With only one differentiatioṅ S =ė y + λ sm e y =ẏ −ẏ des + λ sm e y = Cf (x, y) + Cg(x, y)u −ẏ des + λ sm e y (50) = −Γ · sgn(S) [Cg(x, y)] u = [ẏ des − λ sm e y − Cf (x, y) − Γ · sgn(S)] (51) Now approaching the system as a control allocation problem, we define the optimization problem as The objective function in (52) is given by the quadratic function of the control inputs in which W is a weighting matrix.
Since A is a full row rank matrix and the dimension of u is larger than the number of equations, the problem is redundant and has an infinite number of solutions. Now, the aforementioned control allocation problem with input limitation is solved using the fmincon optimization solver in MATLAB. The u i min and u i max should be within bounds so that the allocation problem becomes feasible. The threshold values defining the bounds could depend on various factors, such as physical limits and initial and boundary conditions.
Logically, to stop an increase in body mass, the maximum allowable amount of energy intake would beĒI at the beginning of the program. It means that the first component of u s = [u s1 u s2 ] should be equal to or less thanĒI at the initial time that is u s1 (t = 0) ≤ĒI. Hence, the minimum value for energy intake changes over time and is proposed as (54) where the parameters ρ 1 , ρ 2 and τ are for determining lower bound, upper bound and speed of convergence from upper bound to lower bound of u s1 to design appropriate behavior. At the beginning of treatment, EI min is equal toĒI − ρ 1 (1 − ρ 2 ) and after the passing some time, it isĒI − ρ 1 .

SIMULATION RESULTS
In this section, we consider simulations that rely on the proposed allocated controller for comparative analysis and performance investigation. The control objective in each simulation is computing energy intake and physical activity coefficients using (52) to track a desired cubic polynomial function of total body mass in the presence of uncertainty, noise and disturbances. The initial and final values of the body weight are 100 kg with slope -0.05 and 70 kg with slope 0, respectively. The control parameters considered in this simulation are λ f l = 0.7, λ sm = 0.1, W 11 = 0.2, W 22 = 1000, W ij = 0, Γ = 0.01,ū = [3500 0], ρ 2 = 1, τ = 5,ĒI = 3500 For true comparison, the bound of tracking errors for both controllers are considered to be equal so that λ sm would be 7 times greater than λ f l . The applied uncertainty to the system and noise to the measured daily body weight are r = (1+0.5 * rand) * r and bm = bm+0.1 * rand, respectively and EI = 3492(1 + 0.01 * rand) and δ = δ(1 − 0.1 * rand) disturbances inserted in to the inputs. The rand is a MATLAB function that generates uniformly distributed pseudo-random numbers between 0 and 1.
Here, the results of u 1 min = EI min = 3000 (i.e. ρ 1 = 500) is considered and the results are given in Figs. 13-15. As long as the energy intake meets the lower bound, increases in the physical activity coefficient occur (see Figs. 14 and 15). The sliding mode controller shows in Fig. 14 a significantly smaller increase in δ than the feedback linearization one.
Instead of total body mass, we can consider any combination of body composition for control purposes by appropriate determination of matrix C in Eq. (12). Similar results are obtained when the fat mass is considered to be controlled.

VI. CONCLUSION
This paper has presented two model-free controllers for human weight management with physical activity as the control input. The first method is based on time-delayed feedback of the system input for approximate linearization and the second one is a switching-based controller. To estimate the daily body composition (fat, lean and extracellular fluid), a soft switchingbased observer using human body weight dynamics has been proposed. This is based on daily measurements of body weight and periodic measurement of whole body composition. This paper also has addressed weight management as a control allocation problem with energy intake and physical activity coefficients as the two inputs. Based on dynamic behavior of body composition, feedback linearization and sliding mode controllers have been used to form linear algebraic equivalence of the nonlinear controllers. Then, an input-constrained nonlinear optimal controller was designed using the constrained linear least squares method. Moreover, a subject may prefer that the start point of energy intake or expenditure is close to the current one. So this preference has been considered in the model-free set point control and optimal-model-based control. Also, it could be imposed through the reference trajectory planning of the model-free tracking control.