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EAAU,QAAQ,CACtB,QAAS,KAAK,UAEhB,IAAK,EAAQ,UAAW,MAAM,IAAI,MAAM,yBAMxC,MAAO,CACL,QAAS,EACT,SAPe,qBAAqB,CACpC,QAAS,EAAQ,aACjB,eAAgB,KAAK,eACrB,SAAU,KAAK,WAMnB","file":"/npm/simple-simplex@1.0.0/dist/lib/simple-simplex/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/simple-simplex@1.0.0/dist/lib/simple-simplex/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };\n\nconst mathjs = require('mathjs');\nconst simplex = require('./algorithms/simplex');\n\nconst {\n  mapVector: mapVector,\n  assertCoefficientParallelism: assertCoefficientParallelism,\n  generateTableauRow: generateTableauRow,\n  constraintToPreRow: constraintToPreRow,\n  extractNamedSolution: extractNamedSolution\n} = require('./simplex-helpers');\n\nmodule.exports = class SimpleSimplex {\n  constructor({\n    optimizationType: optimizationType,\n    objective: objective,\n    constraints: constraints\n  }) {\n    assertCoefficientParallelism({\n      objective: objective,\n      constraints: constraints\n    });\n    this.objective = objective;\n    this.constraints = constraints;\n    this.optimizationType = optimizationType;\n    this.numRows = constraints.length + 1;\n    const {\n      varNames: varNames,\n      indicesToNames: indicesToNames,\n      namesToIndices: namesToIndices,\n      vectorValues: vectorValues\n    } = mapVector(objective);\n    this.varNames = varNames;\n    this.indicesToNames = indicesToNames;\n    this.namesToIndices = namesToIndices;\n    this.objectiveVectorValues = vectorValues;\n    this.tableau = this.generateTableau();\n  }\n\n  generateTableau() {\n    if (this.optimizationType !== 'max') throw new Error('not a maximization problem');\n    const constraintPreRows = this.constraints.map(constraintToPreRow);\n    const constraintTableauRows = constraintPreRows.map((preRow, index) => generateTableauRow(_extends({}, preRow, {\n      rowNo: index,\n      numRows: this.numRows\n    })));\n    const objectiveTableauRow = generateTableauRow({\n      vectorValues: mathjs.multiply(this.objectiveVectorValues, -1),\n      rowNo: this.numRows - 1,\n      numRows: this.numRows\n    });\n    const tableau = [...constraintTableauRows, objectiveTableauRow];\n    return tableau;\n  }\n\n  solve({\n    methodName: methodName\n  }) {\n    if (methodName !== 'simplex') throw new Error('unrecognized algorithm name');\n    const details = simplex({\n      tableau: this.tableau\n    });\n    if (!details.isOptimal) throw new Error('solution not optimal!');\n    const solution = extractNamedSolution({\n      tableau: details.finalTableau,\n      indicesToNames: this.indicesToNames,\n      allNames: this.varNames\n    });\n    return {\n      details: details,\n      solution: solution\n    };\n  }\n};\n"]}