Code Duplication    Length = 33-34 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/lang/ddl/v3/DDLv3Compiler.java 2 locations

@@ 396-429 (lines=34) @@
393
	 * @param ddlDec
394
	 * @return
395
	 */
396
	private ProblemFact addFactToProblem(Problem problem, ComponentValue val, DDLInstantiatedComponentDecision ddlDec) {
397
		// set start bound
398
		long[] start = new long[] {this.origin, this.horizon};
399
		// check start bounds
400
		if (ddlDec.getStart() != null) {
401
			start = new long[] {
402
				ddlDec.getStart().getMin(),
403
				ddlDec.getStart().getMax() > this.horizon ? 
404
						this.horizon : 
405
						ddlDec.getStart().getMax()
406
			};
407
		}
408
		
409
		// set end bound 
410
		long[] end = new long[] {this.origin, this.horizon};
411
		if (ddlDec.getEnd() != null) {
412
			end = new long[] {
413
					ddlDec.getEnd().getMin(),
414
					ddlDec.getEnd().getMax() > this.horizon ? 
415
							this.horizon : 
416
							ddlDec.getEnd().getMax()
417
				};
418
		}
419
		
420
		// parameter labels
421
		String[] labels = new String[] {};
422
		if (ddlDec.getComponentDecision() instanceof DDLSingletonStateVariableComponentDecision) {
423
			// get decision
424
			DDLSingletonStateVariableComponentDecision ddlSingleton = (DDLSingletonStateVariableComponentDecision) ddlDec.getComponentDecision();
425
			labels = ddlSingleton.getParameterNames().toArray(new String[ddlSingleton.getParameterNames().size()]);
426
		}
427
		
428
		// add a fact
429
		return problem.addFact(val, labels, start, end);
430
	}
431
432
	/**
@@ 354-386 (lines=33) @@
351
	 * @param ddlDec
352
	 * @return
353
	 */
354
	private ProblemGoal addGoalToProblem(Problem problem, ComponentValue val, DDLInstantiatedComponentDecision ddlDec) {
355
		// set start bound
356
		long[] start = new long[] {this.origin, this.horizon};
357
		// check start bounds
358
		if (ddlDec.getStart() != null) {
359
			start = new long[] {
360
				ddlDec.getStart().getMin(),
361
				ddlDec.getStart().getMax() > this.horizon ? 
362
						this.horizon : 
363
						ddlDec.getStart().getMax()
364
			};
365
		}
366
		
367
		// set end bound 
368
		long[] end = new long[] {this.origin, this.horizon};
369
		if (ddlDec.getEnd() != null) {
370
			end = new long[] {
371
					ddlDec.getEnd().getMin(),
372
					ddlDec.getEnd().getMax() > this.horizon ? 
373
							this.horizon : 
374
							ddlDec.getEnd().getMax()
375
				};
376
		}
377
		
378
		// parameter labels
379
		String[] labels = new String[] {};
380
		if (ddlDec.getComponentDecision() instanceof DDLSingletonStateVariableComponentDecision) {
381
			// get decision
382
			DDLSingletonStateVariableComponentDecision ddlSingleton = (DDLSingletonStateVariableComponentDecision) ddlDec.getComponentDecision();
383
			labels = ddlSingleton.getParameterNames().toArray(new String[ddlSingleton.getParameterNames().size()]);
384
		}
385
		// add goal
386
		return problem.addGoal(val, labels, start, end);
387
	}
388
389
	/**