Линейное программирование (Составление плана использования технологических способов в производстве), страница 5

if (b<0)and  (strok='<=') and((a*x1+8+b*y1) <= (c))and (a>0)then  begin

lineto(x0,y0-okryy-20);

moveto(x0,y0-okryy-20);

lineto(x0+5,y0-okryy-15);

moveto(x0,y0-okryy-20);

lineto(x0-5,y0-okryy-15);

end;

if (b<0)and  (strok='<=') and((a*x1-8+b*y1) <= (c))and (a>0)then begin

lineto(x0,y0-okryy+20);

moveto(x0,y0-okryy+20);

lineto(x0+5,y0-okryy+15);

moveto(x0,y0-okryy+20);

lineto(x0-5,y0-okryy+15);

end;

end;

end;

end;

procedure TForm1.Button3Click(Sender: TObject);

var x11,x22,F1,y1,y2:real;

x1,x2,okrx,okry,okryy:integer;

x0,y0:integer;

dx,dy,h,w:integer;

begin

x0:=150; y0:=450; (40,250)

dx:=45; dy:=45;

h:=400; w:=400;

x11:=strtofloat(stringgrid2.Cells[0,0]);

x22:=strtofloat(stringgrid2.Cells[1,0]);

F1:=strtofloat(stringgrid2.Cells[3,0]);

x1:=10;

x2:=0;

y1:=(F1-(x11*x1))/x22;

y2:=(F1-(x11*x2))/x22;

okrx:=trunc(x1*dx);

okry:=trunc(y1*dy);

okryy:=trunc(y2*dy);

with form1.image1.Canvas do begin

pen.Color:=clred;

MoveTo(x0,y0-okryy);

LineTo(x0+okrx,y0-okry);

end;

end;

procedure TForm1.Button7Click(Sender: TObject);

var a,a1,b,b1,c,c1,x1,x2,dd,f,fx1,fx2:real;

i,j,k,l:integer;

begin

for i:=0 to stringgrid1.RowCount-1 do begin

k:=strtoint(edit5.text) ;

l:=strtoint(edit6.text) ;

if i=k-1 then begin

a:=strtofloat(stringgrid1.Cells[0,i]);

b:=strtofloat(stringgrid1.Cells[1,i]);

c:=strtofloat(stringgrid1.Cells[2,i]);

end;

if i=l-1 then begin

a1:=strtofloat(stringgrid1.Cells[0,i]);

b1:=strtofloat(stringgrid1.Cells[1,i]);

c1:=strtofloat(stringgrid1.Cells[2,i]);

end;

end;

fx1:=strtofloat(stringgrid2.Cells[0,0]);

fx2:=strtofloat(stringgrid2.Cells[1,0]);

x2:=(a*c1-a1*c)/(a*b1-a1*b);

x1:=(c-b*x2)/a ;

f:=x1*fx1+x2*fx2;

label14.Caption:='f'+stringgrid2.Cells[2,0]+' = '+floattostr(f);

label15.Caption:='x1* = '+floattostr(x1);

label16.caption:='x2* = '+floattostr(x2);

end;

procedure TForm1.Button8Click(Sender: TObject);

var i,j,k,xtoc,ytoc:integer;

x1,x2,a,b,c,y111,y222,xcoo,ycoo:real;

begin

form2.stringgrid3.rowcount:=stringgrid1.rowcount;

for k:=1 to 100 do begin

x2:=k/10;

for j:=1 to 100 do begin

x1:=j/10;

for i:=0 to stringgrid1.RowCount-1 do begin

a:=strtofloat(stringgrid1.Cells[0,i]);

b:=strtofloat(stringgrid1.Cells[1,i]);

c:=strtofloat(stringgrid1.Cells[2,i]);

if (stringgrid1.Cells[3,i]='>=') and (a*x1+b*x2>c)then

form2.stringgrid3.cells[0,i]:=floattostr(x1);

form2.stringgrid3.cells[1,i]:=floattostr(x2);

if  (stringgrid1.Cells[3,i]='<=') and(a*x1+b*x2<c) then

form2.stringgrid3.cells[0,i]:=floattostr(x1);

form2.stringgrid3.cells[1,i]:=floattostr(x2);

end;

if (form2.stringgrid3.cells[0,0]=form2.stringgrid3.cells[0,1])and

(form2.stringgrid3.cells[0,0]=form2.stringgrid3.cells[0,2])and

(form2.stringgrid3.cells[1,0]=form2.stringgrid3.cells[1,1])and

(form2.stringgrid3.cells[1,0]=form2.stringgrid3.cells[1,2])then

form2.stringgrid4.cells[0,0]:=form2.stringgrid3.cells[0,0];

if (form2.stringgrid3.cells[0,0]=form2.stringgrid3.cells[0,1])and

(form2.stringgrid3.cells[0,0]=form2.stringgrid3.cells[0,2])and

(form2.stringgrid3.cells[1,0]=form2.stringgrid3.cells[1,1])and

(form2.stringgrid3.cells[1,0]=form2.stringgrid3.cells[1,2])then

form2.stringgrid4.cells[1,0]:=form2.stringgrid3.cells[1,0];

end;

end;

y111:=strtofloat(form2.stringgrid4.cells[0,0]);

y222:=strtofloat(form2.stringgrid4.cells[1,0]);

xtoc:=round(y111*45);

ytoc:=round(y222*45);

form1.image1.Canvas.Brush.style:=bscross;

form1.image1.Canvas.Brush.color:=clblack;

form1.Image1.Canvas.FloodFill(150+xtoc,450-ytoc,clblack,fsborder);

end;

procedure TForm1.gfgf1Click(Sender: TObject);

begin

form2.Show;

end;

end


3 ТРАНСПОРТНАЯ ЗАДАЧА