简单的单纯形法实现
# -*- coding: utf-8 -*-
# @File : 单纯形法.py
# @Time : 2021/3/27
# @Author : laipinyan
# 输入
def input_():
print('请输入目标函数:')
objective = input()
print('请输入约束条件:')
restrictions = input()
return objective, restrictions
# 获取系数
def get_nub(str_):
lis = [[], []] # [系数, b]
num = 0
symbol = 0 # 大小号
sign = 0 # 正负号
index = 0
n = 0
N = len(str_)
for i in str_:
n += 1
if i.isdigit():
num = 10 * num + int(i)
if n == N and index == 1:
if sign == 0:
lis[index].append(num)
else:
lis[index].append(num * sign)
elif i == 'x':
if sign == 0:
lis[index].append(num)
else:
lis[index].append(num * sign)
elif i == '+':