Professional Documents
Culture Documents
Лр2 Бойко КН-22мс
Лр2 Бойко КН-22мс
Лабораторна робота №2
з дисципліни «ММДО»
Розробка алгоритму і програми для розв’язання задач лінійного програмування
симплекс-методом.
Вінниця 2022
Мета: набути навичок практичного розв’язання ЗЛП табличним симплекс-
методом та його програмної реалізації.
Хід роботи
Практичні завдання
Варіант 28.
Умова:
Розв’язання:
Блок-схема програми для обчислення визначника матриці:
Інструкція користувача
Лістинг програми
<script>
let variablesCount = 3;
let limitationCount = 3;
let resultF;
function Calculate(){
basis[j] = i;
while(!IsOptimal(Fdata)){
biaij[i] = matrix[i][variablesCount+limitationCount] /
matrix[i][minIndexOfFData];
console.log(biaij[i]+" =
"+matrix[i][variablesCount+limitationCount]+' / '+matrix[i][minIndexOfFData]);
}
let currentRowIndex = GetCurrentRowIndex(biaij);
console.log(currentRowIndex);
console.table(biaij);
if(currentRowIndex == undefined){
resultIsInfinity = true;
break;
basis[currentRowIndex] = minIndexOfFData;
if(matrix[currentRowIndex][minIndexOfFData] != 1){
matrix[currentRowIndex][i] /= divider;
let multiple;
console.log(currentRowIndex+" : "+j);
console.log(matrix[j][currentRowIndex]);
if(currentRowIndex == j) continue;
if(matrix[j][minIndexOfFData] == 0) continue;
multiple = -(matrix[j][minIndexOfFData] /
currentRowCopy[minIndexOfFData]);
multiple = -(Fdata[minIndexOfFData] /
currentRowCopy[minIndexOfFData]);
console.table(Fdata);
console.table(matrix);
if(!resultIsInfinity) {
variables[j] = [];
variables[j][0] = basis[j];
variables[j][1] = matrix[j][variablesCount+limitationCount];
if(variables[j][0] == i){
resultVariables[i] = variables[j][1];
break;
}else resultVariables[i] = 0;
console.table(resultVariables);
console.log(resultF);
function GetFData(){
console.log();
console.table();
Fdata[i] = Number(document.getElementById("FVariable-"+i).value);
Fdata[i] = 0;
console.table(Fdata);
return Fdata;
function GetMatrix(){
}
}
console.table(matrix);
return matrix;
function IsOptimal(array){
if(array[i] < 0) {
isOptimal = false;
break;
return isOptimal;
function GetMinIndex(array){
let minIndex = 0;
min = array[i];
minIndex = i;
return minIndex;
function GetCurrentRowIndex(array){
let minIndex;
min = array[i];
minIndex = i;
return minIndex;
</script>
<header>
</header>
<main>
<div class="countSelectors">
</div><br>
<div class="inequalitiesContainer">
<div class="inequalityFx">
F(x) =
{/each}
<select id="VectorF">
<option value="max">max</option>
<option value="min">min</option>
</select>
</div><br><br>
<div class="inequalitiesLimitation">
Нерівність {limId+1}:
{/each}
<select id="sign-{limId}">
<option value="≤">≤</option>
<option value="≥">≥</option>
</select>
<br><br>
{/each}
</div>
<br><br>
<div class="resultContainer">
F* = {Math.round(resultF*100)/100}
<br><br>
X* = (
{Math.round(variable*100)/100},
{/each}
)
</div>
{/if}
{#if resultIsInfinity}
<br><br>
<div class="resultContainer">
</div>
{/if}
</div>
</main>