Created
December 28, 2018 09:02
-
-
Save eponkratova/0960017e7eebdf3a65989e71f7046d80 to your computer and use it in GitHub Desktop.
initiating_gis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __constraints(self, x, unit): | |
""" | |
Constraints for optimization for one unit | |
:param x: combined weights | |
:param unit: which production unit to compute | |
:return: array of constraints | |
""" | |
in_w, out_w, lambdas = x[:self.m], x[self.m:(self.m+self.r)], x[(self.m+self.r):] # unroll the weights | |
constr = [] # init the constraint array | |
# for each input, lambdas with inputs | |
for input in self.input_: | |
t = self.__target(x, unit) | |
lhs = np.dot(self.inputs[:, input], lambdas) | |
cons = t*self.inputs[unit, input] - lhs | |
constr.append(cons) | |
# for each output, lambdas with outputs | |
for output in self.output_: | |
lhs = np.dot(self.outputs[:, output], lambdas) | |
cons = lhs - self.outputs[unit, output] | |
constr.append(cons) | |
# for each unit | |
for u in self.unit_: | |
constr.append(lambdas[u]) | |
return np.array(constr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment