1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

simplified method names

This commit is contained in:
oblonski 2014-07-16 10:34:06 +02:00
parent 74ca4884db
commit 251ded5fb7
2 changed files with 49 additions and 20 deletions

View file

@ -285,6 +285,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
return null;
}
/**
* Generic method to memorize state 'state' of type 'type' of act and stateId.
*
@ -298,16 +299,49 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
* @param stateId stateId of state
* @param type class of state-value
* @param state state-value
* @deprecated use putActivityState(...) instead
*/
@Deprecated
public <T> void putTypedActivityState(TourActivity act, StateId stateId, Class<T> type, T state){
// if(act.getIndex()>=activity_states.length){
// nuActivities=act.getIndex()+1;
// this.activity_states = resizeArr(activity_states,nuActivities);
// }
if(stateId.getIndex()<10) StateFactory.throwReservedIdException(stateId.toString());
if(stateId.getIndex()<10) throw new IllegalStateException("either you use a reserved stateId that is applied\n" +
"internally or your stateId has been created without index, e.g. StateFactory.createId(stateName)\n" +
" does not assign indeces thus do not use it anymore, but use\n " +
"stateManager.createStateId(name)\n" +
" instead.\n");
putInternalTypedActivityState(act, stateId, type, state);
}
/**
* Generic method to memorize state 'state' of type 'type' of act and stateId.
*
* <p><b>For example: </b><br>
* <code>Capacity loadAtMyActivity = Capacity.Builder.newInstance().addCapacityDimension(0,10).build();<br>
* stateManager.putTypedActivityState(myActivity, StateFactory.createStateId("act-load"), Capacity.class, loadAtMyActivity);</code>
* <p>you can retrieve the load at myActivity by <br>
* <code>Capacity load = stateManager.getActivityState(myActivity, StateFactory.createStateId("act-load"), Capacity.class);</code>
*
* @param act for which a new state should be memorized
* @param stateId stateId of state
* @param type class of state-value
* @param state state-value
*/
public <T> void putActivityState(TourActivity act, StateId stateId, Class<T> type, T state){
// if(act.getIndex()>=activity_states.length){
// nuActivities=act.getIndex()+1;
// this.activity_states = resizeArr(activity_states,nuActivities);
// }
if(stateId.getIndex()<10) throw new IllegalStateException("either you use a reserved stateId that is applied\n" +
"internally or your stateId has been created without index, e.g. StateFactory.createId(stateName)\n" +
" does not assign indeces thus do not use it anymore, but use\n " +
"stateManager.createStateId(name)\n" +
" instead.\n");
putInternalTypedActivityState(act, stateId, type, state);
}
private Object[][] resizeArr(Object[][] states, int newLength) {
int oldSize = states.length;
Object[][] new_states = new Object[newLength][stateIndexCounter];
@ -332,10 +366,11 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
* @param stateId stateId of the state value to identify it
* @param type type of state
* @param state state value
* @deprecated use putRouteState(...) instead
*/
@Deprecated
public <T> void putTypedRouteState(VehicleRoute route, StateId stateId, Class<T> type, T state){
putTypedRouteState(route,stateId,state);
putRouteState(route, stateId, state);
}
/**
@ -351,7 +386,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart
* @param stateId stateId of the state value to identify it
* @param state state value
*/
public <T> void putTypedRouteState(VehicleRoute route, StateId stateId, T state){
public <T> void putRouteState(VehicleRoute route, StateId stateId, T state){
if(stateId.getIndex()<10) StateFactory.throwReservedIdException(stateId.toString());
putTypedInternalRouteState(route, stateId, state);
}

View file

@ -16,17 +16,11 @@
******************************************************************************/
package jsprit.core.problem.solution.route.activity;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import jsprit.core.problem.job.Job;
import jsprit.core.problem.solution.route.activity.TourActivity.JobActivity;
import java.util.*;
/**
@ -84,6 +78,8 @@ public class TourActivities {
private final Set<Job> jobs = new HashSet<Job>();
private final Map<Job,List<Integer>> job2activityIndeces = new HashMap<Job,List<Integer>>();
private ReverseActivityIterator backward;
private TourActivities(TourActivities tour2copy) {
@ -178,21 +174,19 @@ public class TourActivities {
* ...
*
*/
if(insertionIndex < tourActivities.size()) tourActivities.add(insertionIndex, act);
else if(insertionIndex >= tourActivities.size()) tourActivities.add(act);
if(insertionIndex < tourActivities.size()) {
tourActivities.add(insertionIndex, act);
}
else if(insertionIndex >= tourActivities.size()) {
tourActivities.add(act);
}
addJob(act);
}
/**
<<<<<<< HEAD
* adds activity.
*
* @throw {@link IllegalStateException} if same activity is added twice.
=======
* Adds specified activity at the end of activity-list.
* <p>If act instanceof JobActivity, it adds underlying job also.
* @throws IllegalStateException if activity-list already contains act.
>>>>>>> refs/remotes/choose_remote_name/relaxAPI
* @param act
*/
public void addActivity(TourActivity act){