0% found this document useful (0 votes)
27 views10 pages

Shaxsiy Topshiriq

The document outlines a practical assignment for the course 'Algorithm Design' at Tashkent University of Information Technologies. It includes tasks such as finding the roots of an equation using the secant and Newton methods, formulating a linear programming problem, and applying the simplex method for optimization. Additionally, it provides economic analysis and recommendations for improving the mathematical model based on the results obtained.

Uploaded by

sayramovazizbek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

Shaxsiy Topshiriq

The document outlines a practical assignment for the course 'Algorithm Design' at Tashkent University of Information Technologies. It includes tasks such as finding the roots of an equation using the secant and Newton methods, formulating a linear programming problem, and applying the simplex method for optimization. Additionally, it provides economic analysis and recommendations for improving the mathematical model based on the results obtained.

Uploaded by

sayramovazizbek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

RAQAMLI TEXNOLOGIYALAR VAZIRLIGI

MUHAMMAD AL-XORAZMIY NOMIDAGI


TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

“ALGORITMLARNI LOYIHALASH” FANIDAN

AMALIY ISH

Bajardi : Sayramov Azizbek

Toshkent – 2025
Topshiriq variantlari N=17
Variant parametrlarini quyidagicha aniqlang: n1={N/3}+1; n2={N/5}+1;
n3={N/7}+1, bu yerda N talabalarning potokdagi nomeri. {N/3} bu N sonini 3
ga bo‘lgandagi qoldig‘i. Misol: N=7 {7/3}=1.
Tenglamani hosil qiling:

1. Tenglamaning yechim joylashgan oralig‘ini toping. Vatarlar usuli yordamida


ildizlarni e=10-5 aniqlik bilan hisoblash algoritmini tuzing. Bunday aniqllika
erishish uchun zarur qadamlar sonini aniqlang.
2. Ushbu masalani Nyuton usuli orqali yechish algoritmini tuzing. Ikkala
usulda ham yechimlarni oling. Ko‘rib chiqilgan usullar samaradorligini
taqqoslang.
3. Chiziqli dasturlash masalasini hosil qiling:

Geometrik usulda mumkin bo‘lgan yechimlar sohasini toping. Tayanach


yechimlarni aniqlang. Optimal yechimni toping.
Egizak masalani shakllantiring va u uchun ChDM tuzib, tayanch yechimlarni
aniqlang. Shuningdek geometrik usulda optimal yechimni toping.
4. ChDM ni simpleks usulida hisoblang. Topilgan yechimlardan iqtisodiy tahlil
o‘tkazing. Tegishli matematik modelni ishlab chiqarishni takomillashtirish
bo‘yicha tavsiyalarni shakllantiring.
📌 Variant parametrlarini hisoblaymiz:
N = 17 bo‘lsa:
 n₁ = {N / 3} + 1 = {17 / 3} + 1 = 2 + 1 = 3
 n₂ = {N / 5} + 1 = {17 / 5} + 1 = 2 + 1 = 3
 n₃ = {N / 7} + 1 = {17 / 7} + 1 = 3 + 1 = 4
Shunday qilib, berilgan tenglama:

✅ 1. Yechim oralig‘ini topish va vatarlar (secant) usuli bilan hisoblash


Biz ushbu tenglamaning ildizlarini topishimiz kerak:

Demak, f(1)<0, f(2)>0 ⇒ oraliq: [1, 2]


✅ 2. Vatarlar (secant) usuli algoritmi:
Vatarlar usuli quyidagi formulaga asoslanadi:

✅ 3. Har bir iteratsiya (qadam) uchun hisob-kitob:


Quyidagi qiymatlar oldin hisoblangan:
| Iteratsiya | x₀ | x₁ | x₂ | f(x₂) |
|-------------|-----------|-----------|------------|---------------| | 1 | 1.000000 | 2.000000 |
1.230769 | -1.283569 | | 2 | 2.000000 | 1.230769 | 1.318273 | -0.450330 | | 3 |
1.230769 | 1.318273 | 1.365566 | 0.044080 | | 4 | 1.318273 | 1.365566 | 1.361349 | -
0.001280 | | 5 | 1.365566 | 1.361349 | 1.361468 | -0.000003 |
✅ Oxirgi 2 ta nuqta orasidagi farq:

🔚 Natija:
 Yechim oralig‘i: [1, 2]
 Yechim: x≈1.361468
 Zarur qadamlar soni: 5
 Aniqlik: ε=10−^5
✅ 3. Chiziqli dasturlash masalasini tuzamiz
a) Parametrlar:

b) Cheklovlar (berilgan formulalarga parametrlarni qo‘yamiz):

✅ Yangi ko‘rinishda ChDM:

