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

Create redundant_facet_removal_backup.py #81

Merged
merged 23 commits into from
Oct 11, 2023

Conversation

nitishmalang
Copy link
Contributor

@nitishmalang nitishmalang commented Oct 4, 2023

pull request

Comment on lines 436 to 438
model_iter = solve_lp_with_different_objectives(
model_iter, objective_function
)
Copy link
Member

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
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Comment on lines 472 to 474
model_iter = solve_lp_with_different_objectives(
model_iter, objective_function
)
Copy link
Member

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

@TolisChal
Copy link
Member

Thanks @nitishmalang! I'm ok with merging. Let's wait for a second review (@vissarion ?)

@nitishmalang
Copy link
Contributor Author

ok thanks

import math


def fast_fba(lb, ub, S, c):
Copy link
Member

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?

Copy link
Contributor Author

@nitishmalang nitishmalang left a 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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

@nitishmalang nitishmalang left a 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):
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor Author

@nitishmalang nitishmalang left a comment

Choose a reason for hiding this comment

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

.

Copy link
Member

@vissarion vissarion left a 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):
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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):
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ub_iter[i] = ub_iter[i] + 1

# Call solve_lp_with_different_objectives to solve LP
model_iter = solve_lp_with_different_objectives(
Copy link
Member

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.

Copy link
Member

@TolisChal TolisChal Oct 6, 2023

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,
Copy link
Member

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?

Copy link
Member

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):
Copy link
Member

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:
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Copy link
Member

@TolisChal TolisChal Oct 6, 2023

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done this

Comment on lines 15 to 24










Copy link
Member

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?

Copy link
Contributor Author

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,
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@nitishmalang nitishmalang left a 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)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok fixing this

Copy link
Contributor Author

@nitishmalang nitishmalang left a comment

Choose a reason for hiding this comment

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

.

Copy link
Contributor Author

@nitishmalang nitishmalang left a comment

Choose a reason for hiding this comment

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

updated

Copy link
Contributor Author

@nitishmalang nitishmalang left a 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

Copy link
Contributor Author

@nitishmalang nitishmalang left a comment

Choose a reason for hiding this comment

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

.

Copy link
Contributor Author

@nitishmalang nitishmalang left a comment

Choose a reason for hiding this comment

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

updated

@TolisChal TolisChal merged commit aaae4ae into GeomScale:develop Oct 11, 2023
1 check passed
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.

3 participants