101 lines
4.0 KiB
Python
101 lines
4.0 KiB
Python
# ADDs: n_iter * n_p * 4 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 / (ceil(((double) (n_p - 7)) / 8))) * 7 * 14 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 - 1 / (ceil(((double) (n_p - 7)) / 8))) * 224 +
|
|
# n_iter * n_p * (n_p - floor((double) n_p / 8) * 8) * 14 +
|
|
# n_iter * n_p * board.n_obstacles * 12 +
|
|
# n_iter * n_p * 7
|
|
|
|
# MULTs: n_iter * n_p * 4 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 / (ceil(((double) (n_p - 7)) / 8))) * 7 * 24 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 - 1 / (ceil(((double) (n_p - 7)) / 8))) * 352 +
|
|
# n_iter * n_p * (n_p - floor((double) n_p / 8) * 8) * 24 +
|
|
# n_iter * n_p * board.n_obstacles * 19 +
|
|
# n_iter * n_p * 17
|
|
|
|
# DIVs: n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 / (ceil(((double) (n_p - 7)) / 8))) * 7 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 - 1 / (ceil(((double) (n_p - 7)) / 8))) * 8 +
|
|
# n_iter * n_p * (n_p - floor((double) n_p / 8) * 8) +
|
|
# n_iter * n_p * board.n_obstacles +
|
|
# n_iter * n_p * 2
|
|
|
|
# SQRTs: n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 / (ceil(((double) (n_p - 7)) / 8))) * 7 * 3 +
|
|
# n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 - 1 / (ceil(((double) (n_p - 7)) / 8))) * 24 +
|
|
# n_iter * n_p * (n_p - floor((double) n_p / 8) * 8) * 3 +
|
|
# n_iter * n_p * board.n_obstacles +
|
|
# n_iter * n_p * 3
|
|
|
|
# EXPs: n_iter * n_p * ceil(((double) (n_p - 7)) / 8) * (1 / (ceil(((double) (n_p - 7)) / 8))) * 7 +
|
|
# n_iter * n_p * (n_p - floor((double) n_p / 8) * 8) +
|
|
# n_iter * n_p * board.n_obstacles
|
|
|
|
from math import ceil
|
|
|
|
|
|
def adds(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
chunks = ceil((n_p - 7) / 8) if n_p > 7 else 0
|
|
remainder = n_p - int(n_p // 8) * 8
|
|
if chunks > 0:
|
|
term1 = n_iter * n_p * chunks * (1 / chunks) * 7 * 14
|
|
term2 = n_iter * n_p * chunks * (1 - 1 / chunks) * 224
|
|
else:
|
|
term1 = 0
|
|
term2 = 0
|
|
return int(n_iter * n_p * 4 + term1 + term2 + n_iter * n_p * remainder * 14 +
|
|
n_iter * n_p * n_obs * 12 + n_iter * n_p * 7)
|
|
|
|
|
|
def mults(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
chunks = ceil((n_p - 7) / 8) if n_p > 7 else 0
|
|
remainder = n_p - int(n_p // 8) * 8
|
|
if chunks > 0:
|
|
term1 = n_iter * n_p * chunks * (1 / chunks) * 7 * 24
|
|
term2 = n_iter * n_p * chunks * (1 - 1 / chunks) * 352
|
|
else:
|
|
term1 = 0
|
|
term2 = 0
|
|
return int(n_iter * n_p * 4 + term1 + term2 + n_iter * n_p * remainder * 24 +
|
|
n_iter * n_p * n_obs * 19 + n_iter * n_p * 17)
|
|
|
|
|
|
def divs(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
chunks = ceil((n_p - 7) / 8) if n_p > 7 else 0
|
|
remainder = n_p - int(n_p // 8) * 8
|
|
if chunks > 0:
|
|
term1 = n_iter * n_p * chunks * (1 / chunks) * 7
|
|
term2 = n_iter * n_p * chunks * (1 - 1 / chunks) * 8
|
|
else:
|
|
term1 = 0
|
|
term2 = 0
|
|
return int(n_iter * n_p * 4 + term1 + term2 + n_iter * n_p * remainder +
|
|
n_iter * n_p * n_obs + n_iter * n_p * 2)
|
|
|
|
|
|
def sqrts(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
chunks = ceil((n_p - 7) / 8) if n_p > 7 else 0
|
|
remainder = n_p - int(n_p // 8) * 8
|
|
if chunks > 0:
|
|
term1 = n_iter * n_p * chunks * (1 / chunks) * 7 * 3
|
|
term2 = n_iter * n_p * chunks * (1 - 1 / chunks) * 24
|
|
else:
|
|
term1 = 0
|
|
term2 = 0
|
|
return int(n_iter * n_p * 4 + term1 + term2 + n_iter * n_p * remainder * 3 +
|
|
n_iter * n_p * n_obs + n_iter * n_p * 3)
|
|
|
|
|
|
def exps(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
chunks = ceil((n_p - 7) / 8) if n_p > 7 else 0
|
|
remainder = n_p - int(n_p // 8) * 8
|
|
if chunks > 0:
|
|
term1 = n_iter * n_p * chunks * (1 / chunks) * 7
|
|
else:
|
|
term1 = 0
|
|
return int(n_iter * n_p * 4 + term1 + n_iter * n_p * remainder +
|
|
n_iter * n_p * n_obs + n_iter * n_p * 3)
|
|
|
|
|
|
def total(n_iter: int, n_p: int, n_obs: int = 2) -> int:
|
|
return adds(n_iter, n_p, n_obs) + mults(n_iter, n_p, n_obs) + divs(
|
|
n_iter, n_p, n_obs) + sqrts(n_iter, n_p,
|
|
n_obs) + exps(n_iter, n_p, n_obs) * 30
|