✅ Egizak masala (Dual problem)


ChDM 3 ta shart va 3 ta o‘zgaruvchidan iborat. Egizak masala (min) bo‘ladi:
Shartlar:

✅ Simpleks usuli natijasi:


Topilgan optimal yechim quyidagicha:

📊 Iqtisodiy tahlil:
Agar:

Takomillashtirish bo‘yicha tavsiyalar:


1. Resurslar hajmini oshirish:
o 1-, 2-, yoki 3-cheklovdagi qiymatlar oshirilsa, maksimal foyda yanada
ortishi mumkin.
2. Mahsulotlarning qiymatini tahlil qilish:
o Agar 2-turdagi mahsulotning foydasi oshirilsa, optimal strategiya
o‘zgarishi mumkin.
3. Ikkilik (binary) cheklovlar qo‘shish:
o Masalan, mahsulotlardan faqat bittasini chiqarish mumkin bo‘lsa —
bu uchun butun sonli dasturlash kerak bo‘ladi.
4. Egizak masalani ham yechib, resurslar qiymatini (shadow price) baholash
mumkin.
Dastur kodi
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

const int MAX_VAR = 3; // x1, x2, x3


const int MAX_CON = 3; // 3 constraints
const int MAX_COL = MAX_VAR + MAX_CON + 1; // variables + slack + RHS

double tableau[MAX_CON + 1][MAX_COL]; // last row = objective function

void initialize() {
// Constraints (with slack variables)
double constraints[MAX_CON][MAX_COL] = {
{15, 10, 5, 1, 0, 0, 290},
{10, 4, 12, 0, 1, 0, 262},
{4, 15, 10, 0, 0, 1, 296}
};

// Objective function (negative coefficients for max problem)


double objective[MAX_COL] = {-1800, -2000, -1500, 0, 0, 0, 0};
for (int i = 0; i < MAX_CON; i++)
for (int j = 0; j < MAX_COL; j++)
tableau[i][j] = constraints[i][j];

for (int j = 0; j < MAX_COL; j++)


tableau[MAX_CON][j] = objective[j];
}

void print_tableau() {
cout << fixed << setprecision(2);
cout << "Simplex Tableau:\n";
for (int i = 0; i <= MAX_CON; i++) {
for (int j = 0; j < MAX_COL; j++)
cout << setw(8) << tableau[i][j] << " ";
cout << endl;
}
cout << "------------------------\n";
}

int findPivotColumn() {
int pivotCol = 0;
double min = tableau[MAX_CON][0];
for (int j = 1; j < MAX_COL - 1; j++) {
if (tableau[MAX_CON][j] < min) {
min = tableau[MAX_CON][j];
pivotCol = j;
}
}
return min < 0 ? pivotCol : -1;
}
int findPivotRow(int pivotCol) {
int pivotRow = -1;
double minRatio = 1e9;
for (int i = 0; i < MAX_CON; i++) {
if (tableau[i][pivotCol] > 0) {
double ratio = tableau[i][MAX_COL - 1] / tableau[i][pivotCol];
if (ratio < minRatio) {
minRatio = ratio;
pivotRow = i;
}
}
}
return pivotRow;
}

void pivot(int row, int col) {


double pivotVal = tableau[row][col];
for (int j = 0; j < MAX_COL; j++)
tableau[row][j] /= pivotVal;

for (int i = 0; i <= MAX_CON; i++) {


if (i != row) {
double factor = tableau[i][col];
for (int j = 0; j < MAX_COL; j++)
tableau[i][j] -= factor * tableau[row][j];
}
}
}
void simplex() {
while (true) {
int pivotCol = findPivotColumn();
if (pivotCol == -1) break;
int pivotRow = findPivotRow(pivotCol);
if (pivotRow == -1) {
cout << "Yechim mavjud emas (inf)." << endl;
return;
}
pivot(pivotRow, pivotCol);
print_tableau();
}

cout << "Optimal qiymat: " << -tableau[MAX_CON][MAX_COL - 1] << endl;


cout << "Optimal x qiymatlari:\n";
for (int j = 0; j < MAX_VAR; j++) {
bool isBasic = false;
double val = 0;
for (int i = 0; i < MAX_CON; i++) {
if (tableau[i][j] == 1) {
bool isUnit = true;
for (int k = 0; k < MAX_CON; k++) {
if (k != i && tableau[k][j] != 0) {
isUnit = false;
break;
}
}
if (isUnit) {
isBasic = true;
val = tableau[i][MAX_COL - 1];
break;
}
}
}
cout << "x" << j + 1 << " = " << (isBasic ? val : 0) << endl;
}
}

int main() {
initialize();
print_tableau();
simplex();
return 0;
}
NATIJA

You might also like