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

Embedding Formulation #73

Merged
merged 29 commits into from
Jun 18, 2018
Merged

Embedding Formulation #73

merged 29 commits into from
Jun 18, 2018

Conversation

jac0320
Copy link
Contributor

@jac0320 jac0320 commented Nov 22, 2017

@kaarthiksundar

File addition:

  • Added new file embedding.jl for handling formulation
  • separating out bin.jl

Data structure changes:

  • Added embedding, embedding_encode, embedding_ibs, embedding_link for options with embedding formulations

Algorithm changes and Function additions:

  • Add logs associated with embedding formulation
  • Let multi.jl fit with embedding formulations, i.e., divert from sos-2 formulation if embedding is true
  • Update function build_constr_block()
  • Introducing Binary Product MultiLinear (bpml) for more complex multilinear terms that ha binary variables in them
  • separating several term storage by using the modularized function
  • Some refactoring in operators.jl

Error schemes and default changes:

Test changes:

  • Added tests for bpml terms
  • Added tests for embedding
  • Cleaned up several test instances code

---------- OLD Comments -------------
@harshangrjn Please see this PR for some consideration on what should be left out.

This is the all the development for POD.jl on the embedding formulation side #64 .
It contains three main aspects,

  • Basic Embedding Formulation (Gray code Encoding)
  • Independent Branching Scheme for Compact Embedding
  • Binary Variable - Continuous Variable Bound restriction constraints reconstruction with embedding

The options introduced in this PR here are:

embedding::Bool -> Control the to use embedding formulation or not
embedding_encode::Any -> Direct which encoding will be used (compatibility will be checked)
embedding_ibs::Bool -> Whether to exploit the compactness of the formulation or not
embedding_link::Bool -> Add bound restriction constraints to regulate variable bounds based on active partition

Test cases are added to verify the encoding mapping and algorithm. Note that embedding formulation, regardless what additional options to choose, should yield the same results as SOS-2 formulation.

!!! This PR branch off #72.

@jac0320 jac0320 requested a review from harshangrjn November 22, 2017 19:05
@jac0320 jac0320 closed this Nov 22, 2017
@jac0320 jac0320 reopened this Nov 22, 2017
@codecov
Copy link

codecov bot commented Nov 22, 2017

Codecov Report

Merging #73 into master will increase coverage by 0.79%.
The diff coverage is 95.41%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #73      +/-   ##
========================================
+ Coverage   78.21%    79%   +0.79%     
========================================
  Files          27     28       +1     
  Lines        5696   5898     +202     
========================================
+ Hits         4455   4660     +205     
+ Misses       1241   1238       -3
Impacted Files Coverage Δ
src/POD.jl 100% <ø> (ø) ⬆️
src/utility.jl 78.46% <ø> (ø) ⬆️
src/algorithm.jl 85.55% <100%> (+0.16%) ⬆️
src/solver.jl 61.02% <100%> (+0.87%) ⬆️
src/log.jl 75.45% <100%> (+0.92%) ⬆️
test/algorithm.jl 100% <100%> (ø) ⬆️
test/solver.jl 100% <100%> (ø) ⬆️
src/multi.jl 74.77% <89.36%> (+6.02%) ⬆️
src/embedding.jl 92.94% <92.94%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 64539d9...a40620f. Read the comment docs.

