planner/src/main/java/School.java
public int _sinkSize() {
        List<Student> kids = new ArrayList<Student>();
        SourceOrSink previous = null;
        SourceOrSink current = this.getBus().getNext();
        int time = 0;
        boolean overFull = false;
        boolean schoolSeen = false;

        if (this.getBus().equals("dummy"))
            return 0;

        while (current != this && current != null) {

            if (current instanceof Stop) { // Stop
                Stop stop = (Stop)current;
                time += Plan.SECONDS_PER_STOP;
                boolean firstStudent = true;
                for (Student kid : stop.getStudentList()) {
                    if(firstStudent) {
                      firstStudent = false;
                    } else {
                      time += Plan.SECONDS_PER_STUDENT_AT_STOP;
                    }

                    kids.add(kid);
                }
            }

            if (kids.size() > Plan.STUDENTS_PER_BUS) {
                overFull = true;
            }

            if (current instanceof School) { // School
                School school = (School)current;
                List<Student> newKids = new ArrayList<Student>();
                for (Student kid : kids) {
                    if (!kid.getSchoolUuid().equals(school.getNode().getUuid())) { // kids not delivered
                        newKids.add(kid);
                    }
                    else { // kids delivered
                        time += Plan.SECONDS_PER_STUDENT_AT_SCHOOL;
                    }
                }
                kids = newKids;
                schoolSeen = true;
            }

            if (previous != null)
                time += previous.getNode().time(current.getNode());
            previous = current;
            current = current.getNext();
        }

        if (!(this.getPrevious() instanceof Bus))
            time += this.getPrevious().getNode().time(this.getNode());

        int delivered = 0;

        time = (int)((1.0 + ((Plan.SIGMA_OVER_MU-1.0)*Plan.SIGMAS))*time);
        if ((time < 60*Plan.MAX_RIDE_MINUTES) &&
            !overFull &&
            !(Plan.NO_TIERING && schoolSeen)) {
            for (Student kid : kids) {
                if (kid.getSchoolUuid().equals(this.getNode().getUuid()))
                    delivered++;
            }
        }

        return delivered;
    }
/**
     * Calculate the size of this stink.  This function is (typically)
     * called by OptaPlanner.
     *
     * @author James McClain
     */
Calculate the size of this stink.  This function is (typically)
called by OptaPlanner.


Calculate the size of this stink . This function is ( typically ) called by OptaPlanner .
public int _sinkSize() {
        List<Student> kids = new ArrayList<Student>();
        SourceOrSink previous = null;
        SourceOrSink current = this.getBus().getNext();
        int time = 0;
        boolean overFull = false;
        boolean schoolSeen = false;
        if (this.getBus().equals("dummy"))
            return 0;
        while (current != this && current != null) {
            if (current instanceof Stop) { 
                Stop stop = (Stop)current;
                time += Plan.SECONDS_PER_STOP;
                boolean firstStudent = true;
                for (Student kid : stop.getStudentList()) {
                    if(firstStudent) {
                      firstStudent = false;
                    } else {
                      time += Plan.SECONDS_PER_STUDENT_AT_STOP;
                    }
                    kids.add(kid);
                }
            }
            if (kids.size() > Plan.STUDENTS_PER_BUS) {
                overFull = true;
            }
            if (current instanceof School) { 
                School school = (School)current;
                List<Student> newKids = new ArrayList<Student>();
                for (Student kid : kids) {
                    if (!kid.getSchoolUuid().equals(school.getNode().getUuid())) { 
                        newKids.add(kid);
                    }
                    else { 
                        time += Plan.SECONDS_PER_STUDENT_AT_SCHOOL;
                    }
                }
                kids = newKids;
                schoolSeen = true;
            }
            if (previous != null)
                time += previous.getNode().time(current.getNode());
            previous = current;
            current = current.getNext();
        }
        if (!(this.getPrevious() instanceof Bus))
            time += this.getPrevious().getNode().time(this.getNode());
        int delivered = 0;
        time = (int)((1.0 + ((Plan.SIGMA_OVER_MU-1.0)*Plan.SIGMAS))*time);
        if ((time < 60*Plan.MAX_RIDE_MINUTES) &&
            !overFull &&
            !(Plan.NO_TIERING && schoolSeen)) {
            for (Student kid : kids) {
                if (kid.getSchoolUuid().equals(this.getNode().getUuid()))
                    delivered++;
            }
        }
        return delivered;
    }
public int _sinkSize ( ) { List < Student > kids = new ArrayList < Student > ( ) ; SourceOrSink previous = null ; SourceOrSink current = this . getBus ( ) . getNext ( ) ; int time = 0 ; boolean overFull = false ; boolean schoolSeen = false ; if ( this . getBus ( ) . equals ( "dummy" ) ) return 0 ; while ( current != this && current != null ) { if ( current instanceof Stop ) { Stop stop = ( Stop ) current ; time += Plan . SECONDS_PER_STOP ; boolean firstStudent = true ; for ( Student kid : stop . getStudentList ( ) ) { if ( firstStudent ) { firstStudent = false ; } else { time += Plan . SECONDS_PER_STUDENT_AT_STOP ; } kids . add ( kid ) ; } } if ( kids . size ( ) > Plan . STUDENTS_PER_BUS ) { overFull = true ; } if ( current instanceof School ) { School school = ( School ) current ; List < Student > newKids = new ArrayList < Student > ( ) ; for ( Student kid : kids ) { if ( ! kid . getSchoolUuid ( ) . equals ( school . getNode ( ) . getUuid ( ) ) ) { newKids . add ( kid ) ; } else { time += Plan . SECONDS_PER_STUDENT_AT_SCHOOL ; } } kids = newKids ; schoolSeen = true ; } if ( previous != null ) time += previous . getNode ( ) . time ( current . getNode ( ) ) ; previous = current ; current = current . getNext ( ) ; } if ( ! ( this . getPrevious ( ) instanceof Bus ) ) time += this . getPrevious ( ) . getNode ( ) . time ( this . getNode ( ) ) ; int delivered = 0 ; time = ( int ) ( ( 1.0 + ( ( Plan . SIGMA_OVER_MU - 1.0 ) * Plan . SIGMAS ) ) * time ) ; if ( ( time < 60 * Plan . MAX_RIDE_MINUTES ) && ! overFull && ! ( Plan . NO_TIERING && schoolSeen ) ) { for ( Student kid : kids ) { if ( kid . getSchoolUuid ( ) . equals ( this . getNode ( ) . getUuid ( ) ) ) delivered ++ ; } } return delivered ; }
Calculate the size of this stink.
Calculate the size of this stink .
// Stop // School // kids not delivered // kids delivered