private void Initialize(OptBoundVariable[] variables) { this._OptVariable = null; this._OptBoundVariable = OptBoundVariable.GetClon(variables); this._ExternalVariables = new double[this._OptBoundVariable.Length]; this._ExternalGradientArray = new double[this._OptBoundVariable.Length]; this.CheckAndSetBounds(this._OptBoundVariable); int numFreeVariable = 0; for (int i = 0; i < this._OptBoundVariable.Length; i++) { this._ExternalVariables[i] = this._OptBoundVariable[i].InitialGuess; if (this._OptBoundVariable[i].Fixed == false) { numFreeVariable++; } } this._NumFreeVariables = numFreeVariable; this._FreeVariables = new double[numFreeVariable]; int index = 0; for (int i = 0; i < this._OptBoundVariable.Length; i++) { if (this._OptBoundVariable[i].Fixed == false) { this._FreeVariables[index] = this._OptBoundVariable[i].InitialGuess; index++; } } this._GradientArray = new double[numFreeVariable]; //c nmax is the dimension of the largest problem to be solved. //c mmax is the maximum number of limited memory corrections. int NMAX = this._NumFreeVariables; int MMAX = this.M; // c wa is a double precision working array of length // c (2mmax + 4)nmax + 12mmax^2 + 12mmax int WADimension = (2 * MMAX + 4) * NMAX + 12 * (MMAX * MMAX) + 12 * MMAX; this.WA = new double[WADimension]; this.IWA = new int[3 * NMAX]; }
private void Initialize(OptMultivariateFunction function, OptMultivariateGradient gradient, OptBoundVariable[] variables) { this.internalFunction = new SFUN(function, gradient, variables); this.MeOptVariable = null; this.MeOptBoundVariable = OptBoundVariable.GetClon(variables); this.CheckAndSetBounds(this.MeOptBoundVariable); this.MeExternalVariables = new double[this.MeOptBoundVariable.Length]; int numFreeVariable = 0; for (int i = 0; i < this.MeOptBoundVariable.Length; i++) { this.MeExternalVariables[i] = variables[i].InitialGuess; if (this.MeOptBoundVariable[i].Fixed == false) { numFreeVariable++; } } this.MeF = function(this.MeExternalVariables); this.MeNumFreeVariables = numFreeVariable; this.MeFreeVariables = new double[numFreeVariable]; this.MeGradientArray = new double[numFreeVariable]; int index = 0; for (int i = 0; i < this.MeOptBoundVariable.Length; i++) { if (this.MeOptBoundVariable[i].Fixed == false) { this.MeFreeVariables[index] = this.MeOptBoundVariable[i].InitialGuess; index++; } } //W - (REAL*8)(REAL*8) WORK VECTOR OF LENGTH AT LEAST 14*N //LW - (INTEGER) THE DECLARED DIMENSION OF W this.MeLW = 14 * this.MeNumFreeVariables; this.MeW = new double[this.MeLW]; this.MeMAXIT = Math.Max(1, this.MeNumFreeVariables / 2); }