Файл: Методы оптимизации.docx

ВУЗ: Не указан

Категория: Отчеты по практике

Дисциплина: Не указана

Добавлен: 28.04.2024

Просмотров: 25

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.


{

Xh = Function(X11, X12);

Xh1 = X11;

Xh2 = X12;

}

else if (Function(X21, X22) > Function(X11, X12) && Function(X21, X22) >

Function(X31, X32))

{

Xh = Function(X21, X22);

Xh1 = X21;

Xh2 = X22;

}

else

{

Xh = Function(X31, X32);

Xh1 = X31;

Xh2 = X32;

}

if (Function(X11, X12) < Function(X21, X22) && Function(X11, X12) <

Function(X31, X32))

{

Xl = Function(X11, X12);

Xl1 = X11;

Xl2 = X12;

}

else if (Function(X21, X22) < Function(X11, X12) && Function(X21, X22) <

Function(X31, X32))

{

Xl = Function(X21, X22);

Xl1 = X21;

Xl2 = X22;

}

else

{

Xl = Function(X31, X32);

Xl1 = X31;

Xl2 = X32;

}

do

{

Console.Write("(" + Math.Round(X11, 2) + ";" + Math.Round(X12, 2) + ") " + Math.Round(Function(X11, X12), 2) + " ");
Console.Write("(" + Math.Round(X21, 2) + ";" + Math.Round(X22, 2) + ") " + Math.Round(Function(X21, X22), 2) + " ");
Console.Write("(" + Math.Round(X31, 2) + ";" + Math.Round(X32, 2) + ") " + Math.Round(Function(X31, X32), 2) + " ");
Console.WriteLine(count);

//смещенный центр тяжести

if (Xh == Function(X11, X12))

{

X41 = (X21 + X31) / n;

X42 = (X22 + X32) / n;

}

else if (Xh == Function(X21, X22))

{

X41 = (X11 + X31) / n;

X42 = (X12 + X32) / n;

}

else

{

X41 = (X11 + X21) / n;

X42 = (X12 + X22) / n;

}

//точка отражения

X51 = 2 * X41 - Xh1;

X52 = 2 * X42 - Xh2;

if (Function(X51, X52) < Xl)

{

//точка растяжения

X61 = 2 * X51 - X41;

X62 = 2 * X52 - X42;

if (Function(X61, X62) < Xl)

{

Xh1 = X61;

Xh2 = X62;

Xh = Function(Xh1, Xh2);

}

else

{

Xh1 = X51;

Xh2 = X52;

Xh = Function(Xh1, Xh2);

}

}

else

{

if (Function(X51, X52) > Function(X11, X12) && Function(X51, X52)

> Function(X21, X22) && Function(X51, X52) > Function(X31, X32))

{

if (Function(X51, X52) > Xh)

{

//редукция

X11 = 0.5 * Xl1 + 0.5 * X11;

X12 = 0.5 * Xl2 + 0.5 * X12;

X21 = 0.5 * Xl1 + 0.5 * X21;

X22 = 0.5 * Xl2 + 0.5 * X22;

X31 = 0.5 * Xl1 + 0.5 * X31;

X32 = 0.5 * Xl2 + 0.5 * X32;

if (Function(X11, X12) > Function(X21, X22) &&

Function(X11, X12) > Function(X31, X32) && Function(X11, X12) > Max)

{

Xh = Function(X11, X12);

Xh1 = X11;

Xh2 = X12;

}

else if (Function(X21, X22) > Function(X11, X12) &&

Function(X21, X22) > Function(X31, X32) && Function(X21, X22) > Max)

{

Xh = Function(X21, X22);

Xh1 = X21;

Xh2 = X22;

}

else

{

Xh = Function(X31, X32);

Xh1 = X31;

Xh2 = X32;

}

if (Function(X11, X12) < Function(X21, X22) &&

Function(X11, X12) < Function(X31, X32) && Function(X11, X12) < Min)

{

Xl = Function(X11, X12);

Xl1 = X11;

Xl2 = X12;

}

else if (Function(X21, X22) < Function(X11, X12) &&

Function(X21, X22) < Function(X31, X32) && Function(X21, X22) < Min)

{

Xl = Function(X21, X22);

Xl1 = X21;

Xl2 = X22;

}

else

{

Xl = Function(X31, X32);

Xl1 = X31;

Xl2 = X32;

}

}

else

{

//Сжатие

X71 = 0.5 * X51 - X41;

X72 = 0.5 * X52 - X42;

if (Function(X71, X72) > Xh)

{

//редукция

X11 = 0.5 * Xl1 + 0.5 * X11;

X12 = 0.5 * Xl2 + 0.5 * X12;

X21 = 0.5 * Xl1 + 0.5 * X21;

X22 = 0.5 * Xl2 + 0.5 * X22;

X31 = 0.5 * Xl1 + 0.5 * X31;

X32 = 0.5 * Xl2 + 0.5 * X32;

if (Function(X11, X12) > Function(X21, X22) &&

Function(X11, X12) > Function(X31, X32) && Function(X11, X12) > Max)

{

Xh = Function(X11, X12);

Xh1 = X11;

Xh2 = X12;

}

else if (Function(X21, X22) > Function(X11, X12) &&


Function(X21, X22) > Function(X31, X32) && Function(X21, X22) > Max)

{

Xh = Function(X21, X22);

Xh1 = X21;

Xh2 = X22;

}

else

{

Xh = Function(X31, X32);

Xh1 = X31;

Xh2 = X32;

}

if (Function(X11, X12) < Function(X21, X22) &&

Function(X11, X12) < Function(X31, X32) && Function(X11, X12) < Min)

{

Xl = Function(X11, X12);

Xl1 = X11;

Xl2 = X12;

}

else if (Function(X21, X22) < Function(X11, X12) &&

Function(X21, X22) < Function(X31, X32) && Function(X21, X22) < Min)

{

Xl = Function(X21, X22);

Xl1 = X21;

Xl2 = X22;

}

else

{

Xl = Function(X31, X32);

Xl1 = X31;

Xl2 = X32;

}

}

else

{

Xh1 = X71;

Xh2 = X72;

Xh = Function(Xh1, Xh2);

}

}

}

else

{

Xh1 = X51;

Xh2 = X52;

Xh = Function(Xh1, Xh2);

}

}

count++;

A = (Math.Pow(Function(X11, X12) - Function(X41, X42), 2) +

Math.Pow(Function(X21, X22) - Function(X41, X42), 2) + Math.Pow(Function(X31, X32) -

Function(X41, X42), 2)) / (n + 1);

} while (A >= 0.01);

Console.WriteLine();

}

public static double T(double X11, double X12, double t)

{

return (X11 - t * DeFfirst(X11, X12) - 2) * (X11 - t * DeFfirst(X11, X12) - 2)

+ (X12 - t * DeFsecond(X11, X12) - 7) * (X12 - t * DeFsecond(X11, X12) - 7) + 50

* (X12 - t * DeFsecond(X11, X12) + 2 * (X11 - t * DeFfirst(X11, X12)) - 6) * (X12 - t

* DeFsecond(X11, X12) + 2 * (X11 - t * DeFfirst(X11, X12)) - 6) + 7.6;

}

}

}