@jac0320 jac0320 mentioned this pull request Nov 23, 2017
@jac0320 jac0320 closed this Feb 21, 2018
@jac0320 jac0320 reopened this Jun 11, 2018
@jac0320 jac0320 changed the title Embedding Formulation Embedding Formulation and Strengthening BPML terms Jun 11, 2018
@jac0320 jac0320 requested review from kaarthiksundar and removed request for harshangrjn June 11, 2018 21:58
@jac0320 jac0320 changed the title Embedding Formulation and Strengthening BPML terms Embedding Formulation Jun 14, 2018
embedding::Bool
embedding_encode::Any # Encoding method used for embedding
embedding_ibs::Bool # Enable independent branching scheme
embedding_link::Bool # Linking constraints between x and α, type 1 usse hierarchical and type 2 with big-m
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this embedding_link for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for an experiment to try out the alternative bounding constraints (y1b0+y1b1<=x<=y1b1+y2b2) when you have log # of binary variables.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this experiment successful - did it improve computation time and bounds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The short answer is: it can be good. The results are not consistent for two reasons: 1) in some cases, this can help, 2)the test scope is small. I suggest we keep the current code for later experiments.
For example, with the multiKND problem,
image
Another example with nlp3:
image

src/embedding.jl Outdated
return v
end

# # Version 1 implementation #
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you clean up the commented part - or may be remove it it we are not going to use it any more. Or if you dont want to remove it - make it as a function and add a comment saying old version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is taken care of in the most recent commit.

src/embedding.jl Outdated
@@ -0,0 +1,253 @@
# Make sure two things :: correct setup & compatible mapping function
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add a comment for each 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.

This is taken care of in the most recent commit.

src/multi.jl Outdated
@@ -170,8 +179,7 @@ function populate_convhull_extreme_values(m::PODNonlinearModel, discretization::
end

"""
TODO: docstring
method for general multilinear term
Extreme value for gneral multilinear terms Efficient implementation
Copy link
Collaborator

Choose a reason for hiding this comment

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

general

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is taken care of in the most recent commit.

src/multi.jl Outdated
@@ -197,7 +205,7 @@ function populate_convhull_extreme_values(m::PODNonlinearModel, discretization::
end

"""
Less memeory & time efficient, but a easier implementation
Less memeory & time efficiency, but a easier implementation
Copy link
Collaborator

Choose a reason for hiding this comment

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

memory*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is taken care of in the most recent commit.

src/multi.jl Outdated
@@ -197,7 +205,7 @@ function populate_convhull_extreme_values(m::PODNonlinearModel, discretization::
end

"""
Less memeory & time efficient, but a easier implementation
Less memeory & time efficiency, but a easier implementation
"""
function _populate_convhull_extreme_values(discretization::Dict, ml_indices::Any, λ::Dict, extreme_point_cnt::Int)
Copy link
Collaborator

Choose a reason for hiding this comment

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

make function names consistent why is there an underscore before the function name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function _populate_convhull_extreme_values() is not actively used. But it serves the purpose of verifying the populate_convhull_extreme_values() just in case the multi-dimensional scheme in Julia is different.

src/multi.jl Outdated
@@ -347,18 +381,16 @@ function valid_inequalities(m::PODNonlinearModel, discretization::Dict, λ::Dict
return
end

# Minimum Formulation with Boundary Cuts
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we still need this - let me discuss with harsha and russell and get back to you on this - for now have it

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. This is good for testing purposes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove this function with its solver options.

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. This is addressed in the most recent commit. Just a note, this option is removed in a later PR. We can do it here and I will rebase the other branches.

Copy link
Collaborator

@kaarthiksundar kaarthiksundar left a comment

Choose a reason for hiding this comment

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

Please address the comments and get back

Copy link
Collaborator

@kaarthiksundar kaarthiksundar left a comment

Choose a reason for hiding this comment

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

Please address the comments

Copy link
Collaborator

@kaarthiksundar kaarthiksundar left a comment

Choose a reason for hiding this comment

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

The one thing I am not completely satisfied about is the naming convention for the embedding options. I will try to come up with more meaningful names and we can do another update later.

@kaarthiksundar kaarthiksundar merged commit 9ff7bf1 into master Jun 18, 2018
@jac0320 jac0320 deleted the embedding branch June 18, 2018 19:18
@jac0320
Copy link
Contributor Author

jac0320 commented Jun 18, 2018

The "embedding" will be later refactored as "ebd". The rest of the string will be the same. This is the final stage of such options.
image

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