Skip to content

Commit

Permalink
Rename UNDEFINED_Type to UNDEFINED_PLAN_TYPE (is ok, because was pri…
Browse files Browse the repository at this point in the history
…vate before) and move it to BasicPlan.
  • Loading branch information
kt86 committed Mar 25, 2024
1 parent edb5b40 commit 03a43ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

package org.matsim.api.core.v01.population;

import org.matsim.core.replanning.selectors.GenericWorstPlanForRemovalSelector;

public interface BasicPlan {

void setScore( Double score );
String UNDEFINED_PLAN_TYPE = "undefined";

void setScore(Double score );

Double getScore();

/**
* Plan type, which may be used to ensure there is at least one plan of a certain type.
*/
default String getType() {
return GenericWorstPlanForRemovalSelector.UNDEFINED_TYPE;
return UNDEFINED_PLAN_TYPE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import static org.matsim.api.core.v01.population.BasicPlan.UNDEFINED_PLAN_TYPE;

/**
* <p>Selects the worst plan of a person (most likely for removal), but respects
* the set plan types in a way the no plan is selected that is the last one of
Expand All @@ -41,8 +43,6 @@
*/
public class GenericWorstPlanForRemovalSelector<T extends BasicPlan, I> implements PlanSelector<T, I> {

public static final String UNDEFINED_TYPE = "undefined";

@Override
public T selectPlan(HasPlansAndId<T, I> person) {

Expand All @@ -53,7 +53,7 @@ public T selectPlan(HasPlansAndId<T, I> person) {
for (T plan : person.getPlans()) {
String type = plan.getType();
if ( type==null ) {
type = UNDEFINED_TYPE ;
type = UNDEFINED_PLAN_TYPE;
}
typeCounts.merge( type, 1, ( a, b ) -> a + b );
}
Expand All @@ -64,7 +64,7 @@ public T selectPlan(HasPlansAndId<T, I> person) {

String type = plan.getType();
if ( type==null ) {
type = UNDEFINED_TYPE;
type = UNDEFINED_PLAN_TYPE;
}
if ( typeCounts.get( type ) > 1) {
// (if we have more than one plan of the same type:)
Expand Down

0 comments on commit 03a43ee

Please sign in to comment.