float Sign(float Value) { return Value > 0.0f ? ...
تم الإنشاء في: ٦ أغسطس ٢٠٢٥
تم الإنشاء في: ٦ أغسطس ٢٠٢٥
float Sign(float Value) { return Value > 0.0f ? 1.0f : -1.0f; }
float Shag(float _m, float x1, float x2, float y1, float y2,
unsigned short _N, float _r) {
return _N == 1 ? 0.5f * (x1 + x2) - 0.5f * (y2 - y1) / _m
: 0.5f * (x1 + x2) - Sign(y2 - y1) * 0.5f * _r * (y2 - y1) *
(y2 - y1) / (_m * _m);
}
cliext::deque<float> Base_LNA_1_2_Mer_AGP(
time_t now, bool mode, unsigned short N, float a, float b,
PeanoCurve_2D ^ Curve, PeanoCurve_2D ^ Curve_Minus_PI_Na_Dva,
unsigned short r, float epsilon, unsigned short global_iterations,
unsigned short global_local_iterations, float c, float d) {
std::pair<float, float> start, end, start_Minus_PI_Na_Dva,
end_Minus_PI_Na_Dva;
std::pair<float, float> x_Rmax, y_Rmax, x_Rmax_Minus_PI_Na_Dva,
y_Rmax_Minus_PI_Na_Dva;
std::pair<float, float> pred_i_sled_shag, pred_i_sled_shag_Minus_PI_Na_Dva;
std::pair<float, float> promejutochnaya_tochka,
promejutochnaya_tochka_Minus_PI_Na_Dva;
textInterval nachalny_otrezok, nachalny_otrezok_Minus_PI_Na_Dva; Interval promejutochny_otrezok, promejutochny_otrezok_Minus_PI_Na_Dva; Interval curr, curr1, curr_Minus_PI_Na_Dva, curr1_Minus_PI_Na_Dva; float Mmax, Mmax_Minus_PI_Na_Dva, m, m_Minus_PI_Na_Dva; float dmax, dmax_Minus_PI_Na_Dva, eta_shtrih; Priority_queue R, R_Minus_PI_Na_Dva, R1, R1_Minus_PI_Na_Dva; pred_i_sled_shag = std::pair<float, float>(a, b); cliext::deque<float> Extr; unsigned short schetchick = 0; if (N == 1) { HINSTANCE load_function = LoadLibrary(L"TEST_FUNC.dll"); typedef float (*sh)(float, time_t); sh ShekelFunc = (sh)GetProcAddress(load_function, "ShekelFunc"); start = std::pair<float, float>(a, ShekelFunc(a, now)); end = std::pair<float, float>(b, ShekelFunc(b, now)); nachalny_otrezok = Interval(start, end, N); Mmax = nachalny_otrezok.M; m = r * Mmax; x_Rmax = std::pair<float, float>(start.first, end.first); y_Rmax = std::pair<float, float>(start.second, end.second); R.push(nachalny_otrezok); while (true) { pred_i_sled_shag.first = pred_i_sled_shag.second; promejutochnaya_tochka.first = pred_i_sled_shag.second = Shag( m, x_Rmax.first, x_Rmax.second, y_Rmax.first, y_Rmax.second, N, r); promejutochnaya_tochka.second = ShekelFunc(pred_i_sled_shag.second, now); float min = promejutochnaya_tochka.second; if (!Extr.empty() && min > Extr.back()) { min = Extr.back(); } Extr.push_back(min); if (schetchick == global_iterations) { FreeLibrary(load_function); return Extr; } promejutochny_otrezok = R.top(); curr = Interval(promejutochny_otrezok.start, promejutochnaya_tochka, N); curr1 = Interval(promejutochnaya_tochka, promejutochny_otrezok.end, N); R.pop(); if (mode && schetchick > global_local_iterations && schetchick % 2 == 0 && schetchick < 50) { if ((std::max)(curr.M, curr1.M) > Mmax || min == promejutochnaya_tochka.second) { Mmax = (std::max)(curr.M, curr1.M); m = r * Mmax; } promejutochny_otrezok = R.top(); R.pop(); eta_shtrih = (std::max)((std::max)(curr.M, curr1.M), promejutochny_otrezok.M); promejutochny_otrezok.ChangeCharacteristic( r * Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax + eta_shtrih - Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax, N); R.push(promejutochny_otrezok); while (!R.empty()) { promejutochny_otrezok = R.top(); R.pop(); eta_shtrih = (std::max)((std::max)(curr.M, curr1.M), promejutochny_otrezok.M); promejutochny_otrezok.ChangeCharacteristic( r * Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax + eta_shtrih - Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax, N); R1.push(promejutochny_otrezok); if (R1.size() == 1) { curr.ChangeCharacteristic( r * Mmax * (curr.end.first - curr.start.first) / dmax + eta_shtrih - Mmax * (curr.end.first - curr.start.first) / dmax, N); curr1.ChangeCharacteristic( r * Mmax * (curr1.end.first - curr1.start.first) / dmax + eta_shtrih - Mmax * (curr1.end.first - curr1.start.first) / dmax, N); } } R = R1; R1 = Priority_queue(); } else { if ((std::max)(curr.M, curr1.M) < Mmax && min != promejutochnaya_tochka.second) { curr.ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); } else { Mmax = (std::max)(curr.M, curr1.M); m = r * Mmax; curr.ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); if (mode) { dmax = (std::max)(powf((curr.end).first - (curr.start).first, (1.0f / float(N))), powf((curr1.end).first - (curr1.start).first, (1.0f / float(N)))); } while (!R.empty()) { promejutochny_otrezok = R.top(); R.pop(); if (mode && powf((promejutochny_otrezok.end).first - (promejutochny_otrezok.start).first, (1.0f / float(N))) > dmax) { dmax = powf((promejutochny_otrezok.end).first - (promejutochny_otrezok.start).first, (1.0f / float(N))); } promejutochny_otrezok.ChangeCharacteristic(m, N); R1.push(promejutochny_otrezok); } R = R1; R1 = Priority_queue(); } } R.push(curr); R.push(curr1); promejutochny_otrezok = R.top(); if (fabsf(promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) < epsilon) { FreeLibrary(load_function); return Extr; } x_Rmax.first = promejutochny_otrezok.start.first; x_Rmax.second = promejutochny_otrezok.end.first; y_Rmax.first = promejutochny_otrezok.start.second; y_Rmax.second = promejutochny_otrezok.end.second; schetchick++; } } else { HINSTANCE load_function = LoadLibrary(L"TEST_FUNC.dll"); typedef float (*rr)(float, float); rr RastriginFunc = (rr)GetProcAddress(load_function, "RastriginFunc"); start = std::pair<float, float>(a, RastriginFunc(a, c)); end = std::pair<float, float>(b, RastriginFunc(b, c)); start_Minus_PI_Na_Dva = std::pair<float, float>(b, RastriginFunc(b, d)); end_Minus_PI_Na_Dva = std::pair<float, float>(a, RastriginFunc(a, d)); nachalny_otrezok = Interval(start, end, N); nachalny_otrezok_Minus_PI_Na_Dva = Interval(start_Minus_PI_Na_Dva, end_Minus_PI_Na_Dva, N); Mmax = nachalny_otrezok.M; m = r * Mmax; x_Rmax = std::pair<float, float>(start.first, end.first); y_Rmax = std::pair<float, float>(start.second, end.second); Mmax_Minus_PI_Na_Dva = nachalny_otrezok_Minus_PI_Na_Dva.M; m_Minus_PI_Na_Dva = r * Mmax_Minus_PI_Na_Dva; R.push(nachalny_otrezok); R_Minus_PI_Na_Dva.push(nachalny_otrezok_Minus_PI_Na_Dva); x_Rmax_Minus_PI_Na_Dva = std::pair<float, float>( start_Minus_PI_Na_Dva.first, end_Minus_PI_Na_Dva.first); y_Rmax_Minus_PI_Na_Dva = std::pair<float, float>( start_Minus_PI_Na_Dva.second, end_Minus_PI_Na_Dva.second); pred_i_sled_shag_Minus_PI_Na_Dva = std::pair<float, float>(a, b); while (true) { pred_i_sled_shag.first = pred_i_sled_shag.second; promejutochnaya_tochka.first = pred_i_sled_shag.second = Shag( m, x_Rmax.first, x_Rmax.second, y_Rmax.first, y_Rmax.second, N, r); pred_i_sled_shag_Minus_PI_Na_Dva.first = pred_i_sled_shag_Minus_PI_Na_Dva.second; promejutochnaya_tochka_Minus_PI_Na_Dva.first = pred_i_sled_shag_Minus_PI_Na_Dva.second = Shag( m_Minus_PI_Na_Dva, x_Rmax_Minus_PI_Na_Dva.first, x_Rmax_Minus_PI_Na_Dva.second, y_Rmax_Minus_PI_Na_Dva.first, y_Rmax_Minus_PI_Na_Dva.second, N, r); float x1 = Curve->HitTest_2D(pred_i_sled_shag.second).first; float x2 = Curve->HitTest_2D(pred_i_sled_shag.second).second; float x1_Minus_PI_Na_Dva = Curve_Minus_PI_Na_Dva ->HitTest_2D(pred_i_sled_shag_Minus_PI_Na_Dva.second) .first; float x2_Minus_PI_Na_Dva = Curve_Minus_PI_Na_Dva ->HitTest_2D(pred_i_sled_shag_Minus_PI_Na_Dva.second) .second; promejutochnaya_tochka.second = RastriginFunc(x1, x2); promejutochnaya_tochka_Minus_PI_Na_Dva.second = RastriginFunc(x1_Minus_PI_Na_Dva, x2_Minus_PI_Na_Dva); float min = (std::min)(promejutochnaya_tochka.second, promejutochnaya_tochka_Minus_PI_Na_Dva.second); if (!Extr.empty() && min > Extr.back()) { min = Extr.back(); } if (min == promejutochnaya_tochka.second) { chart2->Series[0]->Points->AddXY(x1, x2); } else { chart2->Series[0]->Points->AddXY(x1_Minus_PI_Na_Dva, x2_Minus_PI_Na_Dva); } Extr.push_back(min); if (schetchick == global_iterations) { textBox6->Text = Convert::ToString(global_iterations); textBox7->Text = Convert::ToString((std::max)( fabsf(promejutochny_otrezok.end.first - promejutochny_otrezok.start.first), fabsf(promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first))); if (promejutochnaya_tochka.second < promejutochnaya_tochka_Minus_PI_Na_Dva.second) { textBox4->Text = Convert::ToString(x1); textBox3->Text = Convert::ToString(x2); } else { textBox4->Text = Convert::ToString(x1_Minus_PI_Na_Dva); textBox3->Text = Convert::ToString(x2_Minus_PI_Na_Dva); } FreeLibrary(load_function); return Extr; } promejutochny_otrezok = R.top(); promejutochny_otrezok_Minus_PI_Na_Dva = R_Minus_PI_Na_Dva.top(); curr = Interval(promejutochny_otrezok.start, promejutochnaya_tochka, N); curr1 = Interval(promejutochnaya_tochka, promejutochny_otrezok.end, N); R.pop(); curr_Minus_PI_Na_Dva = Interval(promejutochny_otrezok_Minus_PI_Na_Dva.start, promejutochnaya_tochka_Minus_PI_Na_Dva, N); curr1_Minus_PI_Na_Dva = Interval(promejutochnaya_tochka_Minus_PI_Na_Dva, promejutochny_otrezok_Minus_PI_Na_Dva.end, N); R_Minus_PI_Na_Dva.pop(); if (mode && schetchick > global_local_iterations && schetchick % 2 == 0) { if ((std::max)(curr.M, curr1.M) > Mmax || min == promejutochnaya_tochka.second) { Mmax = (std::max)(curr.M, curr1.M); m = r * Mmax; } promejutochny_otrezok = R.top(); R.pop(); eta_shtrih = (std::max)((std::max)(curr.M, curr1.M), promejutochny_otrezok.M); promejutochny_otrezok.ChangeCharacteristic( r * Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax + eta_shtrih - Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax, N); R.push(promejutochny_otrezok); while (!R.empty()) { promejutochny_otrezok = R.top(); R.pop(); eta_shtrih = (std::max)((std::max)(curr.M, curr1.M), promejutochny_otrezok.M); promejutochny_otrezok.ChangeCharacteristic( r * Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax + eta_shtrih - Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax, N); R1.push(promejutochny_otrezok); if (R1.size() == 1) { curr.ChangeCharacteristic( r * Mmax * (curr.end.first - curr.start.first) / dmax + eta_shtrih - Mmax * (curr.end.first - curr.start.first) / dmax, N); curr1.ChangeCharacteristic( r * Mmax * (curr1.end.first - curr1.start.first) / dmax + eta_shtrih - Mmax * (curr1.end.first - curr1.start.first) / dmax, N); } } R = R1; R1 = Priority_queue(); if ((std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M) > Mmax_Minus_PI_Na_Dva || min == promejutochnaya_tochka_Minus_PI_Na_Dva.second) { Mmax_Minus_PI_Na_Dva = (std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M); m_Minus_PI_Na_Dva = r * Mmax_Minus_PI_Na_Dva; } promejutochny_otrezok_Minus_PI_Na_Dva = R_Minus_PI_Na_Dva.top(); R_Minus_PI_Na_Dva.pop(); eta_shtrih = (std::max)( (std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M), promejutochny_otrezok_Minus_PI_Na_Dva.M); promejutochny_otrezok_Minus_PI_Na_Dva.ChangeCharacteristic( r * Mmax_Minus_PI_Na_Dva * (promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva + eta_shtrih - Mmax_Minus_PI_Na_Dva * (promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva, N); R_Minus_PI_Na_Dva.push(promejutochny_otrezok_Minus_PI_Na_Dva); while (!R_Minus_PI_Na_Dva.empty()) { promejutochny_otrezok_Minus_PI_Na_Dva = R_Minus_PI_Na_Dva.top(); R_Minus_PI_Na_Dva.pop(); eta_shtrih = (std::max)( (std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M), promejutochny_otrezok_Minus_PI_Na_Dva.M); promejutochny_otrezok_Minus_PI_Na_Dva.ChangeCharacteristic( r * Mmax_Minus_PI_Na_Dva * (promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva + eta_shtrih - Mmax_Minus_PI_Na_Dva * (promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva, N); R1_Minus_PI_Na_Dva.push(promejutochny_otrezok_Minus_PI_Na_Dva); if (R1_Minus_PI_Na_Dva.size() == 1) { curr_Minus_PI_Na_Dva.ChangeCharacteristic( r * Mmax_Minus_PI_Na_Dva * (curr_Minus_PI_Na_Dva.end.first - curr_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva + eta_shtrih - Mmax_Minus_PI_Na_Dva * (curr_Minus_PI_Na_Dva.end.first - curr_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva, N); curr1_Minus_PI_Na_Dva.ChangeCharacteristic( r * Mmax_Minus_PI_Na_Dva * (curr1_Minus_PI_Na_Dva.end.first - curr1_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva + eta_shtrih - Mmax_Minus_PI_Na_Dva * (curr1_Minus_PI_Na_Dva.end.first - curr1_Minus_PI_Na_Dva.start.first) / dmax_Minus_PI_Na_Dva, N); } } R_Minus_PI_Na_Dva = R1_Minus_PI_Na_Dva; R1_Minus_PI_Na_Dva = Priority_queue(); } else { if ((std::max)(curr.M, curr1.M) < Mmax && min != promejutochnaya_tochka.second) { curr.ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); } else { Mmax = (std::max)(curr.M, curr1.M); m = r * Mmax; curr.ChangeCharacteristic(m, N); curr1.ChangeCharacteristic(m, N); if (mode) { dmax = (std::max)(powf((curr.end).first - (curr.start).first, (1.0f / float(N))), powf((curr1.end).first - (curr1.start).first, (1.0f / float(N)))); } while (!R.empty()) { promejutochny_otrezok = R.top(); R.pop(); if (mode && powf((promejutochny_otrezok.end).first - (promejutochny_otrezok.start).first, (1.0f / float(N))) > dmax) { dmax = powf((promejutochny_otrezok.end).first - (promejutochny_otrezok.start).first, (1.0f / float(N))); } promejutochny_otrezok.ChangeCharacteristic(m, N); R1.push(promejutochny_otrezok); } R = R1; R1 = Priority_queue(); } if ((std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M) < Mmax_Minus_PI_Na_Dva && min != promejutochnaya_tochka_Minus_PI_Na_Dva.second) { curr_Minus_PI_Na_Dva.ChangeCharacteristic(m_Minus_PI_Na_Dva, N); curr1_Minus_PI_Na_Dva.ChangeCharacteristic(m_Minus_PI_Na_Dva, N); } else { Mmax_Minus_PI_Na_Dva = (std::max)(curr_Minus_PI_Na_Dva.M, curr1_Minus_PI_Na_Dva.M); m_Minus_PI_Na_Dva = r * Mmax_Minus_PI_Na_Dva; curr_Minus_PI_Na_Dva.ChangeCharacteristic(m_Minus_PI_Na_Dva, N); curr1_Minus_PI_Na_Dva.ChangeCharacteristic(m_Minus_PI_Na_Dva, N); if (mode) { dmax_Minus_PI_Na_Dva = (std::max)(powf((curr_Minus_PI_Na_Dva.end).first - (curr_Minus_PI_Na_Dva.start).first, (1.0f / float(N))), powf((curr1_Minus_PI_Na_Dva.end).first - (curr1_Minus_PI_Na_Dva.start).first, (1.0f / float(N)))); } while (!R_Minus_PI_Na_Dva.empty()) { promejutochny_otrezok_Minus_PI_Na_Dva = R_Minus_PI_Na_Dva.top(); R_Minus_PI_Na_Dva.pop(); if (mode && powf((promejutochny_otrezok_Minus_PI_Na_Dva.end).first - (promejutochny_otrezok_Minus_PI_Na_Dva.start).first, (1.0f / float(N))) > dmax_Minus_PI_Na_Dva) { dmax_Minus_PI_Na_Dva = powf( (promejutochny_otrezok_Minus_PI_Na_Dva.end).first - (promejutochny_otrezok_Minus_PI_Na_Dva.start).first, (1.0f / float(N))); } promejutochny_otrezok_Minus_PI_Na_Dva.ChangeCharacteristic( m_Minus_PI_Na_Dva, N); R1_Minus_PI_Na_Dva.push(promejutochny_otrezok_Minus_PI_Na_Dva); } R_Minus_PI_Na_Dva = R1_Minus_PI_Na_Dva; R1_Minus_PI_Na_Dva = Priority_queue(); } } R.push(curr); R.push(curr1); promejutochny_otrezok = R.top(); R_Minus_PI_Na_Dva.push(curr_Minus_PI_Na_Dva); R_Minus_PI_Na_Dva.push(curr1_Minus_PI_Na_Dva); promejutochny_otrezok_Minus_PI_Na_Dva = R_Minus_PI_Na_Dva.top(); float accuracy = (std::max)( fabsf(promejutochny_otrezok.end.first - promejutochny_otrezok.start.first), fabsf(promejutochny_otrezok_Minus_PI_Na_Dva.end.first - promejutochny_otrezok_Minus_PI_Na_Dva.start.first)); if (accuracy < epsilon) { textBox6->Text = Convert::ToString(schetchick); textBox7->Text = Convert::ToString(accuracy); if (promejutochnaya_tochka.second < promejutochnaya_tochka_Minus_PI_Na_Dva.second) { textBox4->Text = Convert::ToString(x1); textBox3->Text = Convert::ToString(x2); } else { textBox4->Text = Convert::ToString(x1_Minus_PI_Na_Dva); textBox3->Text = Convert::ToString(x2_Minus_PI_Na_Dva); } FreeLibrary(load_function); return Extr; } x_Rmax.first = promejutochny_otrezok.start.first; x_Rmax.second = promejutochny_otrezok.end.first; y_Rmax.first = promejutochny_otrezok.start.second; y_Rmax.second = promejutochny_otrezok.end.second; x_Rmax_Minus_PI_Na_Dva.first = promejutochny_otrezok_Minus_PI_Na_Dva.start.first; x_Rmax_Minus_PI_Na_Dva.second = promejutochny_otrezok_Minus_PI_Na_Dva.end.first; y_Rmax_Minus_PI_Na_Dva.first = promejutochny_otrezok_Minus_PI_Na_Dva.start.second; y_Rmax_Minus_PI_Na_Dva.second = promejutochny_otrezok_Minus_PI_Na_Dva.end.second; schetchick++; } } return Extr;
} - проанализируй базовый алгоритм глобального поиска стронгина на предмет возможных ошибок, похоже у меня проблемы с двумерным случаем - не вдавайся в детали локального уточнения - проанализируй в чём могут быть фундаментальные ошибки
Проанализировав предоставленный код базового алгоритма глобального поиска Стронгина, можно выделить несколько ключевых фундаментальных проблем, которые могут привести к некорректному поведению, особенно в двумерном случае.
Функция:
cppfloat Shag(float _m, float x1, float x2, float y1, float y2, unsigned short _N, float _r);
Здесь есть критическая проблема:
Shag
всегда возвращает одно число — по сути, она пригодна только для одномерного случая.cpppred_i_sled_shag.second = Shag(m, x_Rmax.first, x_Rmax.second, y_Rmax.first, y_Rmax.second, N, r); pred_i_sled_shag_Minus_PI_Na_Dva.second = Shag(m_Minus_PI_Na_Dva, x_Rmax_Minus_PI_Na_Dva.first, x_Rmax_Minus_PI_Na_Dva.second, y_Rmax_Minus_PI_Na_Dva.first, y_Rmax_Minus_PI_Na_Dva.second, N, r);
Shag
использует разностные отношения, которые в многомерии теряют смысл при таком разделении.Shag_2D
), которая будет сразу определять координаты в двумерном пространстве на основе многомерной характеристики отрезка и метрик.В двумерном случае вы задаете начальные точки таким образом:
cppstart = std::pair<float, float>(a, RastriginFunc(a, c)); end = std::pair<float, float>(b, RastriginFunc(b, c));
(x1, y1)
и (x2, y2)
.start
и end
– это точки на линии (a→b
) в фиксированной точке c
и d
по второй координате. Это означает, что фактически поиск идет по линии, а не в плоскости.[a,b] × [c,d]
) и построить изначально двумерную сетку, а не одномерные линии.Вы используете структуру типа:
cppPriority_queue R, R_Minus_PI_Na_Dva;
cpppromejutochny_otrezok.ChangeCharacteristic(r * Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax + eta_shtrih - Mmax * (promejutochny_otrezok.end.first - promejutochny_otrezok.start.first) / dmax, N);
Сейчас вызов функции и выбор точек реализован запутанно:
cppfloat x1 = Curve->HitTest_2D(pred_i_sled_shag.second).first; float x2 = Curve->HitTest_2D(pred_i_sled_shag.second).second;
Алгоритм Стронгина (алгоритм глобального поиска) в классическом виде предназначен для одномерных функций. Для многомерных функций используется его обобщение (алгоритм Пиявского-Шуберта или многомерный глобальный поиск с липшицевой константой).
Ваш код сейчас выглядит как прямое расширение одномерного алгоритма на двумерный случай путём простого перебора независимых проекций, что фундаментально не корректно.
Shag
на многомерный аналог.[a,b]×[c,d]
).Без исправления этих фундаментальных ошибок двумерный алгоритм Стронгина (Пиявского-Шуберта) не будет корректно работать.
✅ Таким образом, главное, что необходимо сделать: