Ultron/static/js/plugins/D3-dag/d3-dag.0.9.0.min.js

17 lines
85 KiB
JavaScript
Raw Normal View History

2022-01-12 14:39:15 +01:00
// d3-dag Version 0.9.0. Copyright 2021 Erik Brinkman.
var d3 = Object.assign(d3 || {}, (() => {
var d3=(()=>{var Mn=Object.create;var mt=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var Ie=t=>mt(t,"__esModule",{value:!0});var Oe=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_n=(t,e)=>{for(var r in e)mt(t,r,{get:e[r],enumerable:!0})},Me=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of En(e))!Sn.call(t,i)&&(r||i!=="default")&&mt(t,i,{get:()=>e[i],enumerable:!(n=Cn(e,i))||n.enumerable});return t},it=(t,e)=>Me(Ie(mt(t!=null?Mn(Bn(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),jn=(t=>(e,r)=>t&&t.get(e)||(r=Me(Ie({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Qt=P((ls,Le)=>{function Fe(t,e,r,n){this.feasible=r,this.evaluation=e,this.bounded=n,this._tableau=t}Le.exports=Fe;Fe.prototype.generateSolutionSet=function(){for(var t={},e=this._tableau,r=e.varIndexByRow,n=e.variablesPerIndex,i=e.matrix,s=e.rhsColumn,o=e.height-1,a=Math.round(1/e.precision),f=1;f<=o;f+=1){var l=r[f],u=n[l];if(!(u===void 0||u.isSlack===!0)){var c=i[f][s];t[u.id]=Math.round((Number.EPSILON+c)*a)/a}}return t}});var We=P((us,Ge)=>{var Ue=Qt();function jt(t,e,r,n,i){Ue.call(this,t,e,r,n),this.iter=i}Ge.exports=jt;jt.prototype=Object.create(Ue.prototype);jt.constructor=jt});var J=P((cs,Je)=>{var Wn=Qt(),Jn=We();function H(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}Je.exports=H;H.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()};function te(t,e){this.priority=t,this.reducedCosts=new Array(e);for(var r=0;r<e;r+=1)this.reducedCosts[r]=0}te.prototype.copy=function(){var t=new te(this.priority,this.reducedCosts.length);return t.reducedCosts=this.reducedCosts.slice(),t};H.prototype.setOptionalObjective=function(t,e,r){var n=this.objectivesByPriority[t];if(n===void 0){var i=Math.max(this.width,e+1);n=new te(t,i),this.objectivesByPriority[t]=n,this.optionalObjectives.push(n),this.optionalObjectives.sort(function(s,o){return s.priority-o.priority})}n.reducedCosts[e]=r};H.prototype.initialize=function(t,e,r,n){this.variables=r,this.unrestrictedVars=n,this.width=t,this.height=e;for(var i=new Array(t),s=0;s<t;s++)i[s]=0;this.matrix=new Array(e);for(var o=0;o<e;o++)this.matrix[o]=i.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};H.prototype._resetMatrix=function(){var t=this.model.variables,e=this.model.constraints,r=t.length,n=e.length,i,s,o=this.matrix[0],a=this.model.isMinimization===!0?-1:1;for(i=0;i<r;i+=1){var f=t[i],l=f.priority,u=a*f.cost;l===0?o[i+1]=u:this.setOptionalObjective(l,i+1,u),s=t[i].index,this.rowByVarIndex[s]=-1,this.colByVarIndex[s]=i+1,this.varIndexByCol[i+1]=s}for(var c=1,d=0;d<n;d+=1){var v=e[d],g=v.index;this.rowByVarIndex[g]=c,this.colByVarIndex[g]=-1,this.varIndexByRow[c]=g;var h,O,x,m=v.terms,b=m.length,I=this.matrix[c++];if(v.isUpperBound){for(h=0;h<b;h+=1)O=m[h],x=this.colByVarIndex[O.variabl
`));for(var c=0;c<t.length;c++)if(l="__"+c,i=t[c],s=0,o=null,e.is_objective.test(i))r.opType=i.match(/(max|min)/gi)[0],o=i.match(e.parse_lhs).map(function(g){return g.replace(/\s+/,"")}).slice(1),o.forEach(function(g){a=g.match(e.get_num),a===null?g.substr(0,1)==="-"?a=-1:a=1:a=a[0],a=parseFloat(a),f=g.match(e.get_word)[0].replace(/\;$/,""),r.variables[f]=r.variables[f]||{},r.variables[f]._obj=a});else if(e.is_int.test(i))o=i.match(e.parse_int).slice(1),r.ints=r.ints||{},o.forEach(function(g){g=g.replace(";",""),r.ints[g]=1});else if(e.is_bin.test(i))o=i.match(e.parse_bin).slice(1),r.binaries=r.binaries||{},o.forEach(function(g){g=g.replace(";",""),r.binaries[g]=1});else if(e.is_constraint.test(i)){var d=i.indexOf(":"),v=d===-1?i:i.slice(d+1);o=v.match(e.parse_lhs).map(function(g){return g.replace(/\s+/,"")}),o.forEach(function(g){a=g.match(e.get_num),a===null?g.substr(0,1)==="-"?a=-1:a=1:a=a[0],a=parseFloat(a),f=g.match(e.get_word)[0],r.variables[f]=r.variables[f]||{},r.variables[f][l]=a}),u=parseFloat(i.match(e.parse_rhs)[0]),i=n[i.match(e.parse_dir)[0]],r.constraints[l]=r.constraints[l]||{},r.constraints[l][i]=u}else e.is_unrestricted.test(i)&&(o=i.match(e.parse_int).slice(1),r.unrestricted=r.unrestricted||{},o.forEach(function(g){g=g.replace(";",""),r.unrestricted[g]=1}));return r}function ti(t){if(!t)throw new Error("Solver requires a model to operate on");var e="",r=[],n=1,i={max:"<=",min:">=",equal:"="},s=new RegExp("[^A-Za-z0-9_[{}/.&#$%~'@^]","gi");if(t.opType){e+=t.opType+":";for(var o in t.variables)t.variables[o][o]=t.variables[o][o]?t.variables[o][o]:1,t.variables[o][t.optimize]&&(e+=" "+t.variables[o][t.optimize]+" "+o.replace(s,"_"))}else e+="max:";e+=`;
`;for(var a in t.constraints)for(var f in t.constraints[a])if(typeof i[f]!="undefined"){for(var l in t.variables)typeof t.variables[l][a]!="undefined"&&(e+=" "+t.variables[l][a]+" "+l.replace(s,"_"));e+=" "+i[f]+" "+t.constraints[a][f],e+=`;
`}if(t.ints){e+=`
`;for(var u in t.ints)e+="int "+u.replace(s,"_")+`;
`}if(t.unrestricted){e+=`
`;for(var c in t.unrestricted)e+="unrestricted "+c.replace(s,"_")+`;
`}return e}gr.exports=function(t){return t.length?Qn(t):ti(t)}});var xr=P(fe=>{fe.reformat=qt();function mr(t){return t=t.replace("\\r\\n",`\r
`),t=t.split(`\r
`),t=t.filter(function(e){var r;return r=new RegExp(" 0$","gi"),!(r.test(e)===!0||(r=new RegExp("\\d$","gi"),r.test(e)===!1))}).map(function(e){return e.split(/\:{0,1} +(?=\d)/)}).reduce(function(e,r,n){return e[r[0]]=r[1],e},{}),t}fe.solve=function(t){return new Promise(function(e,r){typeof window!="undefined"&&r("Function Not Available in Browser");var n=qt()(t);t.external||r("Data for this function must be contained in the 'external' attribute. Not seeing anything there."),t.external.binPath||r("No Executable | Binary path provided in arguments as 'binPath'"),t.external.args||r("No arguments array for cli | bash provided on 'args' attribute"),t.external.tempName||r("No 'tempName' given. This is necessary to produce a staging file for the solver to operate on");var i=Oe("fs");i.writeFile(t.external.tempName,n,function(s,o){if(s)r(s);else{var a=Oe("child_process").execFile;t.external.args.push(t.external.tempName),a(t.external.binPath,t.external.args,function(f,l){if(f)if(f.code===1)e(mr(l));else{var u={"-2":"Out of Memory","1":"SUBOPTIMAL","2":"INFEASIBLE","3":"UNBOUNDED","4":"DEGENERATE","5":"NUMFAILURE","6":"USER-ABORT","7":"TIMEOUT","9":"PRESOLVED","25":"ACCURACY ERROR","255":"FILE-ERROR"},c={code:f.code,meaning:u[f.code],data:l};r(c)}else e(mr(l))})}})})}});var yr=P((Ps,br)=>{br.exports={lpsolve:xr()}});var le=P((Ts,wr)=>{wr.exports=function(t,e){var r=e.optimize,n=JSON.parse(JSON.stringify(e.optimize)),i=Object.keys(e.optimize),s,o=0,a={},f="",l={},u=[],c,d,v,g,h;for(delete e.optimize,c=0;c<i.length;c++)n[i[c]]=0;for(c=0;c<i.length;c++){e.optimize=i[c],e.opType=r[i[c]],s=t.Solve(e,void 0,void 0,!0);for(g in i)if(!e.variables[i[g]]){s[i[g]]=s[i[g]]?s[i[g]]:0;for(v in e.variables)e.variables[v][i[g]]&&s[v]&&(s[i[g]]+=s[v]*e.variables[v][i[g]])}for(f="base",d=0;d<i.length;d++)s[i[d]]?f+="-"+(s[i[d]]*1e3|0)/1e3:f+="-0";if(!a[f]){for(a[f]=1,o++,d=0;d<i.length;d++)s[i[d]]&&(n[i[d]]+=s[i[d]]);delete s.feasible,delete s.result,u.push(s)}}for(c=0;c<i.length;c++)e.constraints[i[c]]={equal:n[i[c]]/o};e.optimize="cheater-"+Math.random(),e.opType="max";for(c in e.variables)e.variables[c].cheater=1;for(c in u)for(v in u[c])l[v]=l[v]||{min:1e99,max:-1e99};for(c in l)for(v in u)u[v][c]?(u[v][c]>l[c].max&&(l[c].max=u[v][c]),u[v][c]<l[c].min&&(l[c].min=u[v][c])):(u[v][c]=0,l[c].min=0);return s=t.Solve(e,void 0,void 0,!0),{midpoint:s,vertices:u,ranges:l}}});var pt=P((Rs,Or)=>{var ei=fr(),ue=dr(),ri=ae(),Pt=zt(),Ir=vr(),ni=Pt.Constraint,ii=Pt.Variable,si=Pt.Numeral,oi=Pt.Term,Tt=yr(),Rt=function(){"use strict";this.Model=ue,this.branchAndCut=ri,this.Constraint=ni,this.Variable=ii,this.Numeral=si,this.Term=oi,this.Tableau=ei,this.lastSolvedModel=null,this.External=Tt,this.Solve=function(t,e,r,n){if(n)for(var i in Ir)t=Ir[i](t);if(!t)throw new Error("Solver requires a model to operate on");if(typeof t.optimize=="object"&&Object.keys(t.optimize>1))return le()(this,t);if(t.external){var s=Object.keys(Tt);if(s=JSON.stringify(s),!t.external.solver)throw new Error("The model you provided has an 'external' object that doesn't have a solver attribute. Use one of the following:"+s);if(!Tt[t.external.solver])throw new Error("No support (yet) for "+t.external.solver+". Please use one of these instead:"+s);return Tt[t.external.solver].solve(t)}else{t instanceof ue||(t=new ue(e).loadJson(t));var o=t.solve();if(this.lastSolvedModel=t,o.solutionSet=o.generateSolutionSet(),r)return o;var a={};return a.feasible=o.feasible,a.result=o.evaluation,a.bounded=o.bounded,o._tableau.__isIntegral&&(a.isIntegral=!0),Object.keys(o.solutionSet).forEach(function(f){o.solutionSet[f]!==0&&(a[f]=o.solutionSet[f])}),a}},this.ReformatLP=qt(),this.MultiObjective=function(t){return le()(this,t)}};typeof define=="function"?define([],function(){return new Rt}):typeof window=="object"?window.solver=new Rt:typeof self=="object"&&(self.solver=new Rt);Or.exports=new Rt});var _r=P((Fs,Sr)=>{"use strict";var vt=1e-60,Er,Br;do vt+=vt,Er=1+.1*vt,Br=1+.2*vt;while(Er<=1||Br<=1);Sr.exports=vt});var zr=P((Ls,jr)=>{"use strict";function li(t,e,r){let n,i;for(let s=1;s<=r;s+=1){t[s][s]=
return d3; })())