phantasmal-world/9.a09c9b2e8e67bf469efc.js

1 line
100 KiB
JavaScript
Raw Normal View History

2020-01-29 20:34:43 +08:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{483:function(t,e,n){var i=n(691),r=n(793);function s(t){this.model=null,this.matrix=null,this.width=0,this.height=0,this.costRowIndex=0,this.rhsColumn=0,this.variablesPerIndex=[],this.unrestrictedVars=null,this.feasible=!0,this.evaluation=0,this.simplexIters=0,this.varIndexByRow=null,this.varIndexByCol=null,this.rowByVarIndex=null,this.colByVarIndex=null,this.precision=t||1e-8,this.optionalObjectives=[],this.objectivesByPriority={},this.savedState=null,this.availableIndexes=[],this.lastElementIndex=0,this.variables=null,this.nVars=0,this.bounded=!0,this.unboundedVarIndex=null,this.branchAndCutIterations=0}function a(t,e){this.priority=t,this.reducedCosts=new Array(e);for(var n=0;n<e;n+=1)this.reducedCosts[n]=0}t.exports=s,s.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()},a.prototype.copy=function(){var t=new a(this.priority,this.reducedCosts.length);return t.reducedCosts=this.reducedCosts.slice(),t},s.prototype.setOptionalObjective=function(t,e,n){var i=this.objectivesByPriority[t];void 0===i&&(i=new a(t,Math.max(this.width,e+1)),this.objectivesByPriority[t]=i,this.optionalObjectives.push(i),this.optionalObjectives.sort((function(t,e){return t.priority-e.priority})));i.reducedCosts[e]=n},s.prototype.initialize=function(t,e,n,i){this.variables=n,this.unrestrictedVars=i,this.width=t,this.height=e;for(var r=new Array(t),s=0;s<t;s++)r[s]=0;this.matrix=new Array(e);for(var a=0;a<e;a++)this.matrix[a]=r.slice();this.varIndexByRow=new Array(this.height),this.varIndexByCol=new Array(this.width),this.varIndexByRow[0]=-1,this.varIndexByCol[0]=-1,this.nVars=t+e-2,this.rowByVarIndex=new Array(this.nVars),this.colByVarIndex=new Array(this.nVars),this.lastElementIndex=this.nVars},s.prototype._resetMatrix=function(){var t,e,n=this.model.variables,i=this.model.constraints,r=n.length,s=i.length,a=this.matrix[0],o=!0===this.model.isMinimization?-1:1;for(t=0;t<r;t+=1){var u=n[t],l=u.priority,h=o*u.cost;0===l?a[t+1]=h:this.setOptionalObjective(l,t+1,h),e=n[t].index,this.rowByVarIndex[e]=-1,this.colByVarIndex[e]=t+1,this.varIndexByCol[t+1]=e}for(var c=1,d=0;d<s;d+=1){var f,m,v=i[d],y=v.index;this.rowByVarIndex[y]=c,this.colByVarIndex[y]=-1,this.varIndexByRow[c]=y;var p=v.terms,g=p.length,b=this.matrix[c++];if(v.isUpperBound){for(f=0;f<g;f+=1)m=p[f],b[this.colByVarIndex[m.variable.index]]=m.coefficient;b[0]=v.rhs}else{for(f=0;f<g;f+=1)m=p[f],b[this.colByVarIndex[m.variable.index]]=-m.coefficient;b[0]=-v.rhs}}},s.prototype.setModel=function(t){this.model=t;var e=t.nVariables+1,n=t.nConstraints+1;return this.initialize(e,n,t.variables,t.unrestrictedVariables),this._resetMatrix(),this},s.prototype.getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t},s.prototype.density=function(){for(var t=0,e=this.matrix,n=0;n<this.height;n++)for(var i=e[n],r=0;r<this.width;r++)0!==i[r]&&(t+=1);return t/(this.height*this.width)},s.prototype.setEvaluation=function(){var t=Math.round(1/this.precision),e=this.matrix[this.costRowIndex][this.rhsColumn],n=Math.round((Number.EPSILON+e)*t)/t;this.evaluation=n,0===this.simplexIters&&(this.bestPossibleEval=n)},s.prototype.getSolution=function(){var t=!0===this.model.isMinimization?this.evaluation:-this.evaluation;return this.model.getNumberOfIntegerVariables()>0?new r(this,t,this.feasible,this.bounded,this.branchAndCutIterations):new i(this,t,this.feasible,this.bounded)}},528:function(t,e,n){"use strict";function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function r(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}funct