This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
2024-03-10 20:32:51 +03:00

28 lines
664 B
ObjectPascal

uses NumLibABC;
// Ñëó÷àéíûé ïîèñê (ôóíêöèÿ ñ îãðàíè÷åíèÿìè)
function f(x:array of real):real;
begin
var x1:=x[0];
var x2:=x[1];
var s:=0.0; // øòðàôíàÿ ôóíêöèÿ
if x1+x2>8 then s:=real.MaxValue
else if -2*x1+3*x2>9 then s:=real.MaxValue
else if 2*x1-x2>10 then s:=real.MaxValue
else if x1<0 then s:=real.MaxValue
else if x2<0 then s:=real.MaxValue;
Result:=-4*x1-3*x2+1+s
end;
begin
var a:=Arr(0.0,0.0);
var b:=Arr(8.0,8.0);
var y:real;
var oL:=new FMinN(a,f);
oL.MKSearch(a,b,y);
oL.x.Transform(t->real(Round(t)));
Write('Ïîëó÷åííûå çíà÷åíèÿ àðãóìåíòîâ: '); oL.x.Println;
Writeln('Ïîëó÷åííîå çíà÷åíèå ôóíêöèè: ',f(oL.x))
end.