Skip to content

Commit

Permalink
Export Unary Encoding links #232
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed Jan 23, 2024
1 parent 695810d commit 179b202
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 11 additions & 0 deletions include/mp/flat/redef/MIP/converter_mip.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,18 @@ class MIPFlatConverter
/// A benefit would be if some solver later supports them natively
/// (IloDistribute?), now they are always converted below.
void CreateUnaryEncoding(int var, const SingleVarEqConstMap& map) {
// Create links from CondLinEQ's into the dummy UEnc
auto valnode = MPD( AddConstraint( UnaryEncodingConstraint{{var}} ) );
auto& ck = GET_CONSTRAINT_KEEPER(CondLinConEQ);
for (const auto& veq : map) {
MPD( GetMany2OneLink().AddEntry(
{ ck.SelectValueNodeRange(veq.second), valnode } ));
}
// Start AutoLinking from the dummy UEnc into its reformulation
pre::AutoLinkScope<Impl> auto_link_scope{
*(Impl*)this, valnode
};
// Create UEncoding
const Model& model = MP_DISPATCH( GetModel() );
if (!model.is_integer_var(var))
MP_RAISE("MP2MIP: Equality encoding: comparing non-integer variables not implemented");
Expand Down
1 change: 0 additions & 1 deletion include/mp/valcvt-link.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ class Many2ManyLink : public BasicLink {
/// Instead of a new entry, tries to extend the last one
/// if exists
void AddEntry(LinkEntry be) {
assert(be.first.IsSingleIndex());
if (entries_.empty() ||
!(
(entries_.back().first==be.first // same sources
Expand Down

0 comments on commit 179b202

Please sign in to comment.