You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found 2 methods to change a variable coefficient but both of them are problematic:
1- Using Expression.setVariable. The problem: the coefficient of the variable within the expression seems to be correctly updated but not within the tableau. Is it normal?
A simple example to illustrate the problem:
varsolver=newSimplexSolver();solver.autoSolve=false;varx=newVariable({name: 'x',value: 5});varmyExpression=newExpression(x,2);varmyConstraint1=newInequality(myExpression,GEQ,5);varmyConstraint2=newInequality(myExpression,LEQ,5);solver.addConstraint(myConstraint1);solver.addConstraint(myConstraint2);console.log(myExpression.toString());// 2*5myExpression.setVariable(x,1);console.log(myExpression.toString());// 1*5solver.resolve();// At this point x should be equal to 5 if the expression was correctly updatedconsole.log(x);// x = 2.5
2 - By removing and re-adding constraints. The problem: it gives really poor performance. e.g 2ms to remove and add back a single constraint on a 15 row by 10 columns tableau although it takes 0.05ms to solve it!.
Is there a more friendly and reliable way to cheaply do that coefficient change operation? (I tried to dive in the code but could not figure out what to do!)
Note: I am using cassowary to implement a complex responsive UI and I plan on implementing a branch and cut algorithm based on cassowary in order to solve problems that include integer variables. Therefore I am searching for an efficient way to dynamically change cut constraints.
The text was updated successfully, but these errors were encountered:
Unless I am misunderstanding the correlation here, I think what you are trying to accomplish will be addressed when the feature described in #66 lands. @slightlyoff is this correct?
I think #66 is only about changing the right hand side of a constraint. What I want is more general: I want to be able to change any variable coefficient in the objective function and in the constraints and the right hand side values of any constraint.
I think I might know how to do it (general case for the dynamic changes I listed above):
1 - Take the variable implied (if any) out of the base (pivot if necessary)
2 - Put the slack variable corresponding to the constraint involved (if any) in the base (pivot if necessary)
3 - Update the cell of the matrix that correspond to the variable and the constraint involved: the new value should be the previous value minus the difference between the new and previous coefficients.
4 - Solve
I am just not sure I want to spend time making those changes if the repo is not maintained.
Hello,
I found 2 methods to change a variable coefficient but both of them are problematic:
1- Using
Expression.setVariable
. The problem: the coefficient of the variable within the expression seems to be correctly updated but not within the tableau. Is it normal?A simple example to illustrate the problem:
2 - By removing and re-adding constraints. The problem: it gives really poor performance. e.g 2ms to remove and add back a single constraint on a 15 row by 10 columns tableau although it takes 0.05ms to solve it!.
Is there a more friendly and reliable way to cheaply do that coefficient change operation? (I tried to dive in the code but could not figure out what to do!)
Note: I am using cassowary to implement a complex responsive UI and I plan on implementing a branch and cut algorithm based on cassowary in order to solve problems that include integer variables. Therefore I am searching for an efficient way to dynamically change cut constraints.
The text was updated successfully, but these errors were encountered: