Reliable Fault-Tolerant Model Predictive Control of Drinking Water Networks
Abstract
This project proposes a reliable fault-tolerant MPC applied to DWTNs. The proposed approach the proposed approach allows to carry out a degradation analysis of the system in terms of performance and reliability. As a result of this analysis, the MPC controller design can be modified adapting the constraints such that the best achievable performance with some pre-stablished level of reliability will be achieved. The proposed approach will be tested on the Barcelona Water network.
Full text
Treball de Fi de Màster Master’s degree in Automatic Control and Robotics Reliable Model Predictive Control of Drinking Water Networks MEMÒRIA Autor: Iván Martinez Hurtado Director: Vicenç Puig Cayuela Director: Carlos Ocampo-Martinez Convocatòria: Setembre 2016 Escola Tècnica Superior d’Enginyeria Industrial de Barcelona
To B. Fabiola
"Nonlinear Model Predictive Control of a Quadrotor" 5 Abstract This project proposes a reliable Model Predictive Control (MPC) applied to drinking water networks (DWNs). The system reliability is calculated by structural analysis of the whole system taking into in account the network topology. In this form it is possible to describe the system reliability as a function of actuators reliability. Therefore by using CSP the system reliability can be controlled by imposing some new control actions bounds. This approach maintain the convexity of optimization problem avoiding problems with local-minima. The methodology, tested by simulation in the Barcelona DWN, shows that it is possible to control the evolution of the reliability level of the system by tuning only one parameter and also to describe a trade-off between reliability and operational costs. Other approaches that include reliability inside the controller that are based on the actuators reliability does not consider the connections between the actuators and therefore new control bounds are established without taking into in account possible parallel paths. With this new approach presented in this project the results shown how through the redundancy of optimal solutions it is possible to increase reliability levels without economic cost. Model predictive control, reliability control, structural analysis, drinking water networks, constraint satisfaction problem
"Nonlinear Model Predictive Control of a Quadrotor" 7 Acknowledgement This project would have been impossible for me without the tireless help of my advisors Vicenç and Carlos. A few months ago I went to Vicenç to ask for a challenging research project. Since that request I always felt integrated and respected and the assistance received has been constant. I am also very grateful to all the colleagues of the SAC and the IRI that never hesitate to help when I need it. I would also like to thank all the colleagues who have helped me improve in every aspect of my life. Those who have made my time in the university more enjoyable, whether teaching me or having coffee with me. Por supuesto no puedo olvidarme de mi familia, a la cual escribiré en castellano. Ellos siempre han sido un ejemplo de esfuerzo y trabajo. Sin su apoyo incondicional y sin su confianza en mi, demostradas durante todo este largo camino, seria muy probable que nunca hubiera llegado hasta aquí. Para terminar tengo que darle las gracias a Fabiola por su paciencia, fuerza y amor infinitos y por ayudarme, sobretodo, en los peores momentos. Iván Martínez Hurtado Barcelona, June 2016
"Nonlinear Model Predictive Control of a Quadrotor" 9 Notation General Operators and relations |such that ∈is element of ∀for all ←assign right-hand side to the left-hand side →mapping General Sets and Spaces Rset of real numbers R+set of non-negative real numbers, defined as R+,R\(−∞,0] Rnspace of n-dimensional (column) vectors with real entries Rn×mspace of nby mdimension matrix with real entries Zset of integer numbers Z+set of non-negative integer numbers ⊂subset General Sets and Spaces min minimum max maximum
16 LIST OF FIGURES 4.5 Control action 5 (with vs. without) Reliability constraints (α= 5 ×10−3)........ 52 4.6 Total system reliability evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 4.7 Final System Reliability vs. Economical Cost for different α.............. 53 4.8 Control input 5 (with vs. without) Reliability constraints (αu= 5 ×10−3)and Ra0= 0.954 4.9 Control action 5 (with vs. without) Reliability constraints (α= 5e−3and Ra0= 0.7) . . 55 4.10 Final System Reliability vs. Economical Cost for different Ra0............. 55
"Nonlinear Model Predictive Control of a Quadrotor" 17 List of Tables 4.1 ComputationalTime ................................... 49 4.2 Final System Reliability vs. Economical Cost . . . . . . . . . . . . . . . . . . . . . . 53 6.1 BudgetBreakdown .................................... 59
"Nonlinear Model Predictive Control of a Quadrotor" 19 Chapter 1 Introduction Drinking water is provided by means of a drinking water network (DWN) to consumers and industry. DWNs are large-scale systems that can be structurally organised into several layers [5] • Supply layer, composed of water sources, large reservoirs and also natural aquifers. • Transportation layer, linking water treatment and desalination plants with reservoirs distributed all over the city. • Distribution layer, used for meeting consumer demands and linking reservoirs with consumers. This project is focused in the transportation layer also called Drinking Water Transport Network (DWTN). This networks are large-scale, expensive and strategical systems that need a sophisticate control strategies in order to achieve performance and robustness. This project presents a Reliable Model Predictive Controller based on topology reliability with the purpose to incorporate in a further step a fault tolerant control. 1.1 Motivation Water is essential for life. For this reason is considered a human right and a strategical resource. Water is a renewable resource, however the overpopulation in the large urban areas make the water sup-
20 CHAPTER 1. INTRODUCTION ply something critical. Therefore it is essential to work on improving the supply, treatment and transport of water in other to have always good quality water and saving operational cost. For this reason it is necessary to improve the actual control systems and adapt them in order to work with a DWTN. At this moment exist lot of literature talking about DWTN. Specifically for Barcelona DWTN exist literature that implement MPC to Barcelona DWTN endowing inside the MPC reliability analysis and fault tolerant control. Since this project the system reliability has been controlled actuator by actuator without taking into in account the topology of the network. Therefore the motivation of this project is to include inside the controller the reliability of the whole system taking into in account the topology of the network. In this form is possible establish a criteria that regulate not only the actuators reliability but the total system reliability. This reliability is understood as the probability to reach all of demands in a period of time that is interesting in order to guarantee the continuous water demand flow. 1.2 Project Objectives This project is based on extended MPC for large-scale networked systems subject to constraints and to persistent stochastic disturbances. Particularly, the management of DWNs within a multiobjective optimisation framework will be studied, considering water demands as system disturbances. The objectives of the project are: [1.]To establish a criteria and equations to determine the reliability of the whole system based on the reliability of the actuators and taking into in account the network topology. Defining reliability as the probability to reach all water demands. To design a method to control the loss of DWTN reliability in a certain time. To include the reliability inside the MPC controller based on the control actions contraction. To implement the MPC with Reliability constraints on the Barcelona DWTN as a real case of study and to extract relevant results. 1.3 Project structure The dissertation is organized as follows:
Nonlinear Model Predictive Control of a Quadrotor 21 Chapter: 2 Background This chapter introduces some relevant information about MPC and the application of MPC to a drink water transport networks. Moreover has been presented a discussion about the state of the art of reliability, more specifically about how to describe a reliability of drinking water transport networks from different approaches. Chapter: 3 Model Predictive Control with Reliability constraints This chapter presents mathematical preliminaries related with the inclusion of the reliability constraint inside the MPC. During the chapter have been explored different solutions and finally has been explained the selected one. As example of the selected solution has been included a test example with a simple drinking water transport network describing how the solution works and analyzing the implementation results. Chapter: 4 Implementation in the Barcelona DWTN In this chapter a description of the case of study has been provided. Moreover have been analysed the results obtained from the Barcelona drink water transport network as a case of study after the application of the proposed solution. Chapter: 5 Environmental Impact This chapter analyses the environmental impact of the project taking into in account different possible consequences if the solution is finally implemented in a drinking water transport network. Chapter: 6 Budget In this chapter it is possible to see a budget breakdown of this project. Chapter: 7 Concluding Remarks This chapter summarises the contributions made in this project and discusses the main concluding ideas and ways for future research.
"Nonlinear Model Predictive Control of a Quadrotor" 23 Chapter 2 Background This chapter presents the basic ideas and a literature review of the different topics related with the project. 2.1 Fundamentals of Model Predictive Control 2.1.1 General Consideration Model Predictive Control (MPC) is one of the most successful control technologies due to the capability to incorporate constraints and define a multiobjective cost function. The use of a cost function allows to describe the desired system behaviour and to specify preferences in a multi-objective optimal control problem. It is possible to specify whatever cost function but is highly recommended in the literature to use convex cost functions, like linear or quadratic ones. The most important part inside an MPC is the dynamic model of the system. This model is similar to one constraint of the optimisation problem but the dynamical model can be linear or non-linear, deterministic or stochastic, discrete, continuous or hybrid. More details about theory and dissing of MPC can be found in [1] and [8]. Since a DWTN is a large-scale system it is highly recommended to guarantee the optimization problem convexity. In this form a fast solvers can be applied and problems with local minima can be avoided. For this reason the dynamics of the system are simplified as a control oriented linear ones
24 CHAPTER 2. BACKGROUND and the cost functions are in a linear and quadratic form. 2.1.2 Problem Statement A generic MPC uses information about the present and the past to predict the system evolution over a given period of time (prediction horizon) and solve an open-loop optimization problem to compute a sequence of control actions that achieve maximum performance satisfying the problem constraints. After the prediction only the first control action is applied. Therefore the procedure is repeated in each step. The optimization problem can be described as: Cost Function, J∗= min uk,...uk+Hp−1 Hp−1 X i=0 li(uk+i,xk+i)(2.1) Subject To: Dynamics, xk+i+1 =f(xk+i,uk+i) + dk(2.2) And physical constraints, xk+i∈X(2.3) uk+i∈U(2.4) Hp is the prediction horizon, xkis the system state vector, ukis the control input vector, liis the stage cost, fiis the state system evolution, dkis the disturbances vector and X,Uare the physical bounds. Since the Hp ,∞the optimization problem is a finite horizon open-loop optimization problem.
Nonlinear Model Predictive Control of a Quadrotor 25 2.2 Model Predictive Control of Drinking Water Transport Networks A DWTN can be described as a large-scale flow system which is composed of different hydraulic elements [2] like: valves, pumps, tanks, pipes, etc. With the purpose of transport water from the sources to the demands, satisfying pressure and potability levels. From the side of control is possible to separate the elements into two classes, active elements like pumps or valves or passive elements like nodes or tanks. In this form is possible to construct a model by associating a control action for each active element and a state for each passive elements. On the other hand DWTN requires a instrumentation in order to obtain sufficient information about the system state and a telemetry system in order to do a tele-control of the system, which is indispensable due to the scale of a DWTN. DWTN are redundant systems with a lot of states and actuators, moreover the demands of water can be predicted in a stochastic form. Therefore an optimal management of this systems becomes a hard task. Moreover DWTN are expensive and strategical systems and the operational cost are also important. For this reason in the last years important projects around DWTN have been strongly supported. 2.2.1 Control Model DWTN can be synthesized as a interconnection of nrsources, nxtanks, nuactuators (pumps and valves), nddemands and nqintersection nodes. Then the system can be described with a control-oriented lineal discrete-time model for all time instant k: xk+1 =Axk+Buk+Dddk(2.5) 0 = Euuk+Eddk(2.6) xk∈Rnxare the tanks water volume, uk∈Ruxare the control inputs and dk∈Rndare the demands. Eq. (2.5) describes the dynamics of the tanks volume and (2.6) is the statics equation that describes the mass balance into the nodes of the system. Therefore A∈Rnx×nx,B ∈Rnx×nu,Dd∈Rnx×nd,Eu∈ Rnq×nuand Ed∈Rnq×ndare time-invariant matrices that describe the relation between states, actuators and disturbances.
32 CHAPTER 3. MODEL PREDICTIVE CONTROL WITH RELIABILITY CONSTRAINTS 3.2 Proposed solution On the other hand it is possible to convert the reliability bound to a control action bound since the system reliability only depends on control inputs and some constants values. In this project is proposed to use a CSP to find the new actuators for which is preserved the reliability constraint. 3.2.1 CSP concept A Constraint Satisfaction Problem (CSP) is defined as the problem of finding a fixed set of variables satisfying a given set of constraint. In CSP the variables v1,v2,...,vnare defined as a finite sets D1,D2,...,Dn. This sets are also called the variables domains. CSP can be formulate as a 3-tupla H=V ,D,C on: 1.2.3.4.• V={v1,...,vn}is a finite set of variables •D={D1,...,Dn}the domains set of the variables •C={c1,...,cm}the set of constraint related with the variables V The solution of a CSP S(H)is a set of solutions {Z1,...,Zn} ⊂ Dthat satisfy the set of constraints C. One variable is consistent if for (z1,...,zn)∈S(H), [11]: ∀zi∈Zi⊂Di∃(z1∈D1,...,zn∈Dn)(3.10) 3.2.2 Including the CSP inside the MPC Therefore, the idea is to synthesise the network as a connection of actuators from each source to each demand by using (3.3), (3.4) and (3.5). After that by using (3.6) is possible to describe the whole system reliability in terms on reliability of each actuator. Moreover the actuator reliability only depends on two factors: a temporal factor and a control input factor. So finally it is possible to associate the total system reliability to the control inputs of all actuators.
Nonlinear Model Predictive Control of a Quadrotor 33 Now, transferring the CSP theory to the case of study the CSP has been described as follows: •V={u1,...,unu,α}, the control actions and the reliability degradation •D={U1,...,Unu,[α,α]}, the actuators and reliability bounds •C={α=f(u)}, the function that connects reliability and control actions. As a result is obtained a set of solutions Zthat are the new control inputs bounds. On the other hand the reliability is computed each step closing the CSP loop, Figure 3.1. Figure 3.1: Methodology Flowchart Therefore it is possible to contract the control inputs in order to preserve a desired level of reliability. Therefore this method preserve the convexity of the optimization problem. umin →CSP →umincsp (3.11) umax →CSP →umaxcsp (3.12)
34 CHAPTER 3. MODEL PREDICTIVE CONTROL WITH RELIABILITY CONSTRAINTS 3.3 Algorithmic implementation In this subsection the general algorithmic implementation and the problematic around the CSP computation has been explained. Algorithm 1. Algorithm 1 Computation of new actuator bounds 1: set(α) 2: set(Ra0) 3: Rt0←Network Topology(Ra0) 4: for k= 1 to Horizon of Simulation do 5: uk←solve(CSP ) 6: uk←solve(MP C) 7: Rak←Reliability Computation(uk) 8: Rtk←Network Topology(Rak) 9: end for 3.3.1 Reachability analysis First of all before the CSP it is necessary to compute the reliability equations that describe the system. As has been said before in 3.1 the total system reliability has been calculated by decomposing the system into a small subsystems. These subsystems are the different paths that exist in order to satisfy each demand from each source. It is possible to extract the equation of the reliability by hand if the system are not too much large. In 3.4 has been explained a test model on it is possible to compute the reliability equation by hand. However it is not the case of the Barcelona DWTN that are a large-scale and complex system. For this reason has been implemented an algorithm in order to identify each path for each demand and then construct automatically the reliability equations. The first step is to describe the network as a matrix by using (2.5) and (2.6). With the matrix description it is possible to construct a graph of the network. A graph is a description based on the connection of the system elements. In a graph each vertex is connected to others vertexes trough edges. For this system the vertexes are the tanks, the nodes and the sources and the edges are the actuators. The connection of the states has been establish by using the matrix Band E(2.5). In these matrices the union between the states (tanks and nodes) and the actuators is represented using numerical nonzero values. So, the algorithm goes over all actuators (columns) an look for non-zero values, then by looking the sign of the values it is possible to determine also the direction of the connection. There-
Nonlinear Model Predictive Control of a Quadrotor 35 fore for each actuator has been established a link between the states taking into in account the direction of the connection. Moreover in these variables ,called in the code links, are added the actuator that connect the states as extra information. In the same way the connection between the sources and the states has been added. The following step is to create a matrix that describe the relation between the states by using the links computed above. This relation takes into in account the direction of the actuator. Its means that maybe is possible to go from state "i" to state "j" but is not possible to go from state "j" to state "i." Now it is necessary to determine the initial vertexes that in this case are the vertexes that have direct relation with the disturbances. The relation between states and disturbances has been described by the matrices Bp and Ed (2.6) in 2.2.1. Starting from each disturbances (initial vertexes) the code analyze the connections that exist with other vertexes and write down a matrix with one column for each possible path. The algorithm takes the vertexes found in the last step and repeat the process growing the matrix. Finally when the vertex analyzed correspond to a source vertex the algorithm break the loop and continue looking for an other branch. Finally all paths end in a source vertex its means that all of possible paths in order to satisfy one demand have been found. Therefore the algorithm is repeated for each demand (disturbance) in order to find all paths of all demands. Moreover the algorithm takes into in account the possibility that exist one or more loops in the network. A loop is an infinite close path that the connection between the states form. To avoid loops, when the paths are found, the code reject all paths that have more than one time the same vertex. The MatLab code of this algorithm can be found in Appendix B. This process has been executed one time since the topology of the system is always the same. Therefore it is possible to use the paths matrices extracted from the code in other projects if is it necessary. On the other hand the code is useful in order to determine the paths of other systems with no effort since the code are made for the general case and not specifically for the Barcelona DWTN. 3.3.2 Writing down the input file for IBEX The solver selected to compute CSP is the IBEX. IBEX is a C++ library and is execute outside Mat- Lab. The C++ program is waiting one flat text file with the inputs of the procedure on the inputs are
36 CHAPTER 3. MODEL PREDICTIVE CONTROL WITH RELIABILITY CONSTRAINTS the constants values, the variables and the constraints. Full code is in Appendix C Due to the reliability constraint is made for each step and the values of the actuator reliability varies in each step the input file also varies in each step. Therefore becomes essential one code that autogenerate the input file in each step. The code write the actual reliability of each actuator as a constants values and the physical bounds of the actuators as a variables. Then it write two equations one is the eq. that constraint the maximum total reliability degradation. The second equation is the total reliability in terms on the actuators taking into in account the topology of the system. This equation are write by using the paths matrices obtained above. Therefore each path for each demand has been taken and using the 3.8, step by step, the total equation is written down. To get an idea, for the 17 tanks model of Barcelona DWTN, this equation occupies 100 pages in Arial 10 points. 3.3.3 C++ IBEX program As has been said before the selected solver to compute the CSP is the IBEX library. Before to explore this solution others solutions has been explored like for example Interval Peleer but finally with the others solutions the results thus achieved are not good when the problem become too heavy. IBEX is a C++ library for constraint processing over real numbers based on interval arithmetic. IBEX library is easy to install in a Linux or iOS and is possible to install in a Windows computer following the documentation in the IBEX web page "www.ibex-lib.org". IBEX is a ideal library to work with this kind of problems. Moreover include a set of defined functions that simplifies a lot the task of compute a CSP. In this case the C++ code consists in: to read of the input file, to set the solver parameters, to call the solve function, to read and simplify the solutions and to write the solutions in a text file. Code in Appendix D. The main problem with IBEX is that uses box variables and compute a multidimensional solution. It means that the new actuators bounds depend on each other and the possible solution is an hypervolume inside of a polytope. This would be a problem because the purpose is to maintain the optimisation problem as a convex problem and it is not guaranteed in this case. Therefore after the computation of the CSP the solution is simplified taking only the higher minimum and the lower maximum introducing a conservative policy in the method.
Nonlinear Model Predictive Control of a Quadrotor 37 In Figure 3.2 has been drawn a representation of this problem for a 2 actuator system. In the left side is represented the solution extract from the IBEX solver that is a two dimensional solution. In this solution the maximum value for the actuator 1 depends on the value of the actuator 2 and vice versa. It has sense since the total reliability depends on the combination of control actions so, if one actuator is degrading the system a little maybe the rest can degrade more the system and even satisfy the reliability constraints. (a) Multidimensional solution (b) Multiple one-dimensional solution Figure 3.2: CSP solution simplification Then the solution is simplified as has been said before obtaining the blue area. It is possible to see that for the blue area the actuator 1 and 2 maximums are a constant values and no depends on the other actuator value. Therefore the solution can be represented like in the right side as a two unidimensional solution. However also is possible to see how the simplification despise the grey area that are a set of valid solution. This example can be extrapolated to an n-dimensional one. In the Barcelona DWTN there are 61 actuators therefore with this simplification it is possible to convert a complex 61-dimensional space into a 61 one-dimensional space. Moreover into the optimization problem is use the same control input bound for all the prediction horizon, that are also conservative. At this point seems difficult to control the reliability of the system analytically due the the fact that the method is very pessimistic. On the other hand it is possible to
38 CHAPTER 3. MODEL PREDICTIVE CONTROL WITH RELIABILITY CONSTRAINTS tune experimentally αin other to obtain the desired reliability. It is important to mention that the evolution of the reliability depends on the actual reliability of all the actuators. For this reason it is necessary make the new actuators bounds computation on each iteration. It is specially important when the differences between actuators reliability are high. 3.4 Application to Test model The purpose of this section is to implement the method that has been described above in a test system. The motivation to do this is twofold. For one side the test model is simple and do not take to much computational time in other to simulate them, therefore it is easier to extract results and to test some variations. The second motivation is to explain the method and the equations in a not too much complex example. 3.4.1 Case of study description The test model consist in a small part of the Barcelona DWTN.
Nonlinear Model Predictive Control of a Quadrotor 39 Figure 3.3: Test model diagram The test model has 4 demands nd= 4, 3 tanks nx= 3, 2 nodes nq= 2, 6 actuators nu= 6 and 2 sinks nr= 2. Figure 3.3. It is important to remark that not all of actuators have the same bounds and also tanks have different capacities. The optimisation of the control action is achieved through the minimisation of the operational cost, that includes the electrical cost associated with the transport and the cost associated with the exploitation of the water resources, satisfying the demands in each consume sector. On the other hand the electricity tariffs change depending on the time of the day. Due to the fact that the water demands describes a cycle of 24 hours the prediction horizon (Hp)is 24 hours and the sampling time (Ts)is 1 hour. 3.4.2 Implementation over the test model Following the method the first step is to describe the reliability of the whole system decomposing the system in connections of smaller subsystems. It is possible following the methodology explained before in 3.1
40 CHAPTER 3. MODEL PREDICTIVE CONTROL WITH RELIABILITY CONSTRAINTS The total reliability of the system Rgis represented by using (3.3). For this system with 4 demands: Rg(k) = Rd1Rd2Rd3Rd4(3.13) Then using (3.4) is possible to decompose the demand reliability Rd. For demand 1: Rd1(k)=1−(1 −R1path1)(1 −R1path2)(3.14) Now is possible to compute the reliability of the both path (R1path1and R1path2) that demand 1 has in terms on the reliability of actuators Raby using the (3.5). R1path1(k) = Ra4(3.15) R1path2(k) = Ra1Ra2Ra5(3.16) Combining (3.15) and (3.16) with (3.14), Rd1(k)=1−(1 −Ra4)(1 −Ra1Ra2Ra5)(3.17) On the other hand demands 2, 3 and 4 do not have parallel paths, Figure 3.3. Therefore is possible to simplify the (3.4) : Rd2(k) = Ra1Ra2(3.18) Rd3(k) = Ra1Ra6(3.19)
Nonlinear Model Predictive Control of a Quadrotor 41 Rd4(k) = Ra1Ra3(3.20) So finally substituting (3.17), (3.18), (3.19) and (3.20) in (3.13) the system reliability equation in terms on actuators reliability is obtained. Rg(k) = (1 −(1 −Ra4)(1 −Ra1Ra2Ra5))Ra1Ra2Ra1Ra6Ra1Ra3(3.21) Furthermore it is possible to describe the actuators reliability as: Ra1(k) = Ra10e−λ0 1e(β1|u1|(k))t(3.22) Ra2(k) = Ra20e−λ0 2e(β2|u2|(k))t(3.23) Ra3(k) = Ra30e−λ0 3e(β3|u3|(k))t(3.24) Ra4(k) = Ra40e−λ0 4e(β4|u4|(k))t(3.25) Finally is possible to use (3.22), (3.23), (3.24) and (3.25) with (3.21) obtaining a expression of the reliability of whole system only in terms on initial reliability of actuators, constant parameters of actuators and the control action. Is suppose that the actual reliability of each actuator is know or can be estimated. Therefore it is possible to relate directly the system reliability with the control actions. By using (3.3.2) is possible to determine the new bounds of Rt(k+N)by fixing the tune parameter αand computing the actual system reliability Rt(k). Therefore using CSP the Rt(k+N)bounds are propagated by using (3.22), (3.23), (3.24), (3.25) and (3.21) obtaining finally a new actuators bounds. Of course as it have been said before this bound contraction has been computed in each iteration. In this point is possible to see how the method works by present some results. As it has been said before the reliability constraint is actually convert into a control action constraint. For loose reliability
48 CHAPTER 4. IMPLEMENTATION IN THE BARCELONA DWTN function (2.12). As has been explained before the economical cost is associated to 2 factors (2.9). One of them is the electrical cost that is related with the electrical tariff. In Barcelona the cost of a kWh is not always the same and it is cheaper during the night. For this reason and in order to save money more electricity is expended during the night. The prediction horizon is 24 hours because the system and also the electrical tariff have periodicity of 1 day. The sampling time is 1 hour. Figure 4.1: Barcelona DWTN 17 tank model 4.2 Results In this section have been explained the results obtained from the application of the approach explained during the project to the Barcelona DWTN. The first result is the analysis of the computation time expend during the simulations. All of simulation are computed in the same PC with an AMD phenom X6 1090T at 3.2 GHz CPU and 8 GB of
Nonlinear Model Predictive Control of a Quadrotor 49 DDR3 RAM, without the support of video card. Also all of simulation have the same simulation horizon (192 hours), Table 4.1 Table 4.1: Computational Time Time MPC (min) % MPC Time CSP (min) % CSP Total Time (min) With α= 2 ×10−348 18.3 214 81.7 262 With α= 5 ×10−340 16.6 201 83.4 241 With α= 2 ×10−238 15.5 206 84.5 244 Without CSP 39 100 0 0 39 The percentage of the time used in order to compute the CSP will be discussed below in the conclusions chapter, but the main conclusion is that the solver used to solve the CSP is non-optimal for this application and for this reason the CSP computation is time-costly. On the other hand the time expend to solve the simulation is practically the same for all simulation with the exception of the simulations with a very restrictive reliability constraints. When the reliability constraint are more important, due to have lower values of αor because the system reliability is low, the computational time increase significantly. The next point is the umax analysis. As it happens the previous simplified model not all the actuators bounds are affected with the same severity. For example actuator 5 (Figure 4.1) is important because is the only way to satisfy the demand 3. Other actuators are also important because are involved in a lot of demand paths, for example actuators 12, 16 or 61. Others actuators like actuator 35 are not so important because exist a parallel path in order to satisfy the demand, in this case demand 11. Therefore the degradation of each actuator affects to the degradation of the system in different ways and magnitudes. For this reason the new control action bounds resulting from the reliability constraints are different for each actuator. As has been said before the actuator 35 reliability is not so relevant because exist a parallel actuator. In Figure 4.2 it is possible to see that the actuator bounds are not affected by the reliability con-
50 CHAPTER 4. IMPLEMENTATION IN THE BARCELONA DWTN (a) Control input 35 (b) Control input 61 Figure 4.2: Maximum control input along the simulation straints. On the other hand the actuator 61 is important because is involve in a lot of demands. For this reason the actuators bounds decrease as more restrictive reliability constraint are impose. In Figure 4.2 also is possible to see that the bounds become more restrictive along the simulation time. As it has been said before the reliability of the actuators are exponential, its means that as less reliability more reliability the actuator lost for the same control action. This fact bring the result, as more work time, less reliability and more restrictive bounds in other to constraint the reliability of the whole system. On the other hand a new more restrictive control action bounds maybe not suppose a change in the control action along the simulation. It means that the actuator have a surplus and the new restriction no affects their behaviour. In this case the actuator is not affected by the reliability constraint, therefore the reliability for the actuators is not preserved. It is the case of actuator 61, fig 4.3. The previous case can be a problem if it is the case of all of actuators because, if it happens, the new reliability constraint not longer affects the system behaviour. If it not the case interesting, the result is quite interesting because only the more sensible actuator, those who affect in a more relevant manner to the reliability of the system, change their behaviour in order to maintain the system reliability. On the other hand, since it is a dynamic system, it is possible that the evolution of the actuator bounds change and in some point the behaviour of the actuator must change in order to preserve the reliability constraints. On the other hand actuator 5 is affected by the new bounds, Figure 4.4. The new bound increase the
Nonlinear Model Predictive Control of a Quadrotor 51 Figure 4.3: Control action 61 comparison (with vs. without) Reliability constraints Figure 4.4: Control action 5 (with vs. without) Reliability constraints (= 1 ×10−2) final reliability of the actuator and therefore the final reliability of the whole system. In Figure 4.4 the actuator is able to pump almost all water during the night and scarcely during the day. Increasing the reliability constraint this is not longer possible, Figure 4.5. Therefore the operational cost increase in other to increase the reliability pumping water during the day.
52 CHAPTER 4. IMPLEMENTATION IN THE BARCELONA DWTN Figure 4.5: Control action 5 (with vs. without) Reliability constraints (α= 5 ×10−3) Figure 4.6: Total system reliability evolution So finally we can compare the system reliability evolution for different constraints. As it is expected as more restrictive constraint as more final reliability the system have. Also it is possible to see that as more time lapse more increment on the reliability. In Figure 4.4 and 4.5 it is possible to see that no all of constraint affects in the same manner to the system behaviour. Due to the fact that the system have more than one optimal solutions with the same economical cost is possible to change the behaviour of the system without an increment on the operational cost. For example pumping water from two pump instead of only one, therefore reducing the
Nonlinear Model Predictive Control of a Quadrotor 53 Figure 4.7: Final System Reliability vs. Economical Cost for different α effort of actuators but with similar cost. Or pumping water during more hours of the night with the same cost. This is a relevant result because actually is possible to increase the reliability of the system at cost 0. On the other hand if the reliability is crucial is possible to increase the restriction and preserve more reliability. It is possible by tuning αuparameter. In this case the problem converts into a trade-off between reliability and operational cost. Figure 4.7 and Table 4.2. Table 4.2: Final System Reliability vs. Economical Cost Final Relibility (Rt(192)) Economic Cost for 192 h. α= 2 ×10−30.89691 114.37 α= 3 ×10−30.89737 111.2 α= 5 ×10−30.89027 108.01 α= 7 ×10−30.88161 106.19 α= 1 ×10−20.87989 106.09 α= 2 ×10−20.86801 106.09 α= 3 ×10−20.85767 106.03 α= 5 ×10−20.85767 106.03 α= 1 ×10−10.86229 106.06 Without CSP 0.86229 106 At this point can be interesting to see what happens if the reliability of the system is lower that in the
54 CHAPTER 4. IMPLEMENTATION IN THE BARCELONA DWTN previous cases. Figure 4.8: Control input 5 (with vs. without) Reliability constraints (αu= 5 ×10−3)and Ra0= 0.9 Comparing fig 4.5 and 4.8 is possible to see that for the same αwith less system reliability the reliability constraints affects more and the bounds are more restrictive. Also is possible to see that during the hour 116 it is not possible to respect the new bounds, due to the fact that the new actuator constraint is a soft constraint the system is able to continue working. Fig 4.9 are the results when all of actuator of the system have a initial reliability equal to 0.7. Of course the bound are more restrictive and it is not possible to satisfy the new bound constraint. On the other hand and other relevant result in Figure 4.9 is how the bound evolves along the simulation time. As less reliability the system have more faster the bounds become more restrictive. Finally in Figure 4.10 we have the evolution of the cost versus the reliability of the whole system. It has sense that for more system reliability less cost since the bounds are less restrictive when the reliability are higher.
Nonlinear Model Predictive Control of a Quadrotor 55 Figure 4.9: Control action 5 (with vs. without) Reliability constraints (α= 5e−3and Ra0= 0.7) Figure 4.10: Final System Reliability vs. Economical Cost for different Ra0
"Nonlinear Model Predictive Control of a Quadrotor" 57 Chapter 5 Environmental Impact Water is a fundamental and limited resource. During the last years the overpopulation in the cities has resulted in a over-exploitation of this resource and nowadays supply the demand becomes a challenge. For this reason is very important to invest founds in order to improve the water networks and to develop new modern control systems that allow to save water and energy. Since the application of the new control techniques to the DWTN, like MPC, the performance of these has increase a lot, saving energy and water. With the new proposal explained in this project it is possible to achieve a new long term saving by using the reliability analysis in order to increase the life time and improving the state of the actuators. Increase the life time of something is always good in terms on environmental impact. Moreover actuators in better conditions implies less energy consumption and less water loses. On the other hand increase the life time of the actuators implies less number of failures. A failure in this kind of systems implies the waste of energy in order to satisfy the demands since the optimal paths are not able and in some cases the waste of water.
"Nonlinear Model Predictive Control of a Quadrotor" 65 Appendix A Main Code, Reliable Model Predictive Control 1 2% 17 de Abril de 2016 3% IRI-UPC 4 5close all 6clear all 7yalmip(’clear’) 8clc 9 10 h = waitbar(0,’Creating problem structure, please wait...’); 11 12 %% Source data & System Description 13 % load(’Data3tanks.mat’); % 3 tanks network 14 load(’Data17tanks.mat’); % 17 tanks network 15 % load(’Data63tanks.mat’); % 63 tanks network 16 % load(’x_initial.mat’); 17 18 % load(’Sources3tanks.mat’); 19 load(’Sources17tanks.mat’);
66 APPENDIX A. MAIN CODE, RELIABLE MODEL PREDICTIVE CONTROL 20 % load(’Sources63tanks.mat’); 21 22 23 %----------------------------------------------% 24 %------------ Begin Model-MPC data ------------% 25 %----------------------------------------------% 26 27 A = S.A; B = S.B.*3600; Bp = S.Bp.*3600; % x_{k+1} = Ax_{ k} + Bu_{k} + B_{p}d{k} 28 Eu = S.E.*3600; Ed = S.Ed.*3600; d = S.d; % 0 = E_{u}u_{k} + E_{d}d_{k} 29 % A = S.A; B = S.B; Bp = S.Bp; % x_{k+1} = Ax_{k} + Bu_{k } + B_{p}d{k} 30 % Eu = S.E; Ed = S.Ed; d = S.d; % 0 = E_{u}u_{k} + E_{d}d_ {k} 31 alpha1 = S.alpha1; alpha2 = repmat(S.alpha2,9,1); % costs data 32 umax = S.umax’; umin = S.umin’; % limits for control actions 33 xmax = S.xmax’; xmin = S.xmin’*0; % limits for control states 34 xs = S.xpenal’; % safety volumes 35 36 % Reliability Parameters 37 Lamda=ones(1,size(S.umin,2))*0.00002; %delta: temporal degradation 38 Beta=log(50)./S.umax; %beta in terms on (u/umax). log(x) x= max degradarion due to inputs respect to temporal degradation 39 % Alpha=0.998; % R(n)=Alpha*R(0) 40 uAlpha =5e-1; %Maximun allowed degradation due to the control actions 41 Ra(:,1)=ones(size(S.umin,2),1)*1; %Initial actuator Reliability
Nonlinear Model Predictive Control of a Quadrotor 67 42 Rt(1)=1; %initial whole system Reliability 43 bReliability = ’true’;%’True’ for performing realibility bounding 44 CSPtime=24; %Time between contraction: CSPtime=1 allways, =0 only one time, =24 one per day 45 46 dd= [d ; d]; 47 48 nx=size(A,2); % number of states 49 nu=size(B,2); % number of control actions 50 nd=size(Bp,2); % number of demands 51 ne=size(Eu,1); % Number of nodes (equality constraints) 52 ns=size(Sources,1); % Number of sources 53 54 p = [100;10;1;1000]; % vector priority weights 55 p1 = p(1); p2 = p(2); p3 = p(3); p4 = p(4); % priority weights 56 57 days=8; % days for the simulation 58 Hp = 24; % horizon of prediction 59 Hs = 24*days; % horizon of simulation 60 61 coefs = 0.8*xmax; % coeficients for initial conditions 62 x0 = [xmin’ + coefs’]’; % initial conditions 63 64 65 %% Run The pathfinder 66 67 FindPath(); 68 69 %% ------------ Begin MPC controller ------------% 70 71 uopt=zeros(nu,1); % u{0} initial optimal control action
68 APPENDIX A. MAIN CODE, RELIABLE MODEL PREDICTIVE CONTROL 72 73 for t=1:Hs 74 ti=clock; 75 t% publish current iteration 76 77 du=sdpvar(repmat(nu,1,Hp),repmat(1,1,Hp)); % \Delta u{k}=u{k }-u{k-1} 78 u=sdpvar(repmat(nu,1,Hp),repmat(1,1,Hp)); % u{k} 79 xi=sdpvar(repmat(nx,1,Hp+1),repmat(1,1,Hp+1)); % \xi{k} 80 ui=sdpvar(repmat(nu,1,Hp),repmat(1,1,Hp)); 81 x=sdpvar(repmat(nx,1,Hp+1),repmat(1,1,Hp+1)); 82 83 const = []; 84 obj = 0; 85 x{1}=x0; 86 87 % Run CSP 88 if ((t==1) || (strcmp(bReliability,’false’))) 89 umin_csp(t,:)=umin; 90 umax_csp(t,:)=umax; 91 elseif ((strcmp(bReliability,’true’)) && (t==2)) 92 fprintf(’Contracting actuators bounds’) 93 % Compute new actuators bounds 94 [alphamin(t,:),alphamax(t,:),umin_csp(t,:),umax_csp(t,:)]= ContractorCSP(Alpha,umin’,umax’,Lamda,Beta,Hp,Ra(:,t),’ solver_in.bch’,nd,nu,act_path,Rt(t)); 95 elseif ((strcmp(bReliability,’true’)) && (mod(t,CSPtime)==1)) 96 fprintf(’Contracting actuators bounds’) 97 % Compute new actuators bounds 98 [alphamin(t,:),alphamax(t,:),umin_csp(t,:),umax_csp(t,:)]= ContractorCSP(Alpha,umin’,umax’,Lamda,Beta,Hp,Ra(:,t),’ solver_in.bch’,nd,nu,act_path,Rt(t)); 99 else
Nonlinear Model Predictive Control of a Quadrotor 69 100 umin_csp(t,:)=umin_csp(t-1,:); 101 umax_csp(t,:)=umax_csp(t-1,:); 102 end 103 104 % Run MPC 105 for k = 1:Hp 106 107 dis=dd(t-1+k,:)’; 108 x{k+1} = A*x{k} + B*u{k} + Bp*dis; 109 110 du{k}=u{k}-uopt; 111 if k>1 112 du{k}=u{k}-u{k-1}; 113 end 114 115 f1=(alpha1+alpha2(t-1+k,:))*u{k}; 116 f2=du{k}; 117 f3=xi{k}; 118 f4=ui{k}; 119 obj=obj+norm(p1*f1,1)+norm(p2*f2,2)+norm(p3*f3,2)+norm(p4*f4 ,2); 120 const=[const, Eu*u{k}+Ed*dis==0]; 121 const=[const, xmin <= x{k} <= xmax]; 122 const=[const, umin <= u{k} <= umax]; 123 const=[const, [umin_csp(t,:)’-ui{k}] <= u{k} <= [umax_csp(t ,:)’+ui{k}]]; 124 const=[const, x{k} >= [xs-xi{k}]]; 125 end 126 127 sdpsettings(’solver’,’cplex’) 128 129 solvesdp(const,obj); % solve for the optimization problem 130 clc
70 APPENDIX A. MAIN CODE, RELIABLE MODEL PREDICTIVE CONTROL 131 duopt=double(u{1})-uopt; % compute \Delta u{k} 132 uopt=double(u{1}); % compute u*{k} 133 xiopt=double(xi{1}); % compute xi*{k} 134 135 %---- saving array data ----% 136 ccmpc.x(t,:)=x0; 137 ccmpc.u(t,:)=uopt; 138 ccmpc.du(t,:)=duopt; 139 %---------------------------% 140 x0=A*x0 + B*uopt + Bp*dd(t,:)’; % update for states x0 141 142 % Computing cost 143 ccmpc.Water(t)= alpha1*abs(ccmpc.u(t,:)’); 144 ccmpc.Electric(t)=alpha2(t,:)*abs(ccmpc.u(t,:)’); 145 146 % Compute the new actuator Reliability 147 [Ra(:,t+1),Rc(:,:,t+1),Rd(:,t+1),Rt(t+1),Ran(:,t+1),Rcn(:,:,t+1) ,Rdn(:,t+1),Rtn(t+1)]=Reliability_computation(act_path,nd, Beta,Lamda,ccmpc.u(t,:),Ra(:,t)’,Hp); 148 149 alphamax_2(t)=Rtn(t+1)/Rt(t+1) %%TEST 150 Alpha = alphamax_2(t)-uAlpha %TEST Alpha in terms on temporal 151 152 % Clock 153 tf(t) = etime(clock,ti); 154 waitbar(t/Hs,h,sprintf(’Progress: %.2f%% completed \n Time remaining: %.2f minutes’,... 155 t/Hs*100,tf(t)/60*(Hs-t))); 156 157 end 158 159 close(h,’force’)
Nonlinear Model Predictive Control of a Quadrotor 71 160 161 162 %% Results 163 figure(1) 164 subplot(2,2,1); plot(ccmpc.x,’linewidth’,2); grid on; 165 title(’Evolution of states x’) 166 xlabel(’time [hours]’) 167 ylabel(’volumes [m^3]’) 168 169 subplot(2,2,2); plot(ccmpc.u,’linewidth’,2); grid on; 170 title(’Evolution of control actions u’) 171 xlabel(’time [hours]’) 172 ylabel(’flows [m^3/s]’) 173 174 subplot(2,2,3); plot(ccmpc.du,’linewidth’,2); grid on; 175 title(’Evolution of variation of actions du’) 176 xlabel(’time [hours]’) 177 ylabel(’variations [m^3/s]’) 178 179 uisave
"Nonlinear Model Predictive Control of a Quadrotor" 73 Appendix B Reachability analysis Code 1 2% Programa para buscar todos los caminos desde todas las fuentes hasta 3% todas las demandas de un sistema con nodos 4 5%% Load system 6 7MatrizA = S.A; 8MatrizB = sign(S.B); 9MatrizC = eye(size(MatrizB,2)); 10 11 MatrizB2 = sign(S.E); 12 MatrizA2 = eye(size(S.Ed,1)); 13 14 %% Make complete matrices 15 Bcompleta=[MatrizB;MatrizB2]’; 16 Acompleta=[MatrizA, zeros(size(MatrizA,1),size(MatrizA2,2));zeros( size(MatrizA2,1),size(MatrizA,2)), MatrizA2]; 17 Ccompleta=[MatrizC, zeros(size(MatrizC,1),size(MatrizA2,2))]; 18 19 %% Load sources
80 APPENDIX C. CSP MATLAB CODE 18 19 % Constants 20 buffer = ’Constants’; 21 fprintf(file,’%s \n’,buffer); 22 23 %R0 24 for i=1:size(R_0,1) 25 buffer = strcat(’r’,num2str(i),’_0 = ’,num2str(R_0(i)),’;’); 26 fprintf(file,’%s \n’,buffer); 27 end 28 29 buffer = ’Variables’; 30 fprintf(file,’%s \n’,buffer); 31 32 %Alpha 33 buffer = strcat(’alpha in [’,num2str(Alpha),’,’,num2str(1),’];’); 34 fprintf(file,’%s \n’,buffer); 35 36 %U bound 37 for i=1:size(UMIN,2) 38 buffer = strcat(’u’,num2str(i),’ in [’,num2str(UMIN(i)),’,’, num2str(UMAX(i)),’];’); 39 fprintf(file,’%s \n’,buffer); 40 end 41 42 %rt 43 buffer=strcat(’rt_’,int2str(N-1),’;’); 44 fprintf(file,’%s \n’,buffer); 45 46 %Equations 47 buffer = ’Constraints’; 48 fprintf(file,’%s \n’,buffer); 49
Nonlinear Model Predictive Control of a Quadrotor 81 50 %Eq R(u) 51 for i=1:size(UMIN,2) 52 tRa{i} = strcat(’(exp(-’,num2str(Lamda(i)),’*exp(’,num2str( Beta(i)),’*u’,int2str(i),’)*’,int2str(N-1),’)*r’,int2str(i),’ _0)’); 53 end 54 55 %eq camino 56 for kk=1:nd 57 for i=1:size(act_path(:,:,kk),2) 58 flag=find(act_path(:,i,kk)~=0); 59 if ~isempty(flag) 60 buffer=[’(’]; 61 for j=1:length(flag)-1 62 buffer = strcat(buffer, tRa{(act_path(j,i,kk))},’*’) ; 63 end 64 buffer = strcat(buffer, tRa{(act_path(length(flag),i,kk) )},’)’); 65 tRc{kk,i}= buffer; 66 else 67 break 68 end 69 end 70 71 end 72 73 %R para demanda 74 for kk=1:nd 75 buffer=[’(1-’]; 76 for i=1:size(act_path(:,:,kk),2) 77 if i==size(act_path(:,:,kk),2) 78 break
82 APPENDIX C. CSP MATLAB CODE 79 else 80 flag=find(act_path(:,i+1,kk)~=0); 81 if ~isempty(flag) 82 buffer = strcat(buffer, ’(1-’,tRc{kk,i},’)*’); 83 else 84 break 85 end 86 end 87 end 88 buffer = strcat(buffer, ’(1-’,tRc{kk,i},’))’); 89 tRd{kk}= buffer; 90 end 91 92 93 buffer=[]; 94 for kk=1:nd-1 95 buffer = strcat(buffer, tRd{kk},’*’); 96 end 97 buffer = strcat(buffer, tRd{kk+1}); 98 buffer = strcat(buffer, ’-rt_’,int2str(N-1),’=0;’); 99 fprintf(file,’%s \n’,buffer); 100 101 %Bound Reability 102 buffer = strcat(num2str(Rt_0),’*alpha-rt_’,int2str(N-1),’=0;’); 103 fprintf(file,’%s \n’,buffer); 104 105 106 buffer = ’end’; 107 fprintf(file,’%s \n’,buffer); 108 109 fclose(’all’); 110 111 clear i j kk buffer flag
Nonlinear Model Predictive Control of a Quadrotor 83 112 113 %% Call C++ function contractor PEELER 114 115 %system(’C:\MinGW\msys\1.0\home\ivan\ibex\ibex-2.1.17\examples\ modifsolver C:/MinGW/msys/1.0/home/ivan/ibex/ibex-2.1.17/benchs/ solver_in.bch 1e-01 0.5 > solver_out.txt’ ); 116 117 system(’modifsolver solver_in.bch 1e+03 0.5 > solver_out.txt’ ); 118 119 %% Read the resulting bounds 120 [t1,t2,t3]=textread(’solver_out.txt’,’%s %s %s’,’headerlines’,1); 121 122 % x3 and the bound data, extract the claudators 123 t3=strrep(t3,’[’,’’); 124 t3=strrep(t3,’]’,’’); 125 126 aux=find(t3{1}==’;’); 127 alphamin=str2num(t3{1}(1:aux-1)); 128 alphamax=str2num(t3{1}(aux+1:end)); 129 130 for i=2:nu+1 131 aux=find(t3{i}==’;’); 132 umin(i-1)=str2num(t3{i}(1:aux-1)); 133 umax(i-1)=str2num(t3{i}(aux+1:end)); 134 end 135 136 137 clear i t1 t2 t3 t4
"Nonlinear Model Predictive Control of a Quadrotor" 85 Appendix D CSP C++ IBEX program 1 2 3// modified solver to obtain and provide the outer bounding box of the solution set 4// STS 5// 2014/10/27 6 7#include "ibex.h" 8#include <sstream> 9 10 using namespace std; 11 using namespace ibex; 12 13 14 double convert(const char*argname, const char*arg) { 15 char*endptr; 16 double val = strtod(arg,&endptr); 17 if (endptr!=arg+strlen(arg)*sizeof(char)) { 18 stringstream s; 19 s << "\"" << argname << "\" must be a real number"; 20 ibex_error(s.str().c_str());
86 APPENDIX D. CSP C++ IBEX PROGRAM 21 } 22 return val; 23 } 24 25 int main(int argc, char** argv){ 26 try{ 27 28 // check the number of arguments 29 if (argc<4) { 30 ibex_error("usage: modifsolver filename precision timelimit"); 31 } 32 33 // load a system of equations 34 System sys(argv[1]); 35 cout << "Load file " << argv[1] << "." << endl; 36 37 // configure the solver 38 double prec = convert("prec",argv[2]); 39 double time_limit = convert("Timelimit",argv[3]); 40 DefaultSolver s(sys,prec); 41 s.time_limit=time_limit; 42 s.trace=0; // the solutions are not printed when they are found 43 cout.precision(12); 44 45 // get the solutions 46 vector<IntervalVector> sols=s.solve(sys.box); 47 48 // for each variable, obtain min and max values in the solution set 49 if (sols.size() >0){ 50 Matrix my_sol(2,sys.nb_var); 51 for (int j=0; j<sys.nb_var; j++) 52 {
Nonlinear Model Predictive Control of a Quadrotor 87 53 my_sol[0][j] = sols[0][j].lb(); 54 my_sol[1][j] = sols[0][j].ub(); 55 for (int i=1; i<(sols.size()); i++) 56 { 57 if (sols[i][j].lb() < my_sol[0][j]) 58 { 59 my_sol[0][j] = sols[i][j].lb(); 60 } 61 if (sols[i][j].ub() > my_sol[1][j]) 62 { 63 my_sol[1][j] = sols[i][j].ub(); 64 } 65 } 66 67 cout << "Variable_" << j << " in [" << my_sol[0][j] << ";" << my_sol[1][j] << "]" << endl; 68 } 69 } 70 71 cout << "Number of solutions = " << sols.size() << endl; 72 cout << "CPU time used = " << s.time << "s."<< endl; 73 cout << "Number of cells = " << s.nb_cells << endl; 74 } 75 catch(ibex::SyntaxError& e) { 76 cout << e << endl; 77 } 78 }
"Nonlinear Model Predictive Control of a Quadrotor" 89 Appendix E Reliability Computation Code 1 2%Funtion to compute the actual reliability of the whole system 3 4function [Ra,Rc,Rd,Rt,Ran,Rcn,Rdn,Rtn]=Reliability_computation( act_path,nd,Beta,Lamda,u,Ra0,N) 5 6Ra=exp(-Lamda.*exp(Beta.*abs(u))).*Ra0; %Relibility for all actuators 7Ran=exp(-Lamda.*(N-1)).*Ra0; 8 9% eq R_0 10 for kk=1:nd 11 12 for i=1:size(act_path(:,:,kk),2) 13 flag=find(act_path(:,i,kk)~=0); 14 if ~isempty(flag) 15 Rc(i,kk)= prod(Ra(act_path(1:length(flag),i,kk))); 16 Rcn(i,kk)= prod(Ran(act_path(1:length(flag),i,kk))); 17 else 18 break 19 end