------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Queueing_System; use Queueing_System.A_Resp_Time_Consumer; package body Queueing_System.theoretical.Mp1 is procedure Initialize (A_Queueing_System : in out Mp1_Queueing_System_theoretical) is begin Initialize (Generic_Queueing_System_theoretical (A_Queueing_System)); A_Queueing_System.Queueing_System_Type := Qs_Mp1; end Initialize; procedure Qs_Average_Waiting_Time (A_Queueing_System : in Mp1_Queueing_System_theoretical; Result : in out Double) is package Double_Io is new Text_IO.Float_IO (Double); use Double_Io; Avg_Service_Time : Double := 0.0; Var_Service_Time : Double := 0.0; Rau : Double := 0.0; Taw : Double := 0.0; Wi : Double := 0.0; Resp_Time : Double := 0.0; Resp_Time_Prec : Double := A_Queueing_System.Consumer_Resp_Time.entries (A_Queueing_System. Consumer_Resp_Time.nb_entries - 1).data; Nb_Service_Time : Double := 0.0; Pcons : constant Double := 1.0 / A_Queueing_System.Service_Rate.entries (0).data; Arrival_Rate : constant Double := A_Queueing_System.Arrival_Rate.entries (0).data; begin -- service time -- Avg_Service_Time := Pcons / (2.0 * (1.0 - Arrival_Rate * (Pcons / 2.0))); Rau := Arrival_Rate * Avg_Service_Time; -- variance -- for I in 0 .. A_Queueing_System.Consumer_Resp_Time.nb_entries - 1 loop Resp_Time := A_Queueing_System.Consumer_Resp_Time.entries (I).data; Wi := Resp_Time + Pcons - Resp_Time_Prec; -- compute the variance Var_Service_Time := Var_Service_Time + Wi * Wi; Resp_Time_Prec := Resp_Time; Nb_Service_Time := Nb_Service_Time + 1.0; end loop; Var_Service_Time := Var_Service_Time / Nb_Service_Time; Var_Service_Time := (1.0 - Rau) * (Pcons * Pcons / 12.0) + Rau * (Var_Service_Time - Pcons * Pcons); Taw := Avg_Service_Time + Arrival_Rate * (Avg_Service_Time * Avg_Service_Time + Var_Service_Time) / (2.0 * (1.0 - Arrival_Rate * Pcons)); -- Mst)); Result := Taw; end Qs_Average_Waiting_Time; procedure Qs_Average_Number_Customer (A_Queueing_System : in Mp1_Queueing_System_theoretical; Result : in out Double) is Avg_Service_Time : Double := 0.0; Var_Service_Time : Double := 0.0; Rau : Double := 0.0; Tao : Double := 0.0; Wi : Double := 0.0; Resp_Time : Double := 0.0; Resp_Time_Prec : Double := A_Queueing_System.Consumer_Resp_Time.entries (A_Queueing_System. Consumer_Resp_Time.nb_entries - 1).data; Nb_Service_Time : Double := 0.0; Pcons : constant Double := 1.0 / A_Queueing_System.Service_Rate.entries (0).data; Arrival_Rate : constant Double := A_Queueing_System.Arrival_Rate.entries (0).data; begin -- service time -- Avg_Service_Time := Pcons / (2.0 * (1.0 - Arrival_Rate * (Pcons / 2.0))); Rau := Arrival_Rate * Avg_Service_Time; -- variance -- for I in 0 .. A_Queueing_System.Consumer_Resp_Time.nb_entries - 1 loop Resp_Time := A_Queueing_System.Consumer_Resp_Time.entries (I).data; Wi := Resp_Time + Pcons - Resp_Time_Prec; -- compute the variance Var_Service_Time := Var_Service_Time + Wi * Wi; Resp_Time_Prec := Resp_Time; Nb_Service_Time := Nb_Service_Time + 1.0; end loop; Var_Service_Time := Var_Service_Time / Nb_Service_Time; Var_Service_Time := (1.0 - Rau) * (Pcons * Pcons / 12.0) + Rau * (Var_Service_Time - Pcons * Pcons); Tao := Avg_Service_Time + Arrival_Rate * (Avg_Service_Time * Avg_Service_Time + Var_Service_Time) / (2.0 * (1.0 - Arrival_Rate * Pcons)); -- Mst)); Tao := Arrival_Rate * Tao; Result := Tao; end Qs_Average_Number_Customer; -- -- return the simulated average waiting time of one customer in the --queue -- -- -- procedure Qs_Average_Waiting_Time_Simulation ( -- A_Queueing_System : in out Mp1_Queueing_System_theoretical; -- Arrival_Rate : in Double; -- Service_Rate : in Double; -- Result : in out Double ) is -- package Double_Io is new Text_Io.Float_Io(Double); -- use Double_Io; -- Avg_Service_Time : Double := A_Queueing_System.Avg_Service; -- Var_Service_Time : Double := A_Queueing_System.Var_Service; -- Rau : Double := 0.0; -- begin -- -- Put_Line("Avg_Service_Time" & Avg_Service_Time'Img); -- -- Put_Line("var_Service_Time" & Var_Service_Time'Img); -- Rau := Arrival_Rate * Avg_Service_Time; -- Put(Rau,Aft=>4, Exp => 0); -- New_Line; -- Result:= Avg_Service_Time + (Arrival_Rate * Avg_Service_Time * -- Avg_Service_Time + Arrival_Rate* Var_Service_Time) -- /(2.0*(1.0 - Arrival_Rate * Avg_Service_Time)); -- end Qs_Average_Waiting_Time_Simulation; -- -- return the simulated average number of customer in the queue -- -- -- procedure Qs_Average_Number_Customer_Simulation ( -- A_Queueing_System : in Mp1_Queueing_System_theoretical; -- Arrival_Rate : in Double; -- Service_Rate : in Double; -- Result : in out Double) is -- Avg_Service_Time : Double := A_Queueing_System.Avg_Service; -- Var_Service_Time : Double := A_Queueing_System.Var_Service; -- begin -- Result:= Avg_Service_Time + (Arrival_Rate * Avg_Service_Time * -- Avg_Service_Time + Arrival_Rate* Var_Service_Time) -- /(2.0*(1.0 - Arrival_Rate * Avg_Service_Time)); -- Result:= Result* Arrival_Rate; -- end Qs_Average_Number_Customer_Simulation; procedure Qs_Maximum_Waiting_Time (A_Queueing_System : in Mp1_Queueing_System_theoretical; Result : in out Double) is begin raise Not_Implemented; end Qs_Maximum_Waiting_Time; procedure Qs_Maximum_Number_Customer (A_Queueing_System : in Mp1_Queueing_System_theoretical; Result : in out Double) is begin raise Not_Implemented; end Qs_Maximum_Number_Customer; function Get_Probability_Of_State (A_Queueing_System : in Mp1_Queueing_System_theoretical; N : in Natural) return Double is begin raise Not_Implemented; return 0.0; end Get_Probability_Of_State; end Queueing_System.theoretical.Mp1;