This repository has been archived on 2026-05-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Operations-Research-Tool/src/pages/parseLP.ts
T
2024-09-19 10:54:04 +02:00

36 lines
755 B
TypeScript

type VariableLP = { name: string; coef: number };
type ConstraintLP = {
name: string;
vars: VariableLP[];
bnds: { ub: number; lb: number };
};
interface ProblemLP {
objective: {
vars: VariableLP[];
};
constraints: ConstraintLP[];
}
function createProblemLP(
objectiveVars: VariableLP[],
constraints: { name: string; vars: VariableLP[]; ub: number; lb: number }[]
): ProblemLP {
const constraintsFormatted: ConstraintLP[] = constraints.map((constraint) => ({
name: constraint.name,
vars: constraint.vars,
bnds: {
ub: constraint.ub,
lb: constraint.lb
}
}));
const problem: ProblemLP = {
objective: {
vars: objectiveVars
},
constraints: constraintsFormatted
};
return problem;
}