Skip to content

Commit

Permalink
Merge pull request #15 from nextmv-io/feature/eng-4745-review-exporte…
Browse files Browse the repository at this point in the history
…d-interfaces-from-nextroute-plugins

Interface review
  • Loading branch information
davidrijsman authored Mar 6, 2024
2 parents 023f86b + 160d985 commit 6a56686
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
4 changes: 0 additions & 4 deletions model_constraint_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ func (l *attributesConstraintImpl) SetVehicleTypeAttributes(
return nil
}

func (l *attributesConstraintImpl) CheckCost() Cost {
return Constant
}

func (l *attributesConstraintImpl) EstimationCost() Cost {
return Constant
}
Expand Down
2 changes: 1 addition & 1 deletion model_constraint_maximum_wait_vehicle.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// MaximumWaitVehicleConstraint is a constraint that limits the accumulated time
// a vehicle can wait at stops on its route. Wait is defined as the time between
// arriving at a the location of stop and starting (to work),
// arriving at a location of stop and starting (to work),
// [SolutionStop.StartValue()] - [SolutionStop.ArrivalValue()].
type MaximumWaitVehicleConstraint interface {
ModelConstraint
Expand Down
8 changes: 5 additions & 3 deletions model_objective.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,23 @@ type ModelObjectiveSum interface {
// factor.
NewTerm(factor float64, objective ModelObjective) (ModelObjectiveTerm, error)

// ObjectiveTerms returns the model objectives that are part of the sum.
// Terms returns the model objective terms that are part of the sum.
Terms() ModelObjectiveTerms
}

// ModelObjectiveTerm is a term in a model objective sum.
type ModelObjectiveTerm interface {
// Factor returns the factor by which the objective is multiplied.
Factor() float64
// Objective returns the objective that is multiplied by the factor.
Objective() ModelObjective
}

// ModelObjectiveTerms is a slice of model objective terms.
type ModelObjectiveTerms []ModelObjectiveTerm

// ObjectiveDataUpdater is is a deprecated interface. Please use
// ObjectiveStopDataUpdater instead.
// ObjectiveDataUpdater is deprecated.
// Deprecated: Please use ObjectiveStopDataUpdater instead.
type ObjectiveDataUpdater interface {
// UpdateObjectiveData is deprecated.
UpdateObjectiveData(s SolutionStop) (Copier, error)
Expand Down
5 changes: 3 additions & 2 deletions solution_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (m solutionMoveImpl) IncrementValueSeen(_ int) SolutionMove {

// takeBestInPlace takes the best move and a candidate move.
// It tries to modify best in place, if the underlying type allows it.
// Otherwise it makes a deep copy of that and returns it.
// Otherwise, it makes a deep copy of that and returns it.
func takeBestInPlace(best, that SolutionMove) SolutionMove {
if !that.IsExecutable() {
return best
Expand All @@ -138,7 +138,8 @@ func takeBestInPlace(best, that SolutionMove) SolutionMove {
return tryReplaceBy(best, that, best.ValueSeen()+that.ValueSeen())
}

// tryReplaceBy the move in src to dst by mutating dst if possible. Otherwise makes a copy.
// tryReplaceBy the move in src to dst by mutating dst if possible. Otherwise,
// makes a copy.
func tryReplaceBy(dst, src SolutionMove, newValueSeen int) SolutionMove {
// first we try to mutate in place
if dstImpl, ok := dst.(*solutionMoveStopsImpl); ok {
Expand Down
3 changes: 1 addition & 2 deletions solution_position_hint.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func noPositionsHint() *stopPositionHintImpl {
}

// SkipVehiclePositionsHint returns a new StopPositionsHint that skips the
// vehicle if skipVehicle is true. Is skipVehicle is false the solver will try
// to find the next stop.
// vehicle.
func SkipVehiclePositionsHint() StopPositionsHint {
return skipVehiclePositionsHint()
}
Expand Down
6 changes: 6 additions & 0 deletions solution_sequence_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import (
// SequenceGeneratorChannel generates all possible sequences of solution stops
// for a given plan planUnit.
//
// If there are more possible sequences than the maximum number of sequences
// allowed by the model, the generator will stop generating sequences after
// the maximum number of sequences has been reached. The maximum number of
// sequences is set by the model's [Model.SequenceSampleSize] function.
// The sequences are generated in a random order.
//
// Example:
//
// quit := make(chan struct{})
Expand Down
4 changes: 4 additions & 0 deletions solution_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ type SolutionStop interface {
// meaning.
CumulativeValue(expression ModelExpression) float64

// DurationValue returns the duration of the stop as a float64. If the stop
// is unplanned, the duration has no semantic meaning.
DurationValue() float64

// End returns the end time of the stop. If the stop is unplanned, the end
// time has no semantic meaning.
End() time.Time
Expand Down

0 comments on commit 6a56686

Please sign in to comment.