Skip to content

Add BasicIndexingPropagator#1

Closed
wbernoudy wants to merge 3 commits intoalexzucca90:dev/cpfrom
wbernoudy:dev/cp-static-basic-indexing-propagator
Closed

Add BasicIndexingPropagator#1
wbernoudy wants to merge 3 commits intoalexzucca90:dev/cpfrom
wbernoudy:dev/cp-static-basic-indexing-propagator

Conversation

@wbernoudy
Copy link
Copy Markdown

No description provided.

std::vector<Advisor> on_bounds;
std::vector<Advisor> on_array_size_change;

const dwave::optimization::ArrayNode* node_;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

public now, no need for trailing _


namespace dwave::optimization::cp {

struct BasicIndexingForwardTransform : IndexTransform {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Unless we need it public, we could move this within the implementation file, indexing_propagators.cpp

}
}

TEST_CASE("BasicIndexingPropagator") {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

To make things more organized, I moved the propagators tests within a subdir propagators/test_*.cpp, see #2 . We could do the same here.

Comment thread tests/cpp/cp/test_propagator.cpp Outdated

// build the advisor for the propagator p aimed to the variable for i
Advisor advisor_i(p, 0, std::make_unique<BasicIndexingForwardTransform>(i, b));
vars[0]->propagate_on_domain_change(std::move(advisor_i));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ok, here you added this advisor for the basic indexing propagator to the domain_change list of of advisors. Which sounds correct, cause you can infer holes in the domains from the indexing node. However, your propagator implementation is only bound consistent - probably because I only added intervals for now and not other type of sets - so we should

Suggested change
vars[0]->propagate_on_domain_change(std::move(advisor_i));
vars[0]->propagate_on_bounds_change(std::move(advisor_i));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Also, as you can see in this PR for binaryop and reduce propagators I started adding this logic inside the constructor of the propagator.

Comment thread tests/cpp/cp/test_propagator.cpp Outdated

// build the advisor for the propagator p aimed to the variable for b
Advisor advisor_b(p, 1, std::make_unique<ElementWiseTransform>());
vars[1]->propagate_on_domain_change(std::move(advisor_b));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Like above:

Suggested change
vars[1]->propagate_on_domain_change(std::move(advisor_b));
vars[1]->propagate_on_bounds_change(std::move(advisor_b));

CPVarsState& v_state) const {
auto data = data_ptr<PropagatorData>(p_state);

const BasicIndexingNode* bi = dynamic_cast<const BasicIndexingNode*>(array_->node_);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

If I understood things correctly, it should be

Suggested change
const BasicIndexingNode* bi = dynamic_cast<const BasicIndexingNode*>(array_->node_);
const BasicIndexingNode* bi = dynamic_cast<const BasicIndexingNode*>(basic_indexing_->node_);

otherwise the dynamic cast is gonna fail in general..

data->indices.to_process.pop_front();
data->indices.is_scheduled[bi_index] = false;

std::vector<ssize_t> in_multi_index =
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Maybe we can talk in person, but I'm getting confused with in and out here. Looks like your in is the output variable of the basic indexing node and and you out is the input of the basic indexing node.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point, clarified here dwavesystems@477046f

@wbernoudy wbernoudy force-pushed the dev/cp-static-basic-indexing-propagator branch from 7fa3ae3 to 092ede7 Compare April 2, 2026 17:26
@wbernoudy
Copy link
Copy Markdown
Author

Closing in favor of dwavesystems#501

@wbernoudy wbernoudy closed this Apr 9, 2026
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