22 lines
737 B
Python
22 lines
737 B
Python
import supply
|
|
import numpy as np
|
|
|
|
class MatrixBot(supply.Chain):
|
|
def __init__(self, hidden1, hidden2, initial):
|
|
a = np.matrix(hidden1).reshape(5,5)
|
|
b = np.matrix(hidden2).reshape(1,5)
|
|
self.mat = np.matmul(b, a)
|
|
super().__init__(initial)
|
|
def request(self):
|
|
x = [self.backlog, self.last_got, self.last_req, self.last_ship, self.supply]
|
|
out = np.matmul(self.mat, np.matrix(x).transpose())
|
|
n = out.tolist()[0][0]
|
|
if n < 0:
|
|
return 0
|
|
if n > 200:
|
|
return 200
|
|
return int(n)
|
|
|
|
if __name__ == "__main__":
|
|
m = MatrixBot(np.random.uniform(low=-3, high=3, size=25), np.random.uniform(low=-3, high=3, size=5), 12)
|
|
print(m.request())
|