-
Notifications
You must be signed in to change notification settings - Fork 28
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
Create redundant_facet_removal_backup.py #81
Create redundant_facet_removal_backup.py #81
Conversation
model_iter = solve_lp_with_different_objectives( | ||
model_iter, objective_function | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz change this to:
model_iter = solve_lp_with_different_objectives(
model_iter.copy(), objective_function
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
model_iter = solve_lp_with_different_objectives( | ||
model_iter, objective_function | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to the previous call
Thanks @nitishmalang! I'm ok with merging. Let's wait for a second review (@vissarion ?) |
ok thanks |
import math | ||
|
||
|
||
def fast_fba(lb, ub, S, c): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you plz remove fast_fba() and fast_fva() from this file since they are irrelevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
# Call solve_lp_with_different_objectives to solve LP | ||
model_iter = solve_lp_with_different_objectives( | ||
model_iter, objective_function_max |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be:
model_iter = solve_lp_with_different_objectives(
model_iter.copy(), objective_function_max
)
Plz change this wherever it has
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did it
|
||
|
||
|
||
def fast_inner_ball(A, b): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you plz also remove the function fast_inner_ball() from this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nitishmalang! I am in general OK with merging this code.
I have a few comments that could be integrated in the code. Please insert them as comments if you agree.
Also I propose to use a different name for the directory than backup
. Maybe experimental_gurobi_functions
and remove the term backup
from all file names. This is not a backup it is the opposite it is something new, but experimental, that is why we are not integrating directly into the codebase, but it has to be tested.
|
||
return model | ||
|
||
def fast_remove_redundant_facets(lb, ub, S, c, opt_percentage=100): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to replace fast_remove_redundant_facets
in https://github.com/GeomScale/dingo/blob/develop/dingo/gurobi_based_implementations.py#L312C4-L312C4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this one is to be replaced
|
||
|
||
|
||
def update_model(model, n, Aeq_sparse, beq, lb, ub, A_sparse, b, objective_function): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to replace update_model
in https://github.com/GeomScale/dingo/blob/develop/dingo/gurobi_based_implementations.py#L277
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is to be deleted. @nitishmalang could you plz delete this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @TolisChal
ub_iter[i] = ub_iter[i] + 1 | ||
|
||
# Call solve_lp_with_different_objectives to solve LP | ||
model_iter = solve_lp_with_different_objectives( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the main change here (and one call below) that replaces the update_model
and optimize()
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be used to change only the objective function of a model. So, this is to be used in the loop
for i in indices:
Inside this loop we have a certain set of constraints and we check for redundant facets.
import numpy as np | ||
import scipy.sparse as sp | ||
|
||
def update_model_constraints_and_bounds(model, Aeq_sparse=None, beq=None, A_sparse=None, b=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand the purpose of this function. Is this to be called by fast_remove_redundant_facets
or replace update_model
in certain cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is to be used in the loop:
while removed > 0 or offset > 0:
and before starting the loop:
for i in indices:
When we remove a facet the set of constraints changes, so we have to update the model (change the matrices A,Aeq,b,beq and the bounds). Then, we have to run for i in indices:
and go over all the active coordinates to check for new redundant facets.
|
||
|
||
|
||
def update_model(model, n, Aeq_sparse, beq, lb, ub, A_sparse, b, objective_function): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you plz delete this function since it is not needed here?
|
||
b_res = [] | ||
A_res = np.empty((0, n), float) | ||
for i in indices: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a line before for i in indices:
to update the model?
i.e.,
update_model_constraints_and_bounds(model_iter, Aeq_sparse, beq, A_sparse, [val], lb, ub)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved indeed? I think this is not implemented yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done this
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you plz delete all these empty lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
import numpy as np | ||
import scipy.sparse as sp | ||
|
||
def update_model_constraints_and_bounds(model, Aeq_sparse=None, beq=None, A_sparse=None, b=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you plz move this function into the file dingo/experimental_gurobi_functions/redundant_facet_removal_experiment.py
and delete this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @TolisChal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated @TolisChal
|
||
b_res = [] | ||
A_res = np.empty((0, n), float) | ||
update_model_constraints_and_bounds(model_iter, Aeq_sparse, beq, A_sparse, [val], lb, ub) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz fix the spaces in this line. That will give a runtime error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok fixing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation change is done
dingo/experimental_gurobi_functions/redundant_facet_removal_experiment.py
Outdated
Show resolved
Hide resolved
dingo/experimental_gurobi_functions/redundant_facet_removal_experiment.py
Outdated
Show resolved
Hide resolved
dingo/experimental_gurobi_functions/redundant_facet_removal_experiment.py
Show resolved
Hide resolved
dingo/experimental_gurobi_functions/redundant_facet_removal_experiment.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
pull request