Skip to content

Instantly share code, notes, and snippets.

def pulp_to_dual(lp):
# A x <= b
# 変数の数
n = len(lp.variables())
# 制約の数
m = 0
for constraint in lp.constraints.values():
import numpy as np
from simplex_method import SimplexMethod
class ReverseSearch:
def __init__(self, round_digit=5):
self.round_digit = round_digit
return
def solve(self, A, b, basis):
import numpy as np
from simplex_method import SimplexMethod
class PhaseOneSimplexMethod:
def __init__(self, round_digit=5):
self.round_digit = round_digit
return
def solve(self, A, b):
import numpy as np
class SimplexMethod:
OPTIMAL = 1
UNBOUNDED = -1
def __init__(self, round_digit=5):
self.round_digit = round_digit
return
import numpy as np
from matplotlib import pyplot as plt
# タイプ一覧(名称)
types_name = [
'normal',
'fire',
'water',
'electric',
'grass',
from itertools import product, combinations
import numpy as np
from numpy import linalg as la
def get_M_list(n):
M_list = [[]]
for _ in range(n):
M_list_ = []
for M in M_list:
cones = get_cones(n, M)
import numpy as np
import pulp
# 行列ゲーム
def solve_matrix_game(A):
n_type = len(A)
lp = pulp.LpProblem(sense=pulp.LpMaximize)
v = pulp.LpVariable("v")
x = [ pulp.LpVariable("x_"+str(i)) for i in range(n_type) ]
for j in range(n_type):
import numpy as np
import pulp
# タイプ一覧(名称)
types_name = [
'ノーマル',
'炎',
'水',
'電気',
'草',
import numpy as np
import pulp
# タイプ一覧(名称)
types_name = [
'ノーマル',
'炎',
'水',
'電気',
'草',
from itertools import product
import numpy as np
from numpy import linalg as la
def bruteforce(q, M):
n = len(q)
I = np.identity(n)