Delphi 7- 4 Adet Tablo Döngü Problemi

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
forisicle
Üye
Mesajlar: 11
Kayıt: 01 May 2019 06:45

Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen forisicle »

Merhabalar.
Delphi'de iş yerinde kullanmak üzere şebeke sistemleri analizi ve şebeke borularından geçen debilerin hesaplanmasıyla ilgili bir modelleme yapıyorum. Modellemede şebeke sisteminde olan toplam boru sayısı olacak. Bu modelleme lineer teori denen bir nümerik yol ile çözüleceği için biraz kafa karıştırıcı zaten bende bu yüzden işin içinden çıkamadım.

4 adet tablomuz var.
Birincisine matris sistemi gibi katsayılar girilecek. Yani mesela boru sayısına 4 dediğimiz zaman 4x4 lük bir tablo oluşacak ve içerisine sayıları kullanıcı girecek.

İkincisinde boru sayısı kadar (misal 4) 1x4'lük bir tablo olacak ve Q1, Q2, Q3, Q4 yazacak.

Üçüncüsünde ise yine 1x4'lük bir tablo olacak ve kullanıcı içerisine yine sayıları girecek.

1. ve 3. tablo 4. tabloda debi değerlerini hesaplarken kullanacağım değerlerle dolu oluyor. (Kullanıcıların girdiği)

4. tabloya geldiğimde ise 1. sütunu iterasyon sayısı olacak ve 1er artırılarak devam edecek.
2., 3., 4,... sütunlarında girilen boru sayısı kadar Q1, Q2, Q3,... değerleri yazılacak.
Bu Q değerlerinin lineer teori formülünde her biri tek tek hesaplanıyor ilk değerleri 0 olarak giriliyor.
Q1 hesaplanırken Q2, Q3, Q4.... ün bir önceki değerleri, Q2 hesaplanırken Q1'in o satırdaki değeri ve Q2, Q3,Q4... ün bir önceki değerleri... vesaire şeklinde hesaplanıyor. Yani hepsi birbirine bağlı.

Ben bunların hepsini programa girdim. Fakat örneğim 4 boru üzerinden olduğu için sadece 4 boruya göre hesap yapabiliyorum. 5 boru olduğunda 1., 2., 3., tabloların satır sayıları artacak 4. tablonun sütun sayısı artacak ve formüllerin hepsi ona göre değişmesi lazım.. Formüllerin değişmesi ve döngüde sıkıntı yaşıyorum..

Derdimi anlatabildim mi bilmiyorum ama 4 boruluk delphi ekran görüntüsünü atıyorum eke. yardımcı olursanız çok sevinirim ... https://i.hizliresim.com/r5q2nP.jpg
Kullanıcı avatarı
freeman35
Admin
Mesajlar: 2356
Kayıt: 12 Haz 2003 04:05
Konum: merkez camii yanı

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen freeman35 »

Tablo dedğin, ekrandaki stringgrid sanırım. Onda satır "Row" sütün da "Column" olarak geçiyor. Bunu araştır. (rowcount, columncount vs yıllardır kullanmadığım için isimler farklı olabilir). Genelde de anlatılırken basit örnek kodlar veriliyor açıklamalarda. onları incelersen, satır satır ve her bir komutu, bileşen hakkında deneyimin artar.
ZAGOR TENAY TÜRK'tür... TÜRK kalacak...
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5

Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
forisicle
Üye
Mesajlar: 11
Kayıt: 01 May 2019 06:45

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen forisicle »

StringGrid'de Rowcount ve Colcount bileşenlerini biliyorum hocam. Sorunum orada değil.. Sorunum sütun sayısı girilen boru değerlerine göre artıyor. Formüllerinde ona göre artması gerekiyor orada sorun yaşıyorum..
Kullanıcı avatarı
freeman35
Admin
Mesajlar: 2356
Kayıt: 12 Haz 2003 04:05
Konum: merkez camii yanı

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen freeman35 »

rowcount colcount bileşen değil, özellik. karışıklık anlaşmada sorun çıkartabilir. formülde ona göre değişiyor diyorsun da, görmediğin birşeyi bilmek gaybı bilmek demek. kodu yazmazsan nerden bilebilirz?
ZAGOR TENAY TÜRK'tür... TÜRK kalacak...
Zoru başarırım, İmkansız zaman alır
FreeMan 35.5

Soru sormaya üşenmiyorsan, sorunun çözümünü yazmaya da üşenme !!!
forisicle
Üye
Mesajlar: 11
Kayıt: 01 May 2019 06:45

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen forisicle »

