Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add TypeScript definitions #98

Merged
merged 2 commits into from
Nov 6, 2019
Merged

WIP: Add TypeScript definitions #98

merged 2 commits into from
Nov 6, 2019

Conversation

CXuesong
Copy link
Contributor

@CXuesong CXuesong commented Nov 6, 2019

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.

* @example
* ```
* {
* x: { x1: 10, x2: 5, x3: 2, x: 1 } // x = 10 x1 + 5 x2 + 2 x3
Copy link
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
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
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 on lines +152 to +289

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: {
};
Copy link
Contributor Author

@CXuesong CXuesong Nov 6, 2019

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