Simpleks usulining mazmun-mohiyati; Simpleks jadvalini tuzish



Yüklə 288,59 Kb.
səhifə5/5
tarix19.05.2023
ölçüsü288,59 Kb.
#118130
1   2   3   4   5
Mamasoliyev Abror chiziqli algebra

#include
#include
#include
#include "SimplexSolver.h"
#include "exception.h"

using namespace std;
using namespace Eigen;

int main()
{
MatrixXd constraints(3, 3);
VectorXd objectiveFunction(2);
try {
/*
Maximization problem
*/
objectiveFunction << 1,
2;

constraints << 2, 3, 34,
1, 5, 45,
1, 0, 15;

SimplexSolver solver1(SIMPLEX_MAXIMIZE, objectiveFunction, constraints);

if (solver1.hasSolution()) {
cout << "The maximum is: " << solver1.getOptimum() << endl;
cout << "The solution is: " << solver1.getSolution().transpose() << endl;
} else {
cout << "The linear problem has no solution." << endl;
}

cout << endl;
/*
Minimization problem
*/
objectiveFunction << 3,
4;

constraints << 2, 1, 8,
1, 2, 13,
1, 5, 16;
SimplexSolver solver2(SIMPLEX_MINIMIZE, objectiveFunction, constraints);

if (solver2.hasSolution()) {
cout << "The minimum is: " << solver2.getOptimum() << endl;
cout << "The solution is: " << solver2.getSolution().transpose() << endl;
} else {
cout << "The linear problem has no solution." << endl;
}
} catch (const FException &ex) {
ex.Print();
return 1; } return 0;}
Foydalanilgan adabiyotlar va saytlar:
Yo. Soatov oliy matematika asoslari 1-3 qism Toshkent 1995
www.cplusplus.com
www.fayl.org.uz
www.ziyo.uz
Yüklə 288,59 Kb.

Dostları ilə paylaş:
1   2   3   4   5




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin