亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? penaltyconstrainedminimizer.java

?? Standord Classifier實現了一個基于Java的最大熵分類器。用于模式識別
?? JAVA
字號:
package edu.stanford.nlp.optimization;/** * A wrapper class which builds a constrained minimizer out of an * unconstrained one by finding the unconstrained minimum of a * sequence of penalized surfaces.  It assumes that the objective it * is given is a <code>DiffFunction</code>, even if the base * unconstrained minimzer just ignores the derivative information. * * The desired unconstrained minimizer is passed in on construction: * * <code>Minimizer m = new SomeUnconstrainedMinimizer();</code> * <code>ConstrainedMinimizer cm = new PenaltyConstrainedMinimizer(m);</code> * * @author <a href="mailto:klein@cs.stanford.edu">Dan Klein</a> * @version 1.0 * @since 1.0 * @see ConstrainedMinimizer */public class PenaltyConstrainedMinimizer implements ConstrainedMinimizer {  private Minimizer minimizer;  private boolean silent = true;  class PenalizedFunction implements DiffFunction {    DiffFunction function;    DiffFunction[] eqConstraints;    double[] eqLagrange;    double[] eqPenalties;    DiffFunction[] ineqConstraints;    double[] ineqLagrange;    double[] ineqPenalties;    public int domainDimension() {      return function.domainDimension();    }    public double valueAt(double[] x) {      double val = 0.0;      val += function.valueAt(x);      // equality constraints      for (int i=0; i<eqConstraints.length; i++) {	double c = eqConstraints[i].valueAt(x);	val += eqLagrange[i]*c;	val += 0.5*eqPenalties[i]*c*c;      }      // inequality constraints      for (int i=0; i<ineqConstraints.length; i++) {	double c = ineqConstraints[i].valueAt(x);	//val += Math.exp(-1.0*ineqPenalties[i]*c);	double tmp = fmax(c,2.0*c+ineqLagrange[i]/ineqPenalties[i]);	val += ineqLagrange[i]*tmp;	val += 0.5*ineqPenalties[i]*tmp*tmp;	//val += (tmp2*tmp2 - ineqLagrange[i]*ineqLagrange[i])/2.0*ineqPenalties[i];      }      return val;    }    public double[] derivativeAt(double[] x) {      double[] deriv = copyArray(function.derivativeAt(x));      // equality constraints      for (int i=0; i<eqConstraints.length; i++) {	double[] cDeriv = eqConstraints[i].derivativeAt(x);	double cVal = eqConstraints[i].valueAt(x);	for (int d=0; d<domainDimension(); d++) {	  deriv[d] += eqLagrange[i]*cDeriv[d];	  deriv[d] += eqPenalties[i]*cVal*cDeriv[d];	}      }      // inequality constraints      for (int i=0; i<ineqConstraints.length; i++) {	double[] cDeriv = ineqConstraints[i].derivativeAt(x);	double cVal = ineqConstraints[i].valueAt(x);	for (int d=0; d<domainDimension(); d++) {	  //deriv[d] += ineqLagrange[i]*cDeriv[d];	  //deriv[d] += -1.0*ineqPenalties[i]*Math.exp(-1.0*ineqPenalties[i]*cVal)*cDeriv[d];	  //deriv[d] += (cVal > 0 ? 0 : ineqPenalties[i]*cVal*cDeriv[d]);	  double tmp = cVal;	  double tmpD = cDeriv[d];	  double crit = cVal + ineqLagrange[i]/ineqPenalties[i];	  if (crit > 0) {	    tmp += crit;	    tmpD += cDeriv[d];	  }	  deriv[d] += ineqLagrange[i]*tmpD;	  deriv[d] += ineqPenalties[i]*tmp*tmpD;	}      }      return deriv;    }    PenalizedFunction(Function function, Function[] eqConstraints, double[] eqLagrange, double[] eqPenalties, Function[] ineqConstraints, double[] ineqLagrange, double[] ineqPenalties) {      this.function = (DiffFunction)function;      this.eqConstraints = (DiffFunction[])eqConstraints;      this.eqLagrange = eqLagrange;      this.eqPenalties = eqPenalties;      this.ineqConstraints = (DiffFunction[])ineqConstraints;      this.ineqLagrange = ineqLagrange;      this.ineqPenalties = ineqPenalties;    }  }  double[] copyArray(double[] a) {    double[] result = new double[a.length];    for(int i=0;i<a.length;i++)      result[i]=a[i];    return result;  }  private double arrayMax(double[] x) {    double max = Double.NEGATIVE_INFINITY;    for (int i=0; i<x.length; i++) {      if (max < x[i])	max = x[i];    }    return max;  }  private double fabs(double x) {    if (x<0)      return -1.0*x;    return x;  }  private double fmax(double x, double y) {    if (x<y)      return y;    return x;  }  private String arrayToString(double[] x) {    StringBuffer sb = new StringBuffer("(");    for (int j=0; j<x.length; j++) {      sb.append(x[j]);      if (j != x.length-1)	sb.append(", ");    }    sb.append(")");    return sb.toString();  }  public double[] minimize(Function function, double functionTolerance, Function[] eqConstraints, double eqConstraintTolerance, Function[] ineqConstraints, double ineqConstraintTolerance, double[] initial) {    int dimension = function.domainDimension();    int numEqConstraints = eqConstraints.length;    int numIneqConstraints = ineqConstraints.length;    // check that the function is a DiffFunction    if (! (function instanceof DiffFunction))      throw new UnsupportedOperationException();    // check the constraints    for (int i=0; i<numEqConstraints; i++) {      if (! (eqConstraints[i] instanceof DiffFunction))	throw new UnsupportedOperationException();    }    for (int i=0; i<numIneqConstraints; i++) {      if (! (ineqConstraints[i] instanceof DiffFunction))	throw new UnsupportedOperationException();    }    // use a penalty method to solve for the lagrange multipliers and the x    double[] eqLagrange = new double[numEqConstraints];    double[] eqPenalties = new double[numEqConstraints];    for (int i=0; i<numEqConstraints; i++) {      eqLagrange[i] = 0;      eqPenalties[i] = 1.0;    }    double[] ineqLagrange = new double[numIneqConstraints];    double[] ineqPenalties = new double[numIneqConstraints];    for (int i=0; i<numIneqConstraints; i++) {      ineqLagrange[i] = 0;      ineqPenalties[i] = 1.0;    }    double worstEqViolation = 1.0+2.0*eqConstraintTolerance;    double worstIneqViolation = 1.0+2.0*ineqConstraintTolerance;    double lastWorstEqViolation = 10*worstEqViolation;    double lastWorstIneqViolation = 10*worstIneqViolation;    int iter = 0;    double[] x = copyArray(initial);    // do a series of penalized minimizations    boolean lowTolIter = false;    while (iter < 100 && 	   (worstEqViolation > eqConstraintTolerance ||	    worstIneqViolation > ineqConstraintTolerance ||	    !lowTolIter)) {      if (worstEqViolation <= eqConstraintTolerance &&	  worstIneqViolation <= ineqConstraintTolerance) {	lowTolIter = true;      } else {	lowTolIter = false;      }      // build a penalized surface      DiffFunction penalizedFunction = new PenalizedFunction(function, eqConstraints, eqLagrange, eqPenalties, ineqConstraints, ineqLagrange, ineqPenalties);      // minimize it      double thisTol = (lowTolIter ? functionTolerance : Math.sqrt(functionTolerance));      x = minimizer.minimize(penalizedFunction, thisTol, x);      penalizedFunction.derivativeAt(x);      // update lagrange multipliers and penalties      // EQUALITY CONSTRAINTS      lastWorstEqViolation = worstEqViolation;      worstEqViolation = Double.NEGATIVE_INFINITY;      double[] eqViolations = new double[numEqConstraints];      double[] eqValues = new double[numEqConstraints];      for (int i=0; i<numEqConstraints; i++) {	eqValues[i] = eqConstraints[i].valueAt(x);	eqViolations[i] = fabs(eqValues[i]);      }      worstEqViolation = arrayMax(eqViolations);      // update penalties and lagrange multipliers      for (int i=0; i<numEqConstraints; i++) {	// lagrange multipliers should take over the forces previously	// exerted by the penalty terms	eqLagrange[i] += eqPenalties[i]*eqValues[i];	// penalties increase more or less based on violation severity	if (eqViolations[i] >= worstEqViolation/2.0 &&	    worstEqViolation >= eqConstraintTolerance)	  eqPenalties[i] *= 1.0;//*= 1.2;	else	  eqPenalties[i] *= 1.0;//*= 2.0;	// penalties also increase if constraint satisfaction is too slow	if (worstEqViolation / (lastWorstEqViolation + 1e-100) > 0.25 &&	    worstEqViolation >= eqConstraintTolerance)	  eqPenalties[i] *= 5.0;      }      if (! silent)	System.err.println("!e "+arrayMax(eqPenalties)+"/"+worstEqViolation+"!");      // INEQUALTIY CONSTRAINTS      lastWorstIneqViolation = worstIneqViolation;      worstIneqViolation = Double.NEGATIVE_INFINITY;      double[] ineqViolations = new double[numIneqConstraints];      double[] ineqValues = new double[numIneqConstraints];      for (int i=0; i<numIneqConstraints; i++) {	// ineq violations can be < 0 constraint values OR	//   >= 0 constraints with non-zero lagrange multipliers / penalties	double cVal = ineqConstraints[i].valueAt(x);	ineqValues[i] = cVal;	ineqViolations[i] = ((cVal < 0 ? -1.0*cVal : 0)+fabs(ineqLagrange[i]*cVal));      }      worstIneqViolation = fmax(0.0,arrayMax(ineqViolations));      // update penalties and lagrange multipliers      for (int i=0; i<numIneqConstraints; i++) {	// lagrange multipliers should take over the forces previously	// exerted by the penalty terms ... sort of	double crit =  ineqValues[i] + ineqLagrange[i]/ineqPenalties[i];	if (crit > 0)	  ineqLagrange[i] += ineqPenalties[i]*crit;	ineqLagrange[i] += ineqPenalties[i]*ineqValues[i];	if (ineqLagrange[i] > 0)	  ineqLagrange[i] = 0;	// penalties increase more or less based on violation severity	if (ineqViolations[i] >= worstIneqViolation/2.0 &&	    worstIneqViolation >= ineqConstraintTolerance)	  ineqPenalties[i] *= 1.0;//+= 0.2;	else	  ineqPenalties[i] *= 1.0;//+= 1.0;	// penalties also increase if constraint satisfaction is too slow	if (worstIneqViolation / (lastWorstIneqViolation + 1e-100) > 0.25 &&	    worstIneqViolation >= ineqConstraintTolerance)	  ineqPenalties[i] *= 5.0;      }      if (! silent)	System.err.println("!i "+arrayMax(ineqPenalties)+"/"+worstIneqViolation+"!");    }    return copyArray(x);  }  public double[] minimize(Function function, double functionTolerance, double[] initial) {    return minimizer.minimize(function, functionTolerance, initial);  }  public PenaltyConstrainedMinimizer(Minimizer minimizer) {    this.minimizer = minimizer;  }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆成人免费电影| 精品国产凹凸成av人网站| 久久久久97国产精华液好用吗| 一区二区三区国产精华| 99久免费精品视频在线观看| 久久久久久久综合色一本| 久久精品国产99国产精品| 精品视频在线看| 亚洲成人动漫一区| 在线观看视频一区二区| 综合久久久久久| 色综合一区二区三区| 亚洲精品你懂的| 在线免费av一区| 亚洲第一av色| 日韩欧美成人一区二区| 国产在线视频一区二区三区| 国产视频一区在线播放| 91看片淫黄大片一级在线观看| 亚洲女人小视频在线观看| 欧美手机在线视频| 久久草av在线| 国产精品久久久久永久免费观看| 91在线无精精品入口| 亚洲图片欧美色图| 久久综合色一综合色88| 99久久国产综合精品麻豆| 五月天中文字幕一区二区| 91精品国产综合久久精品性色| 国产黄色精品视频| 亚洲一区成人在线| 欧美videofree性高清杂交| 懂色av一区二区三区蜜臀| 一区二区三区资源| 久久精品一二三| 欧美人妖巨大在线| voyeur盗摄精品| 激情丁香综合五月| 伊人性伊人情综合网| 欧美xxxxx裸体时装秀| 99久久精品情趣| 国产成人综合亚洲网站| 日韩中文字幕不卡| 亚洲福中文字幕伊人影院| 2022国产精品视频| 777午夜精品视频在线播放| 成人黄色777网| 国产69精品久久久久毛片 | 国产一区在线看| 日韩电影免费在线看| 一级做a爱片久久| 亚洲人成影院在线观看| 久久精品一二三| 久久久www免费人成精品| 久久久久亚洲综合| 国产香蕉久久精品综合网| 日韩欧美卡一卡二| 日韩一区二区不卡| 日韩免费高清av| 久久综合九色综合97婷婷| 日韩欧美成人一区| 精品国产一二三区| 精品欧美一区二区久久| 国产视频一区在线播放| 国产精品久久久久影院亚瑟| 一区二区三区四区国产精品| 婷婷综合久久一区二区三区| 久久精品国产精品青草| 国内成人免费视频| 成人免费va视频| 欧美精品v国产精品v日韩精品| 欧美综合亚洲图片综合区| 欧美一区二区三区视频| 久久综合久久鬼色中文字| 中文字幕在线观看不卡| 亚洲一二三四久久| 国内精品写真在线观看| 97se亚洲国产综合自在线观| 这里是久久伊人| 久久综合色8888| 亚洲成人免费在线观看| 成人理论电影网| 欧美成人bangbros| 一区二区三区91| 成人激情文学综合网| 91精品国产欧美一区二区成人 | 欧美tk丨vk视频| 亚洲蜜桃精久久久久久久| 激情六月婷婷综合| 欧美性猛交xxxx乱大交退制版| 亚洲一区二区三区在线看| 国产成人免费xxxxxxxx| 69精品人人人人| 亚洲午夜av在线| 色av一区二区| 亚洲免费在线视频一区 二区| 国产老肥熟一区二区三区| 日韩免费一区二区三区在线播放| 亚洲另类在线制服丝袜| 成人免费视频播放| 国产精品毛片无遮挡高清| 国产中文字幕精品| 欧美成人性战久久| 日本视频中文字幕一区二区三区| 欧美亚洲一区二区在线| 亚洲欧美在线视频| 欧美性受xxxx| 亚洲五码中文字幕| 51久久夜色精品国产麻豆| 日韩精品1区2区3区| 日韩欧美在线网站| 久草在线在线精品观看| 日韩欧美在线不卡| 国产一区视频网站| 国产精品青草综合久久久久99| 成人动漫av在线| 亚洲一级不卡视频| 日韩欧美精品三级| 日本韩国欧美三级| 在线视频综合导航| 精品国产污网站| 一区二区欧美在线观看| 欧美日本免费一区二区三区| 美女性感视频久久| 亚洲日本一区二区三区| 欧美日韩国产精选| 国产成人在线色| 夜夜嗨av一区二区三区四季av| 91精品国产欧美一区二区成人| 国产成人精品影视| 亚洲一区二区视频| 中文无字幕一区二区三区| 欧美亚洲精品一区| 国产成人av一区二区| 日韩精品成人一区二区在线| 国产精品久久久久四虎| 亚洲精品一区二区三区在线观看 | 成人激情动漫在线观看| 日韩二区在线观看| 亚洲自拍偷拍网站| 成人欧美一区二区三区黑人麻豆| 91精品欧美久久久久久动漫 | 91网上在线视频| 激情文学综合插| 日本欧美肥老太交大片| 一区二区三区精品在线观看| 国产精品国产三级国产普通话99 | 91玉足脚交白嫩脚丫在线播放| 久久电影网电视剧免费观看| 日本伊人色综合网| 亚洲一区二区三区四区在线观看| 中文字幕一区二区三| 精品国产伦一区二区三区观看体验| 欧美日韩精品一区二区三区蜜桃| 91色在线porny| 欧美影视一区二区三区| 欧美性xxxxxxxx| 欧美日韩国产区一| 日韩三级视频在线观看| 91麻豆精品国产91久久久久久 | 欧美一级生活片| 日韩欧美国产一二三区| 精品国产乱码久久久久久1区2区| 精品入口麻豆88视频| 国产欧美日韩久久| 亚洲美女屁股眼交| 视频一区欧美精品| 国产精品1区2区3区| 99精品视频一区| 777奇米成人网| 国产婷婷色一区二区三区四区| 一区二区三区在线视频观看 | 高清在线观看日韩| 欧美性色欧美a在线播放| 精品国产精品网麻豆系列| 久久免费国产精品| 国产精品女同一区二区三区| 日韩高清一区在线| av电影一区二区| 日韩欧美电影一区| 一区二区三区欧美日| 成人视屏免费看| 日韩欧美在线1卡| 亚洲国产精品自拍| 9久草视频在线视频精品| 日韩欧美二区三区| 亚洲精品国产a| 国v精品久久久网| 欧美精品一区二区三区四区| 亚洲国产精品一区二区尤物区| 91视频观看视频| 国产精品色婷婷久久58| 国产一区二区伦理片| 在线电影院国产精品| 亚洲免费在线视频| 91免费观看视频| 亚洲欧美色一区| 久久亚洲影视婷婷| 秋霞午夜av一区二区三区| 欧日韩精品视频|