Code Duplication    Length = 33-36 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/framework/microkernel/resolver/plan/TimelineAwarePlanRefinementResolver.java 2 locations

@@ 1030-1065 (lines=36) @@
1027
				c3.setLowerBound(0);
1028
				c3.setUpperBound(this.tdb.getHorizon());
1029
				
1030
				try {
1031
					
1032
					// propagate temporal constraint
1033
					this.tdb.propagate(c3);
1034
					// check temporal consistency
1035
					this.tdb.verify();
1036
					
1037
					//  consistent so create a possible refinements considering this schedule
1038
					for (GoalExpansion exp : this.expansions(goal)) {
1039
						
1040
						// create schedule
1041
						GoalSchedule schedule = new GoalSchedule(
1042
								tokens.get(tokens.size() - 1), 
1043
								goal.getDecision(),
1044
								0,
1045
								this.tdb.getHorizon());
1046
1047
						// add goal schedule
1048
						exp.addGoalSchedule(schedule);
1049
						// add expansion and related relation as feasible refinement of the goal
1050
						goal.addSolution(exp);
1051
						debug("Add goal expansion solution\n\t- " + exp + "\n");
1052
						
1053
					}
1054
					
1055
				} catch (TemporalConstraintPropagationException | ConsistencyCheckException  ix) {
1056
					
1057
					// infeasible schedule of the decision
1058
					debug("Infeasible schedule of goal " + goal.getDecision() + "\n"
1059
							+ "\t- token: " + tokens.get(tokens.size() - 1) + "\n"
1060
							+ "\t- goal: " + goal.getDecision() + "\n");
1061
					
1062
				} finally {
1063
					
1064
					// discard propagated constraints
1065
					this.tdb.retract(c3);
1066
				}
1067
			}
1068
			
@@ 916-948 (lines=33) @@
913
				c0.setLowerBound(0);
914
				c0.setUpperBound(this.tdb.getHorizon());
915
				
916
				try {
917
					
918
					// propagate temporal constraint
919
					this.tdb.propagate(c0);
920
					// check temporal consistency
921
					this.tdb.verify();
922
					
923
					//  consistent so create a possible refinements considering this schedule
924
					for (GoalExpansion exp : this.expansions(goal)) {
925
						
926
						// add goal schedule
927
						exp.addGoalSchedule(new GoalSchedule(
928
								goal.getDecision(),
929
								tokens.get(0),
930
								0,
931
								this.tdb.getHorizon()));
932
						
933
						// add expansion and related relation as feasible refinement of the goal
934
						goal.addSolution(exp);
935
						debug("Add goal expansion solution\n\t- " + exp + "\n");
936
						
937
					}
938
					
939
				} catch (TemporalConstraintPropagationException | ConsistencyCheckException  ix) {
940
					
941
					// infeasible schedule of the decision
942
					debug("Infeasible schedule of goal " + goal.getDecision() + "\n"
943
							+ "\t- goal: " + goal.getDecision() + "\n"
944
							+ "\t- token: " + tokens.get(0) + "\n");
945
				} finally {
946
					
947
					// discard propagated constraints
948
					this.tdb.retract(c0);
949
				}
950
				
951