Minimization of a simple quadratic function of two variables
Code: "func_minimaze2.py". Programming language: Python
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/func_minimaze2_2279.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from com.cureos.numerics import Cobyla,Calcfc
from java.lang import Math
Calcfc
nvar=2 # number of variables
nconst=0 # 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):
return 10.0 * Math.pow(x[0] + 1.0, 2.0) + Math.pow(x[1], 2.0);
x = [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()
You see the box below because you did not login.