Skip to content

Instantly share code, notes, and snippets.

@JesseLivezey
Last active March 31, 2016 16:20
Show Gist options
  • Save JesseLivezey/8ea2f2ddfb51057127275a0bdf7b8d48 to your computer and use it in GitHub Desktop.
Save JesseLivezey/8ea2f2ddfb51057127275a0bdf7b8d48 to your computer and use it in GitHub Desktop.
constraint 4 idea
#this is the constraint that makes Pyhy[i,i] > Pyhy[i,j]
def con4(inputArray):
Pyhy_i = inputArray.reshape(n,n)
# get diagonal vector (Pyhy[i,i])
Pyhy_diag = np.diag(Pyhy_i)
# get max of each row
Pyhy_max = Pyhy.max(axis=1)
# we want the difference to be positive or zero
diff = Pyhy_diag - Pyhy_max
# we want all of the differences to be positive, so we can just return the most negative one
worst_case = diff.min()
return worst_case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment