btnNext.Enabled = False
lblRes.Visible = True
Exit Sub
End If
jr = i
For j = i + 1 To n
If f(j) < 0 And f(jr) < f(j) Then jr = j
Next j
i = 1
While i <= r
If x(i, jr) > 0 Then GoTo 5
i = i + 1
Wend
MsgBox Str(jr) & " " & Chr(13) & Chr(10) & "Решениянет"
Exit Sub
' нахождение разрешающего элемента
5: ir = i
Min = x(i, 0) / x(i, jr)
For j = i + 1 To r
If x(j, jr) > 0 Then
d = x(j, 0) / x(j, jr)
If Min > d Then
Min = d
ir = j
End If
End If
Next j
k = x(ir, jr)
For j = 0 To n
x(ir, j) = x(ir, j) / k
Next j
For i = 1 To r
If i <> ir Then
d = x(i, jr)
For j = 0 To n
x(i, j) = x(i, j) - x(ir, j) * d
Next j
End If
Next i
d = f(jr)
For j = 0 To n
f(j) = f(j) - x(ir, j) * d
Next j
p(ir) = jr
' вывод данных в таблицу
grdData.Row = r + 1
For i = 1 To n + 1
grdData.Col = i
grdData.Text = Str(f(i - 1))
Next i
For i = 1 To r
grdData.Row = i
For j = 0 To n + 1
grdData.Col = j
If j = 0 Then
grdData.Text = " = " & Str(p(i))
Else
grdData.Text = Str(x(i, j - 1))
End If
Next j
Next i
End Sub
Private Sub Form_Load()
'основная матрица
lblyr(0).Caption = " 9 = 0.5X1 + 0.5X2 + 2X3 + X4 + 0X5 + 0X6 + 0X7 + 0X8"
lblyr(1).Caption = " 12 = 2X1 + X2 + X3 + 0X4 + X5 + 0X6 + 0X7 + 0X8"
lblyr(2).Caption = " 12 = 2X1 + 0X2 + X3 + 0X4 + 0X5 + X6 + 0X7 + 0X8"
lblyr(3).Caption = " 8 = X1 + 2X2 + 0.5X3 + 0X4 + 0X5 + 0X6 + X7 + 0X8"
lblyr(4).Caption = " 16 = 0X1 + 0.5X2 + X3 + 0X4 + 0X5 + 0X6 + 0X7 + X8"
lblyr(5).Caption = " F = 22 + 36 + 28 + 0 + 0 + 0 + 0 + 0"
' Загрузка массива исходных данных
p = Array(pv(0), pv(1), pv(2), pv(3), pv(4), pv(5))
fm = Array(fmMin(0), fmMin(1), fmMin(2), fmMin(3), fmMin(4), fmMin(5), fmMin(6), fmMin(7))
f = fm
xn(1) = Array(Ar(1, 0), Ar(1, 1), Ar(1, 2), Ar(1, 3), Ar(1, 4), Ar(1, 5), Ar(1, 6), Ar(1, 7))
xn(2) = Array(Ar(2, 0), Ar(2, 1), Ar(2, 2), Ar(2, 3), Ar(2, 4), Ar(2, 5), Ar(2, 6), Ar(2, 7))
xn(3) = Array(Ar(3, 0), Ar(3, 1), Ar(3, 2), Ar(3, 3), Ar(3, 4), Ar(3, 5), Ar(3, 6), Ar(3, 7))
xn(4) = Array(Ar(4, 0), Ar(4, 1), Ar(4, 2), Ar(4, 3), Ar(4, 4), Ar(4, 5), Ar(4, 6), Ar(4, 7))
xn(5) = Array(Ar(5, 0), Ar(5, 1), Ar(5, 2), Ar(5, 3), Ar(5, 4), Ar(5, 5), Ar(5, 6), Ar(5, 7))
grdData.Row = r + 1
For i = 1 To n + 1
grdData.Col = i
'запись строки в таблицу
grdData.Text = Str(f(i - 1))
Next i
For i = 1 To r
grdData.Row = i
For j = 0 To n + 1
grdData.Col = j
If j = 0 Then
grdData.Text = " = " & Str(p(i - 1))
Else
x(i, j - 1) = xn(i)(j - 1)
grdData.Text = Str(x(i, j - 1))
End If
Next j
Next i
grdData.Cols = n + 2
grdData.Rows = r + 2
grdData.Col = 0
grdData.Row = 0
grdData.Text = "Св. член"
For i = 1 To n + 1
grdData.Col = i
grdData.Text = "X" & Str(i)
Next i
grdData.Col = 0
grdData.Row = r + 1
grdData.Text = "Fmin"
End Sub
'Private Sub grdData_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyDelete Or KeyCode = vbKeyBack) Or (Len(grdData.Text) = 2 And grdData.Col = 0) Then
grdData.Text = ""
End If
End Sub
Private Sub grdData_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 48 And KeyAscii <= 57 And grdData.Col = 0) Then
If Chr(KeyAscii) <= n Then
If grdData.Row <= r Then
grdData.Text = " "
p(grdData.Col) = Chr(KeyAscii)
End If
Else
Exit Sub
End If
End If
If (KeyAscii = 45) And (grdData.Col > 0) Then grdData.Text = Chr(KeyAscii)
If (((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii = 46)) And (grdData.Col > 0)) Or _
((KeyAscii >= 48 And KeyAscii <= 57) And (grdData.Col = 0) And (grdData.Row <= r)) Then
grdData.Text = grdData.Text & Chr(KeyAscii)
End If
End Sub
Private Sub cmdIn_Click()
frmFlash.Show
cmdIn.Visible = False
cmdIninf.Visible = True
End Sub
Private Sub cmdIninf_Click()
Dim i
For i = 0 To 4
If Text1(i).Text = "" Then Text1(i).Text = 0
pv(i) = CSng(Text1(i).Text)
Next
For i = 0 To 7
If Text2(i).Text = "" Then Text2(i).Text = 0
fmMin(i) = CSng(Text2(i).Text)
Next
For i = 0 To 7
If Text3(i).Text = "" Then Text3(i).Text = 0
Ar(1, i) = CSng(Text3(i).Text)
Next
For i = 0 To 7
If Text4(i).Text = "" Then Text4(i).Text = 0
Ar(2, i) = CSng(Text4(i).Text)
Next
For i = 0 To 7
If Text5(i).Text = "" Then Text5(i).Text = 0
Ar(3, i) = CSng(Text5(i).Text)
Next
For i = 0 To 7
If Text6(i).Text = "" Then Text6(i).Text = 0
Ar(4, i) = CSng(Text6(i).Text)
Next
For i = 0 To 7
If Text7(i).Text = "" Then Text7(i).Text = 0
Ar(5, i) = CSng(Text7(i).Text)
Next
Load frmSimpl
frmSimpl.Show
frmIn.Hide
EndSub
Список используемой литературы
1. Шыныбаев М.А. "Курсовая работа по моделированию производственных и экономических процессов." - Талдыкорган. ТПТК 1999 г.
2. Солодовников А.С. "Введение в линейную алгебру и линейное программирование." - М. Просвещение, 1966.
3. Банди Б. "Методы оптимизации" - М. Радио и связь, 1988.
4. Дебора Курата. "Использование объектов в среде VisualBasic". М. Институт освоения информационных систем1998г.
5. Скотт Б. "Программирование VisualBasic 5.0." 1999г.
6. Рамакин Н.И "Элементы линейной алгебры и линейного программирования" Москва "Просвещение 1963г"
7. Солодовский А.С "Системы линейных неравенств" 2-е издание
8. Наука 1977г
9. Кузнецов Ю.Н "Математическое программирование" г Москва
10. Высшая школа 1980г