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

Add integer_programming_avg.py #21

Merged
merged 5 commits into from
May 15, 2024

Conversation

8onlichtman
Copy link
Contributor

Integer_programming_avg.py produces a partition that minimizes the sum of the positive differences from the avg, by solving an integer linear program (ILP).

):
"""
Produce a partition that minimizes the sum of the positive differences from the avg, by solving an integer linear program (ILP).

Copy link
Collaborator

Choose a reason for hiding this comment

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

The description of the params in the function documentation does not match the actual params of the 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.

Fixed.

verbose=0,
solver_name=mip.CBC, # passed to MIP. See https://docs.python-mip.com/en/latest/quickstart.html#creating-models.
# solver_name = mip.GRB, # passed to MIP. See https://docs.python-mip.com/en/latest/quickstart.html#creating-models.
model_filename=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these two arguments used anywhere? If not, they should be removed.

Copy link
Contributor Author

@8onlichtman 8onlichtman May 5, 2024

Choose a reason for hiding this comment

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

fixed.



model.objective = mip.minimize(
0.5 * sum(t_js)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should it always be 0.5, regardless of the number of bins?

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.
sum(t_js) calculates double the difference that we want because it calculates the positive and negative sums (using the absolute value). so we need to devide that into 2.

@erelsgl erelsgl merged commit 3fea15e into coin-or:main May 15, 2024
4 checks 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.

2 participants