Skip to content

feat: enable Basic var and List var to coexist for the construction heuristic#1593

Merged
triceo merged 14 commits into
TimefoldAI:mainfrom
zepfred:feat/multi-var
May 21, 2025
Merged

feat: enable Basic var and List var to coexist for the construction heuristic#1593
triceo merged 14 commits into
TimefoldAI:mainfrom
zepfred:feat/multi-var

Conversation

@zepfred

@zepfred zepfred commented May 15, 2025

Copy link
Copy Markdown
Contributor

This PR allows for the construction of an initial solution using both basic and list variables within the same model. The proposal does not introduce any new configurations for the construction heuristic; rather, it modifies the entity placer definition to accept a list instead of just a single element.

There are some limitations concerning the definition of the entity placer. Therefore, the current behavior for a single placer configuration will remain unchanged. However, a new option has been added to define a placer for values (list variable) and a placer for entities (basic variable).

  <constructionHeuristic>
    <!-- List Variable -->
    <queuedValuePlacer>
      <valueSelector id="placerValueSelector">
        <cacheType>PHASE</cacheType>
        <selectionOrder>SORTED</selectionOrder>
        <sorterManner>INCREASING_STRENGTH</sorterManner>
      </valueSelector>
      <changeMoveSelector>
        <entitySelector>
          <cacheType>PHASE</cacheType>
          <selectionOrder>SORTED</selectionOrder>
          <sorterManner>DECREASING_DIFFICULTY</sorterManner>
        </entitySelector>
        <valueSelector mimicSelectorRef="placerValueSelector"/>
      </changeMoveSelector>
    </queuedValuePlacer>
    <!-- Basic Variable -->
    <queuedEntityPlacer>
      <entitySelector id="placerEntitySelector">
        <cacheType>PHASE</cacheType>
        <selectionOrder>SORTED</selectionOrder>
        <sorterManner>DECREASING_DIFFICULTY</sorterManner>
      </entitySelector>
      <changeMoveSelector>
        <entitySelector mimicSelectorRef="placerEntitySelector"/>
        <valueSelector>
          <cacheType>PHASE</cacheType>
          <selectionOrder>SORTED</selectionOrder>
          <sorterManner>INCREASING_STRENGTH</sorterManner>
        </valueSelector>
      </changeMoveSelector>
    </queuedEntityPlacer>
  </constructionHeuristic>

By default, the solving process combines the default strategies from both placers. For each list variable placement, we then test all possible placements for the basic variables and select the best combination. It is important to note that the list variables impose some restrictions on the CH settings, limiting it to only defining QueuedValuePlacer. The proposed approach retains these limitations, and the mixed model can only be configured as shown in the previous snippet.

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

First round of review finished. Will do a deeper reading when I have more time.

One general comment: until we can deliver this for LS as well, this needs to be disabled - people shouldn't be able to configure this, if it's going to fail later. It also should not be in the docs.

Let's keep the PR as is for now, but before we merge it, we add a kill switch. We will remove the kill switch when we merge the LS part.

Also - did you make sure enterprise works? Including nearby?

Comment thread benchmark/src/main/resources/benchmark.xsd
Comment thread core/src/main/java/ai/timefold/solver/core/impl/AbstractFromConfigFactory.java Outdated
Comment thread core/src/main/java/ai/timefold/solver/core/impl/AbstractFromConfigFactory.java Outdated
Comment thread docs/src/modules/ROOT/pages/optimization-algorithms/construction-heuristics.adoc Outdated
Comment thread docs/src/modules/ROOT/pages/optimization-algorithms/construction-heuristics.adoc Outdated
@zepfred

zepfred commented May 19, 2025

Copy link
Copy Markdown
Contributor Author

did you make sure enterprise works? Including nearby?

Not yet. I've planned it as a later step for when the LS is working.

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One comment, otherwise LGTM.

Comment thread docs/src/modules/ROOT/pages/optimization-algorithms/construction-heuristics.adoc Outdated
@sonarqubecloud

Copy link
Copy Markdown

@triceo triceo merged commit 8f43e8e into TimefoldAI:main May 21, 2025
41 of 42 checks passed
@triceo triceo added this to the v1.23.0 milestone May 21, 2025
@zepfred zepfred deleted the feat/multi-var branch March 10, 2026 16:46
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