Revert "Deleted manual input function"

This reverts commit fa123e0fb0.
This commit is contained in:
Ilya Grigorev
2024-10-07 21:06:00 +05:00
parent 9b67db3629
commit 262894d00d
13 changed files with 1017 additions and 1 deletions
+72
View File
@@ -0,0 +1,72 @@
#include <iostream>
#include "tools/matrix.h"
#include "tools/math.h"
#include "simplex.h"
void manualInput() {
int ZLength;
std::cout << "Write how many x's the objective function has:" << std::endl;
std::cin >> ZLength;
Vector Z = {};
}
void printInitialInputs(Vector C, Matrix A, Vector b) {
}
int main() {
// TODO: Initially should be positive
std::string doManual = "";
std::cout << "Enable manual input? (y/n)" << std::endl;
std::cin >> doManual ;
if (doManual == "y" or doManual == "Y") {
manualInput();
} else if (doManual == "n"){
}
Vector C = {5, 4, 0, 0, 0, 0};
Matrix A = {
{6, 4, 1, 0, 0, 0},
{1, 2, 0, 1, 0, 0},
{-1, 1, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 1}
};
Vector b = {24, 6, 1, 2};
for (int i = 0; i < b.size(); i++) {
if (b[i] < 0) {
std::cout << "Error: method is not applicable" << std::endl;
return 1;
}
}
//Matrix test = {{1, -1, -2}, {1, 1, -2}, {1, -1, 2}};
//showMatrix(test);
Result result = Simplex(C, A, b, 0.1, true);
if(result.state == bounded) {
if(result.solution == nullptr) {
std::cout << "Error: no solution value is returned" << std::endl;
return 1;
}
std::cout << *result.solution << std::endl;
std::cout << result.objective_fucntion_value << std::endl;
delete result.solution;
}
else {
std::cout << "Error: unbounded" << std::endl;
return 1;
}
//std::cout << "asdasd" << std::endl;
return 0;
}