Mustaqil ish Mundarija Kirish I. Shimoli-g’arbiy burchak usuli


Shimoli-g'arbiy burchak qoidasi: 2-misol


Download 221.17 Kb.
bet3/4
Sana15.01.2023
Hajmi221.17 Kb.
#1094278
1   2   3   4
Bog'liq
Amallar tadqiqi,B.Kamolov

Shimoli-g'arbiy burchak qoidasi: 2-misol


Yorqin lampalar uchta zavodga ega - haftasiga mos ravishda 30, 50 va 20 dona ishlab chiqarish quvvatiga ega F 1 , F 2 va F 3 . Ushbu birliklar haftasiga mos ravishda 20, 40, 30 va 10 dona W 1 , W 2 , W 3 va W 4 bo'lgan to'rtta omborga jo'natilishi kerak . Zavodlar va omborlar o'rtasida transport xarajatlari (so'm bilan) quyida keltirilgan.

Shimoli-g'arbiy burchak qoidasidan foydalanib , berilgan transport muammosining dastlabki asosiy mumkin bo'lgan yechimini toping
Yechim.
Shimoliy-g'arbiy burchakdan boshlab, biz F 1 Vt 1 ga 20 birlik ajratamiz. Birinchi ustunga bo'lgan talab to'liq qondirildi.

1-jadval

Shu tarzda davom etsak, biz F 1 W 2 = 10, F 2 W 2 = 30, F 2 W 3 = 20, F 3 W 3 = 10, F 3 W 4 = 10 ekanligini ko'ramiz. Dastlabki asosiy mumkin bo'lgan yechim ko'rsatiladi quyida.
Yakuniy jadval

Asosiy o'zgaruvchilar soni = m + n – 1 = 3 + 4 – 1 = 6.

Boshlang'ich asosiy mumkin bo'lgan yechim


20 X 1 + 10 X 2 + 30 X 3 + 20 X 2 + 10 X 5 + 10 X 9 = 310.

Dasturning java dagi kodi
import java.util.Scanner;

public class Main {


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int qator, ustun, natija;
System.out.println("North West Corner Method");
System.out.println("Qatorlar sonini kiriting:");
qator = input.nextInt();
System.out.println("Ustunlar sonini kiriting:");
ustun = input.nextInt();
Integer[][] yacheyka = new Integer[qator][ustun];
Integer[] supply = new Integer[10];
Integer[] demand = new Integer[10];
Integer[][] bil = new Integer[10][10];
System.out.println("Matritsaning qator va ustunlar qiymatini kiriting");
for (int i = 0; i < qator; i++) {
for (int j = 0; j < ustun; j++) {
System.out.print("yacheyka[" + (i + 1) + "][" + (j + 1) + "]:");
yacheyka[i][j] = input.nextInt();
}
}
System.out.println();
System.out.println("Ustundagi qiymatlar:");
for (int i = 0; i < qator; i++) {
System.out.print("Taminot[" + (i + 1) + "]:");
supply[i] = input.nextInt();
}
System.out.println();
System.out.println("Qatordagi qiymatlar:");
for (int j = 0; j < ustun; j++) {
System.out.print("Talab[" + (j + 1) + "]:");
demand[j] = input.nextInt();
}
System.out.println();
System.out.println("Hosil bolgan transport jadvali");
for (int i = 0; i < qator; i++) {
for (int j = 0; j < ustun; j++) {
if (i == 0 && j == 0) {
if (supply[i] <= demand[j]) {
bil[i][j] = supply[i];
supply[i] = supply[i] - bil[i][j];
demand[j] = demand[j] - bil[i][j];
} else {
bil[i][j] = demand[j];
supply[i] = supply[i] - bil[i][j];
demand[j] = demand[j] - bil[i][j];
}
} else {
if (supply[i] <= demand[j]) {
bil[i][j] = supply[i];
supply[i] = supply[i] - bil[i][j];
demand[j] = demand[j] - bil[i][j];
} else {
bil[i][j] = demand[j];
supply[i] = supply[i] - bil[i][j];
demand[j] = demand[j] - bil[i][j];
}
}
}
}
for (int i = 0; i < qator; i++) {
for (int j = 0; j < ustun; j++) {
System.out.println(bil[i][j] + " ");
}
System.out.println();
}
natija = 0;
for (int i = 0; i < qator; i++) {
for (int j = 0; j < ustun; j++) {
natija = natija + (yacheyka[i][j] * bil[i][j]);
}
}
System.out.println("Xarajat: " + natija);
}
}


Download 221.17 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling