Прошу помощь в создании программы. Условие:
Цитата:
Параметры АЗС:
– число колонок 2;
– поток автомобилей, поступающих на заправку, подчиняется экспоненциальному закону с параметрами λ=0 мин. и β=6,5 мин.
– время заправки на первой колонке 10±2,5 мин., на второй подчиняется усеченно-нормальному закону с параметрами m=8 мин., σ=0,33 мин.;
– автомобиль подъезжает к свободной колонке.
Требуется определить следующие параметры работы АЗС в течение 8 часов:
– коэффициент загрузки каждой колонки;
– среднее время обслуживания каждой колонкой;
– максимальное и среднее число автомобилей в очереди к каждой колонке;
– среднее время нахождения автомобиля в каждой очереди.
|
Имеется программа с тремя колонками и немного другим условием (вложил в архив).
Вот мой код:
Код:
procedure TForm2.Button1Click(Sender: TObject);
var tgeneral,t,t1,t2,
twait1,twait2,
sum_twait1,sum_twait2,
tengaged1,tengaged2,
sum_t1,sum_t2:real;
queue1,queue2,max1,max2,
quancar1,quancar2,
length_queue1,length_queue2,
q1,q2:integer;
begin
stringgrid1.Visible:=true;
tgeneral:=0;
queue1:=0; queue2:=0;
max1:=0; max2:=0;
tengaged1:=0; tengaged2:=0;
twait1:=0; twait2:=0;
sum_twait1:=0; sum_twait2:=0;
quancar1:=0; quancar2:=0;
sum_t1:=0; sum_t2:=0;
length_queue1:=0; length_queue2:=0;
q1:=1;q2:=1;
Randomize;
while tgeneral<480 do
begin
t:=abs(5*ln(5*random));
if (queue1<queue2) and (queue1=queue2) then
begin
t1:=abs(7.5+random*(12.5-7.5));
sum_t1:=sum_t1+t1;
queue1:=queue1+1;
length_queue1:=length_queue1+queue1;
q1:=q1+1;
if max1<queue1 then max1:=queue1;
if tengaged1>tgeneral
then twait1:=tengaged1-tgeneral+t1
else twait1:=0;
sum_twait1:=sum_twait1+twait1;
tengaged1:=tgeneral+t1;
quancar1:=quancar1+1;
end
else
begin
if queue2<queue1 then
begin
t2:=abs(4-4*ln(4*random));
sum_t2:=sum_t2+t2;
queue2:=queue2+1;
length_queue2:=length_queue2+queue2;
q2:=q2+1;
if max2<queue2 then max2:=queue2;
if tengaged2>tgeneral
then twait2:=tengaged2+t2-tgeneral
else twait2:=0;
sum_twait2:=sum_twait2+twait2;
tengaged2:=tgeneral+t2;
quancar2:=quancar2+1;
end
else
end;
if (tengaged1<tgeneral) and (queue1<>0) then
begin
queue1:=queue1-1;
length_queue1:=length_queue1+queue1;
q1:=q1+1;
end;
if (tengaged2<tgeneral) and (queue2<>0) then
begin
queue2:=queue2-1;
length_queue2:=length_queue2+queue2;
q2:=q2+1;
end;
tgeneral:=tgeneral+t;
end;
stringgrid1.Cells[1,0]:='Колонка 1';
stringgrid1.Cells[2,0]:='Колонка 2';
stringgrid1.Cells[0,1]:='Коэффициент загрузки';
stringgrid1.Cells[0,2]:='Среднее время обслуживания, мин';
stringgrid1.Cells[0,3]:='Максимальное число автомобилей в очереди, шт';
stringgrid1.Cells[0,4]:='Среднее число автомобилей в очереди, шт';
stringgrid1.Cells[0,5]:='Среднее время нахождения автомобиля в очереди, мин';
stringgrid1.Cells[1,1]:=floattostr(round(sum_t1/480*1000)/1000);
stringgrid1.Cells[2,1]:=floattostr(round(sum_t2/480*1000)/1000);
stringgrid1.Cells[1,2]:=floattostr(round(sum_t1/quancar1*1000)/1000);
stringgrid1.Cells[2,2]:=floattostr(round(sum_t2/quancar2*1000)/1000);
stringgrid1.Cells[1,3]:=inttostr(max1);
stringgrid1.Cells[2,3]:=inttostr(max2);
stringgrid1.Cells[1,4]:=floattostr(round(length_queue1/q1));
stringgrid1.Cells[2,4]:=floattostr(round(length_queue2/q2));
stringgrid1.Cells[1,5]:=floattostr(round(sum_twait1/quancar1*1000)/1000);
stringgrid1.Cells[2,5]:=floattostr(round(sum_twait2/quancar2*1000)/1000);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
halt;
end;
end.
Прога при нажатии на кнопку моделировать, почему-то выдаёт ошибку...( На форме всего 2 кнопки , групбокс (условие) и Стринггрид.
Помогите пожалуйста
.