code: def runOptimiser(K, u, preOptw, initialValue, maxWeight=10000):
      """
      Args:
          K (double 2d array): Similarity/distance matrix
          u (double array): Mean similarity of each prototype
          preOptw (double): Weight vector
          initialValue (double): Initialize run
          maxWeight (double): Upper bound on weight
  
      Returns:
          Prototypes, weights and objective values
      """
      d = u.shape[0]
      lb = np.zeros((d, 1))
      ub = maxWeight * np.ones((d, 1))
      x0 = np.append(preOptw, initialValue / K[d - 1, d - 1])
  
      G = np.vstack((np.identity(d), -1 * np.identity(d)))
      h = np.vstack((ub, -1 * lb))
  
      (sol, obj_value) = solve_qp(
          K, -u, G, h, A=None, b=None, solver=None, initvals=x0
      )
      return (sol, obj_value)
  
file_path: explainx/lib/PDASH_utils.py
imports: from __future__ import print_function
  import numpy
  from sklearn.preprocessing import OneHotEncoder
  from cvxopt.solvers import qp
  from cvxopt import matrix, spmatrix
  from numpy import array, ndarray
  from scipy.spatial.distance import cdist
label_desc: Use image node_id 3 for calling a global function with example usage: runOptimiser(K, u, preOptw, initialValue, maxWeight) and returns: sol,  obj_value