Haklısınız hocam hemen atıyorum
https://i.hizliresim.com/r5q2nP.jpg

Burada görmüş olduğunuz 4 adet tablonun 1 ve 3. tablo nun içerisine kullanıcının gireceği değerler 4. tabloda kullanılıyor. Şebeke boru sayısını 4 olarak aldım. Fakat 10 olarak alındığında 1. tablo 10x10 luk, 2. tablo 1x10 luk 3. tablo 1x10 luk ve 4. tabloda da 10 tane Q1, Q2,... Q10 olacak. Q1 in hesabında Q2+Q3+...Q10 kullanılıyor, 9 tane olursa Q1+Q2+...+Q9 olması gerekiyor. Burası benim takıldığım yer formülleri öyle bir yazmam gerekiyor ki 50 boruluk sistem bile olsa program çözebilsin...


Lineer teoride hesaplama da şu şekilde ;

https://sheet.zoho.com/sheet/editor.do ... bbcdcb62c

Kod: Tümünü seç

procedure TForm1.Button1Click(Sender: TObject);
begin
borusayisi := strtoint(Edit1.Text);
iterasyon := strtoint(Edit2.Text);
StringGrid1.ColCount:=borusayisi;
StringGrid1.RowCount:=borusayisi;
StringGrid3.ColCount:=1;
StringGrid3.RowCount:=borusayisi;
StringGrid4.ColCount:=1;
StringGrid4.RowCount:=borusayisi;
stringGrid2.ColCount := borusayisi+1;
stringGrid2.RowCount := iterasyon+2;
StringGrid2.Cells[0,0]:='İterasyon';

i:=0;
for satir:=1 to iterasyon+1 do
begin
StringGrid2.Cells[0,satir]:=inttostr(i);
i:=i+1;
end;


for i:=0 to StringGrid3.RowCount do
begin
dongusayi:=i+1;
StringGrid3.Cells[0,i]:= 'Q'+inttostr(dongusayi);
end;

for sutun:=1 to borusayisi do
begin
  dongusayi:=sutun;
  StringGrid2.Cells[sutun,0]:= 'Q'+inttostr(dongusayi);
end;

for sutun:=1 to borusayisi do
begin
StringGrid2.Cells[sutun,1]:='0';
end;

for satir:=2 to StringGrid2.RowCount do
for sutun:=1 to StringGrid2.ColCount do
begin

StringGrid2.Cells[sutun,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun-1,satir-2]))*(strtofloat(StringGrid4.Cells[0,satir-2])-(strtofloat(StringGrid1.Cells[sutun,satir-2])*strtofloat(StringGrid2.Cells[sutun+1,satir-1])+strtofloat(StringGrid1.Cells[sutun+1,satir-2])*strtofloat(StringGrid2.Cells[sutun+2,satir-1])+strtofloat(StringGrid1.Cells[sutun+2,satir-2])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+1,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun,satir-1]))*(strtofloat(StringGrid4.Cells[0,satir-1])-(strtofloat(StringGrid1.Cells[sutun-1,satir-1])*strtofloat(StringGrid2.Cells[sutun,satir]))-(strtofloat(StringGrid1.Cells[sutun+1,satir-1])*strtofloat(StringGrid2.Cells[sutun+2,satir-1])+strtofloat(StringGrid1.Cells[sutun+2,satir-1])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+2,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun+1,satir]))*(strtofloat(StringGrid4.Cells[0,satir])-(strtofloat(StringGrid1.Cells[sutun-1,satir])*strtofloat(StringGrid2.Cells[sutun,satir])+strtofloat(StringGrid1.Cells[sutun,satir])*strtofloat(StringGrid2.Cells[sutun+1,satir]))-(strtofloat(StringGrid1.Cells[sutun+2,satir])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+3,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun+2,satir+1]))*(strtofloat(StringGrid4.Cells[0,satir+1])-(strtofloat(StringGrid1.Cells[sutun-1,satir+1])*strtofloat(StringGrid2.Cells[sutun,satir])+strtofloat(StringGrid1.Cells[sutun,satir+1])*strtofloat(StringGrid2.Cells[sutun+1,satir])+strtofloat(StringGrid1.Cells[sutun+1,satir+1])*strtofloat(StringGrid2.Cells[sutun+2,satir]))));

end;



end;

procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='-1';
StringGrid1.Cells[1,0]:='0';
StringGrid1.Cells[2,0]:='0';
StringGrid1.Cells[3,0]:='-1';
StringGrid1.Cells[0,1]:='0';
StringGrid1.Cells[1,1]:='1';
StringGrid1.Cells[2,1]:='-1';
StringGrid1.Cells[3,1]:='0';
StringGrid1.Cells[0,2]:='0';
StringGrid1.Cells[1,2]:='0';
StringGrid1.Cells[2,2]:='1';
StringGrid1.Cells[3,2]:='1';
StringGrid1.Cells[0,3]:='20';
StringGrid1.Cells[1,3]:='40';
StringGrid1.Cells[2,3]:='50';
StringGrid1.Cells[3,3]:='-60';
StringGrid4.Cells[0,0]:='-0,1';
StringGrid4.Cells[0,1]:='0,04';
StringGrid4.Cells[0,2]:='0,03';
StringGrid4.Cells[0,3]:='0';
end;

end.
mkysoft
Kıdemli Üye
Mesajlar: 3103
Kayıt: 26 Ağu 2003 12:35
Konum: Berlin
İletişim:

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen mkysoft »

Liner model dediğiniz sanrım doğrusal programlama. Anladığım kadarıyla şebeke problemini çözemeye çalışıyorsunuz. Büyük M yöntemini mi kodlamaya çalışıyorsunuz?
forisicle
Üye
Mesajlar: 11
Kayıt: 01 May 2019 06:45

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen forisicle »

Büyük M yöntemini bilmiyorum malesef.. Açıklayabilir misiniz biraz daha detaylı rica etsem
mkysoft
Kıdemli Üye
Mesajlar: 3103
Kayıt: 26 Ağu 2003 12:35
Konum: Berlin
İletişim:

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen mkysoft »

Aşağıdaki videolarda anlatılıyor.
https://www.youtube.com/watch?v=d2Cll53GN1s
https://www.youtube.com/watch?v=yZjxpSaUUZE

Size anlatılmış bir çözüm yöntemi varsa onu uygulamaya devam edebilirisiniz, bu konularda alt yapınız yoksa videolar kafanızı karıştırabilir.
forisicle
Üye
Mesajlar: 11
Kayıt: 01 May 2019 06:45

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen forisicle »

Hocam anladım inceledim videoları ama, exceldeki çözüm yöntemi ile olmak zorunda, başka bi formülazasyon uygulayamam..
ertank
Kıdemli Üye
Mesajlar: 1650
Kayıt: 12 Eyl 2015 12:45

Re: Delphi 7- 4 Adet Tablo Döngü Problemi

Mesaj gönderen ertank »

forisicle yazdı: 19 May 2019 05:20 Haklısınız hocam hemen atıyorum
https://i.hizliresim.com/r5q2nP.jpg

Burada görmüş olduğunuz 4 adet tablonun 1 ve 3. tablo nun içerisine kullanıcının gireceği değerler 4. tabloda kullanılıyor. Şebeke boru sayısını 4 olarak aldım. Fakat 10 olarak alındığında 1. tablo 10x10 luk, 2. tablo 1x10 luk 3. tablo 1x10 luk ve 4. tabloda da 10 tane Q1, Q2,... Q10 olacak. Q1 in hesabında Q2+Q3+...Q10 kullanılıyor, 9 tane olursa Q1+Q2+...+Q9 olması gerekiyor. Burası benim takıldığım yer formülleri öyle bir yazmam gerekiyor ki 50 boruluk sistem bile olsa program çözebilsin...


Lineer teoride hesaplama da şu şekilde ;

https://sheet.zoho.com/sheet/editor.do ... bbcdcb62c

Kod: Tümünü seç

procedure TForm1.Button1Click(Sender: TObject);
begin
borusayisi := strtoint(Edit1.Text);
iterasyon := strtoint(Edit2.Text);
StringGrid1.ColCount:=borusayisi;
StringGrid1.RowCount:=borusayisi;
StringGrid3.ColCount:=1;
StringGrid3.RowCount:=borusayisi;
StringGrid4.ColCount:=1;
StringGrid4.RowCount:=borusayisi;
stringGrid2.ColCount := borusayisi+1;
stringGrid2.RowCount := iterasyon+2;
StringGrid2.Cells[0,0]:='İterasyon';

i:=0;
for satir:=1 to iterasyon+1 do
begin
StringGrid2.Cells[0,satir]:=inttostr(i);
i:=i+1;
end;


for i:=0 to StringGrid3.RowCount do
begin
dongusayi:=i+1;
StringGrid3.Cells[0,i]:= 'Q'+inttostr(dongusayi);
end;

for sutun:=1 to borusayisi do
begin
  dongusayi:=sutun;
  StringGrid2.Cells[sutun,0]:= 'Q'+inttostr(dongusayi);
end;

for sutun:=1 to borusayisi do
begin
StringGrid2.Cells[sutun,1]:='0';
end;

for satir:=2 to StringGrid2.RowCount do
for sutun:=1 to StringGrid2.ColCount do
begin

StringGrid2.Cells[sutun,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun-1,satir-2]))*(strtofloat(StringGrid4.Cells[0,satir-2])-(strtofloat(StringGrid1.Cells[sutun,satir-2])*strtofloat(StringGrid2.Cells[sutun+1,satir-1])+strtofloat(StringGrid1.Cells[sutun+1,satir-2])*strtofloat(StringGrid2.Cells[sutun+2,satir-1])+strtofloat(StringGrid1.Cells[sutun+2,satir-2])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+1,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun,satir-1]))*(strtofloat(StringGrid4.Cells[0,satir-1])-(strtofloat(StringGrid1.Cells[sutun-1,satir-1])*strtofloat(StringGrid2.Cells[sutun,satir]))-(strtofloat(StringGrid1.Cells[sutun+1,satir-1])*strtofloat(StringGrid2.Cells[sutun+2,satir-1])+strtofloat(StringGrid1.Cells[sutun+2,satir-1])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+2,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun+1,satir]))*(strtofloat(StringGrid4.Cells[0,satir])-(strtofloat(StringGrid1.Cells[sutun-1,satir])*strtofloat(StringGrid2.Cells[sutun,satir])+strtofloat(StringGrid1.Cells[sutun,satir])*strtofloat(StringGrid2.Cells[sutun+1,satir]))-(strtofloat(StringGrid1.Cells[sutun+2,satir])*strtofloat(StringGrid2.Cells[sutun+3,satir-1]))));
StringGrid2.Cells[sutun+3,satir]:=floattostr((1/strtofloat(StringGrid1.Cells[sutun+2,satir+1]))*(strtofloat(StringGrid4.Cells[0,satir+1])-(strtofloat(StringGrid1.Cells[sutun-1,satir+1])*strtofloat(StringGrid2.Cells[sutun,satir])+strtofloat(StringGrid1.Cells[sutun,satir+1])*strtofloat(StringGrid2.Cells[sutun+1,satir])+strtofloat(StringGrid1.Cells[sutun+1,satir+1])*strtofloat(StringGrid2.Cells[sutun+2,satir]))));

end;



end;

procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='-1';
StringGrid1.Cells[1,0]:='0';
StringGrid1.Cells[2,0]:='0';
StringGrid1.Cells[3,0]:='-1';
StringGrid1.Cells[0,1]:='0';
StringGrid1.Cells[1,1]:='1';
StringGrid1.Cells[2,1]:='-1';
StringGrid1.Cells[3,1]:='0';
StringGrid1.Cells[0,2]:='0';
StringGrid1.Cells[1,2]:='0';
StringGrid1.Cells[2,2]:='1';
StringGrid1.Cells[3,2]:='1';
StringGrid1.Cells[0,3]:='20';
StringGrid1.Cells[1,3]:='40';
StringGrid1.Cells[2,3]:='50';
StringGrid1.Cells[3,3]:='-60';
StringGrid4.Cells[0,0]:='-0,1';
StringGrid4.Cells[0,1]:='0,04';
StringGrid4.Cells[0,2]:='0,03';
StringGrid4.Cells[0,3]:='0';
end;

end.
Merhaba,

Ekranda gözüken bileşenler ile kod içinde yazılı olanları eşleştirmek maalesef mümkün olmadı. Belirttiğiniz "lineer teoride hesaplama" bağlantısı da benim bilgisayarımda açılmadı. Kurduğunuz formülü de açıkçası konuyu bilmediğim için anlayamadım.

Sadece ekrandaki değerler (Boru sayısı ve iterasyon) değiştiğinde anladığım kadarıyla gridler için gerekli kolon ve sütun ayarlamalarını yapan örnek uygulamayı ekte bulabilirsiniz.

Uygulama Delphi 10.3.1 ile uyumludur.
Dosya ekleri
hesap.rar
(53.15 KiB) 78 kere indirildi
Cevapla