Skip to content

Refactor operator gain evaluation #1266

@jcoupey

Description

@jcoupey

I started to work on some of the changes required for operator gain evaluation in #1252, whose purpose is to add a service time component to the costs. Doing so with the current state of the codebase would require to duplicate the "new" service time logic in many places, typically in all the *::compute_gain functions across local search operators. This would be:

  • error prone;
  • breaking the DRY principle;
  • a maintenance nightmare.

This situation is a hint that we could do better. Actually the cost evaluation is already currently repeating a lot of similar logic across operators. If this were refactored so that the various compute_gain functions would call a unified interface, then:

  • maintenance of the current cost evaluation code would be made much easier;
  • future changes like the one required for Add task times in costs #1252 would be much more straightforward.

This would be in a way similar to what we do with is_valid_addition_for_tw that operates in a generic manner on a route with a replaced range and an inserted range. The difference here is that we should keep things happening in constant time, so re-use various precomputed things from SolutionState, and not go through the inserted ranges.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions