#include"Liear-plan.h"
#include<iostream>
#include<stdio.h>
using namespace std;
/*
作者:亢佳俊
最后一次修改时间:2020.9.14 9:15
修改内容:查改了几处bug,增加了展示模块
程序功能:实现任意变量任意方程的线性规划求解
核心算法:
1.求解初始可行解,若直接构造不满足,通过辅助线性规划寻找可行基
2.求解过程:通过转动交换基础基和非基础,直到检验数为0
3.规避退化过程:每次转动时换入变量都选择序号最小的变量
*/
int main()
{
STANDARD stand;
LINEAR linear;
BeginPart(stand);
linear.InitializeSimplex(stand);
linear.Simplex();
linear.ShowANS();
}
void BeginPart(STANDARD & stand)
{
int i,j;
cout << "请首先将问题化为标准型(化为等式)";
cout << "请输入多少变量(为方程本身不包括松弛变量)" << endl;
cin >> stand.n;
cout << "请输入有多少方程" << endl;
cin >> stand.m;
cout << "请输入目标函数当前的常数值" << endl;
cin >> stand.v;
cout << "请输入目标函数(输入格式5 6 7,如果系数为0请输入0)" << endl;
for (i = 1; i <= stand.n + stand.m; i++)
{
cin >> stand.c[i];
}
cout << "请依行输入方程的系数(输入格式5 6 7,如果系数为0请输入0)" << endl;
for (i = 1; i <= stand.m; i++)
{
for (j = 1; j <= stand.n+stand.m; j++)
{
cin >> stand.A[i][j];
}
}
cout << "请输入方程的右端限制常数" << endl;
for (i = 1; i <= stand.m; i++)
{
cin >> stand.b[i];
}
}