
from com.cureos.numerics import Cobyla,Calcfc
from java.lang import Math

nvar=3         # number of variables
nconst=1       # number of constraints
rhobeg=0.5     # Initial size of the simplex 
rhoend=1.0e-10 # Final value of the simplex 
iprint = 0     # no output to Std.Out
maxfun = 5000  # Maximum number of function evaluations before terminating 
     
class calFun(Calcfc):           
  def Compute(self, n, m, x, con):
      con[0] = 1.0 - x[0] * x[0] - 2.0 * x[1] * x[1] - 3.0 * x[2] * x[2];
      return x[0] * x[1] * x[2];

x = [1.0, 1.0, 1.0]  # initial values of the variables
cc=Cobyla()
result=cc.FindMinimum(calFun(), nvar, nconst, x, rhobeg, rhoend, iprint, maxfun); 
print  cc.getOutput().tolist()
