def argmin_except_c(x,p,c):
  """
  argmin_except_c(x,p,c)

  Ensure that p is the argmin, i.e. the position of the minimum value
  in x, but ignores any value of c.
  
  Note:
  - If there are many minimum values then argmin_except_c(x,p,c) will find
    all these values.
  - We assume that there are at least one value != c.
  """
  n = len(x)
  constraints = [x[p] != c]  
  for i in range(n):
    constraints += [(p != i).implies((x[i] == c) | (x[p] < x[i])) ]
    
  return constraints