private boolean cCreateFromScratch(Bounds i, int from, int to) {
		//Conversion
		long max = i.max;
		long min = i.min;
		if (i.max == APSPSolver.INF) max = H-O;
		if (i.min == -APSPSolver.INF) min = -1 * (H - O);
		i = new Bounds(min,max);

		// Checks
		if (i.min > i.max) return false; 
		if (from == to) return false;
		if (tPoints[from] == null) return false;

		//Already existing edge
		SimpleDistanceConstraint con = tPoints[from].getOut(to);
		if (con != null) {
			//check intersection between active con and new con
			if ( (con.getMinimum() > i.max) || (con.getMaximum() < i.min) ) return false;
			//check con does not contain active con
			if ( (con.getMinimum() > i.min) && (con.getMaximum() < i.max) ) {
				//OK it is. I save con without doing anything else
				if (!con.addInterval(i)) return false;
				return true;
			}
			//Update active con
			long oldd = con.getMinimum();
			long oldD = con.getMaximum();
			if (con.getMinimum() < i.min) con.setMinimum(i.min);
			if (con.getMaximum() > i.max) con.setMaximum(i.max);

			if (!con.addInterval(i)) return false;
			
			if (backupDMatrixSimple) saveDMatrixInternal();
			if (!fromScratchDistanceMatrixComputation()) {
				//Inconsistency. Rollback
				con.removeInterval(i);
				if (backupDMatrixSimple) restoreDMatrixInternal();
				return false;
			}

			//[lb,ub] = [-di0,d0i]
			for (int j = 0; j < MAX_USED+1; j++)
				if (tPoints[j].isUsed()) {
					tPoints[j].setLowerBound(sum(-distance[j][0],O));
					tPoints[j].setUpperBound(sum(distance[0][j],O));
				}
		}				
		else {
			con = new SimpleDistanceConstraint();
			con.setFrom(this.getVariable(from));
			con.setTo(this.getVariable(to));
			con.setMinimum(i.min);
			con.setMaximum(i.max);
			con.addInterval(new Bounds(i.min,i.max));
			//Add edge to tp
			tPoints[from].setOut(to,con);

			if (backupDMatrixSimple) saveDMatrixInternal();
			if (!fromScratchDistanceMatrixComputation()) {
				tPoints[from].setOut(to,null);
				if (backupDMatrixSimple) restoreDMatrixInternal();
				return false;
			}

			//[lb,ub] = [-di0,d0i]
			for (int j = 0; j < MAX_USED+1; j++) {
				if (tPoints[j].isUsed() == true) {
					tPoints[j].setLowerBound (sum(-distance[j][0],O));
					tPoints[j].setUpperBound (sum(distance[0][j],O));
				}
			}
		}
		return true;	
	}
private boolean cCreateFromScratch ( Bounds i , int from , int to ) { long max = i . max ; long min = i . min ; if ( i . max == APSPSolver . INF ) max = H - O ; if ( i . min == - APSPSolver . INF ) min = - 1 * ( H - O ) ; i = new Bounds ( min , max ) ; if ( i . min > i . max ) return false ; if ( from == to ) return false ; if ( tPoints [ from ] == null ) return false ; SimpleDistanceConstraint con = tPoints [ from ] . getOut ( to ) ; if ( con != null ) { if ( ( con . getMinimum ( ) > i . max ) || ( con . getMaximum ( ) < i . min ) ) return false ; if ( ( con . getMinimum ( ) > i . min ) && ( con . getMaximum ( ) < i . max ) ) { if ( ! con . addInterval ( i ) ) return false ; return true ; } long oldd = con . getMinimum ( ) ; long oldD = con . getMaximum ( ) ; if ( con . getMinimum ( ) < i . min ) con . setMinimum ( i . min ) ; if ( con . getMaximum ( ) > i . max ) con . setMaximum ( i . max ) ; if ( ! con . addInterval ( i ) ) return false ; if ( backupDMatrixSimple ) saveDMatrixInternal ( ) ; if ( ! fromScratchDistanceMatrixComputation ( ) ) { con . removeInterval ( i ) ; if ( backupDMatrixSimple ) restoreDMatrixInternal ( ) ; return false ; } for ( int j = 0 ; j < MAX_USED + 1 ; j ++ ) if ( tPoints [ j ] . isUsed ( ) ) { tPoints [ j ] . setLowerBound ( sum ( - distance [ j ] [ 0 ] , O ) ) ; tPoints [ j ] . setUpperBound ( sum ( distance [ 0 ] [ j ] , O ) ) ; } } else { con = new SimpleDistanceConstraint ( ) ; con . setFrom ( this . getVariable ( from ) ) ; con . setTo ( this . getVariable ( to ) ) ; con . setMinimum ( i . min ) ; con . setMaximum ( i . max ) ; con . addInterval ( new Bounds ( i . min , i . max ) ) ; tPoints [ from ] . setOut ( to , con ) ; if ( backupDMatrixSimple ) saveDMatrixInternal ( ) ; if ( ! fromScratchDistanceMatrixComputation ( ) ) { tPoints [ from ] . setOut ( to , null ) ; if ( backupDMatrixSimple ) restoreDMatrixInternal ( ) ; return false ; } for ( int j = 0 ; j < MAX_USED + 1 ; j ++ ) { if ( tPoints [ j ] . isUsed ( ) == true ) { tPoints [ j ] . setLowerBound ( sum ( - distance [ j ] [ 0 ] , O ) ) ; tPoints [ j ] . setUpperBound ( sum ( distance [ 0 ] [ j ] , O ) ) ; } } } return true ; }
Create an interval for a constraint