Skip to content

WIP: Add TypeScript definitions#98

Merged
JWally merged 2 commits into
JWally:masterfrom
CXuesong:typedef
Nov 6, 2019
Merged

WIP: Add TypeScript definitions#98
JWally merged 2 commits into
JWally:masterfrom
CXuesong:typedef

Conversation

@CXuesong

@CXuesong CXuesong commented Nov 6, 2019

Copy link
Copy Markdown
Contributor

Resolves #95

  • Add members used to solve single objective LP/MILP problem.
  • Add members used to solve multi-objective optimization problem.
  • Add other sub-modules (or namespaces), if they are intended to be exported and publicized.

I still have some questions and will post them as comments below.

Comment thread types/main.d.ts
* @example
* ```
* {
* x: { x1: 10, x2: 5, x3: 2, x: 1 } // x = 10 x1 + 5 x2 + 2 x3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the x: 1 here mandatory? What will happen if I use something like

{
    x: { x1: 10, x2: 5 },
// -- OR --
    x: { x1: 10, x2: 5, x: 10 },
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, been out to lunch on this one.

the x: 1 isn't necessary, but I like to include it.

For me, its helpful; since it lets me easily put a constraint on the variable itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. What if user input something like x: 10 instead? Is this case invalid? If so, I may need to add more type constraint on this...

Comment thread types/main.d.ts
Comment on lines +152 to +289
export class Constraint {
constructor(rhs: any, isUpperBound: any, index: any, model: any);

addTerm(coefficient: any, variable: any): any;

relax(weight: any, priority: any): void;

removeTerm(term: any): any;

setRightHandSide(newRhs: any): any;

setVariableCoefficient(newCoefficient: any, variable: any): any;
}

export class Model {
constructor(precision: any, name: any);

activateMIRCuts(useMIRCuts: any): void;

addVariable(cost: any, id: any, isInteger: any, isUnrestricted: any, priority: any): any;

debug(debugCheckForCycles: any): void;

equal(rhs: any): any;

getNumberOfIntegerVariables(): any;

greaterThan(rhs: any): any;

isFeasible(): any;

loadJson(jsonModel: any): any;

log(message: any): any;

maximize(): any;

minimize(): any;

removeConstraint(constraint: any): any;

removeVariable(variable: any): any;

restore(): any;

save(): any;

setCost(cost: any, variable: any): any;

smallerThan(rhs: any): any;

solve(): any;

updateConstraintCoefficient(constraint: any, variable: any, difference: any): any;

updateRightHandSide(constraint: any, difference: any): any;
}

export class Tableau {
constructor(precision: any);

addConstraint(constraint: any): void;

addCutConstraints(cutConstraints: any): void;

addVariable(variable: any): void;

applyCuts(branchingCuts: any): void;

applyMIRCuts(): void;

branchAndCut(): void;

checkForCycles(varIndexes: any): any;

computeFractionalVolume(ignoreIntegerValues: any): any;

copy(): any;

countIntegerValues(): any;

density(): any;

getFractionalVarWithLowestCost(): any;

getMostFractionalVar(): any;

getNewElementIndex(): any;

getSolution(): any;

initialize(width: any, height: any, variables: any, unrestrictedVars: any): void;

isIntegral(): any;

log(message: any, force: any): any;

phase1(): any;

phase2(): any;

pivot(pivotRowIndex: any, pivotColumnIndex: any): void;

removeConstraint(constraint: any): void;

removeVariable(variable: any): void;

restore(): void;

save(): void;

setEvaluation(): void;

setModel(model: any): any;

setOptionalObjective(priority: any, column: any, cost: any): any;

simplex(): any;

solve(): any;

updateConstraintCoefficient(constraint: any, variable: any, difference: any): void;

updateCost(variable: any, difference: any): void;

updateRightHandSide(constraint: any, difference: any): void;

updateVariableValues(): void;

}

export const External: {
};

export const Numeral: any;

export const branchAndCut: {
};

@CXuesong CXuesong Nov 6, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like exported modules from main.js. Are they all intended to be used by the outside world?

jsLPSolver/src/main.js

Lines 36 to 43 in 18942b7

this.Model = Model;
this.branchAndCut = branchAndCut;
this.Constraint = Constraint;
this.Variable = Variable;
this.Numeral = Numeral;
this.Term = Term;
this.Tableau = Tableau;
this.lastSolvedModel = null;

@JWally JWally merged commit 6cc50e1 into JWally:master Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript defintions

2 participants