Package org.libreplan.business.planner.limiting.entities

Examples of org.libreplan.business.planner.limiting.entities.AllocationSpec


    public List<LimitingResourceQueueElement> assignLimitingResourceQueueElement(
            LimitingResourceQueueElement externalQueueElement) {

        InsertionRequirements requirements = queuesState
                .getRequirementsFor(externalQueueElement);
        AllocationSpec allocation = insertAtGap(requirements);
        if (allocation == null) {
            return Collections.emptyList();
        }
        applyAllocation(allocation);

        assert allocation.isValid();
        List<LimitingResourceQueueElement> result = new ArrayList<LimitingResourceQueueElement>();
        result.add(requirements.getElement());

        List<LimitingResourceQueueElement> moved = shift(
                queuesState
View Full Code Here


        List<LimitingResourceQueueElement> mightNeedShift = withoutElementInserted(
                elementInserted,
                QueuesState.topologicalIterator(potentiallyAffectedByInsertion));
        for (LimitingResourceQueueElement each : mightNeedShift) {
            AllocationSpec futureAllocation = getAllocationToBeDoneFor(
                    potentiallyAffectedByInsertion,
                    allocationsToBeDoneByElement, each);
            if (futureAllocation != null) {
                result.add(futureAllocation);
                allocationsToBeDoneByElement.put(each, futureAllocation);
View Full Code Here

        DateAndHour newEnd = current.getEndTime();
        Map<LimitingResourceQueueElement, List<Edge>> incoming = bySource(potentiallyAffectedByInsertion
                .incomingEdgesOf(current));
        for (Entry<LimitingResourceQueueElement, List<Edge>> each : incoming
                .entrySet()) {
            AllocationSpec previous = allocationsToBeDoneByElement.get(each
                    .getKey());
            if (previous != null) {
                newStart = DateAndHour.max(newStart, getStartFrom(previous,
                        each.getValue()));
                newEnd = DateAndHour.max(newEnd, getEndFrom(previous, each
                        .getValue()));
            }
        }
        if (current.getStartTime().compareTo(newStart) == 0
                && current.getEndTime().compareTo(newEnd) == 0) {
            return null;
        }
        InsertionRequirements requirements = InsertionRequirements.create(
                current, newStart, newEnd);
        GapOnQueue gap = Gap.untilEnd(current, newStart).onQueue(
                current.getLimitingResourceQueue());
        AllocationSpec result = requirements.guessValidity(gap);
        assert result.isValid();
        return result;
    }
View Full Code Here

    /**
     * @return <code>null</code> if no suitable gap found; the allocation found
     *         otherwise
     */
    private AllocationSpec insertAtGap(InsertionRequirements requirements) {
        AllocationSpec allocationStillNotDone = findAllocationSpecFor(requirements);
        return doAppropriativeIfNecessary(allocationStillNotDone, requirements);
    }
View Full Code Here

    private AllocationSpec findAllocationSpecFor(List<GapOnQueue> gapsOnQueue, InsertionRequirements requirements) {
        boolean generic = requirements.getElement().isGeneric();
        for (GapOnQueue each : gapsOnQueue) {
            for (GapOnQueue eachSubGap : getSubGaps(each,
                    requirements.getElement(), generic)) {
                AllocationSpec allocation = requirements
                        .guessValidity(eachSubGap);
                if (allocation.isValid()) {
                    return allocation;
                }
            }
        }
        return null;
View Full Code Here

        }
        return null;
    }

    private AllocationSpec insertAtGap(InsertionRequirements requirements, LimitingResourceQueue queue) {
        AllocationSpec allocationStillNotDone = findAllocationSpecForInQueue(requirements, queue);
        return doAppropriativeIfNecessary(allocationStillNotDone, requirements);
    }
View Full Code Here

            final DateAndHour endsAfter) {

        // Check if allocation is possible
        InsertionRequirements requirements = queuesState.getRequirementsFor(
                element, startAt);
        AllocationSpec allocation = insertAtGap(requirements, queue);
        if (!allocation.isValid()) {
            return Collections.emptyList();
        }

        // Do allocation
        applyAllocation(allocation, new IDayAssignmentBehaviour() {

            @Override
            public void allocateDayAssigments(IntraDayDate start,
                    IntraDayDate end) {

                List<DayAssignment> assignments = LimitingResourceAllocator
                        .generateDayAssignments(
                                element.getResourceAllocation(),
                                queue.getResource(), startAt, endsAfter);
                element.getResourceAllocation().allocateLimitingDayAssignments(
                        assignments, start, end);
            }

        });

        assert allocation.isValid();

        // Move other tasks to respect dependency constraints
        List<LimitingResourceQueueElement> result = new ArrayList<LimitingResourceQueueElement>();
        result.add(requirements.getElement());
View Full Code Here

            return null;
        }
        GapOnQueueWithQueueElement first = gaps.get(0);
        GapOnQueue gapOnQueue = first.getGapOnQueue();
        if (gapOnQueue != null) {
            AllocationSpec allocation = requirements.guessValidity(gapOnQueue);
            if (allocation.isValid()) {
                return allocation;
            }
        }
        result.add(unschedule(first.getQueueElement()));
        if (gaps.size() > 1) {
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.limiting.entities.AllocationSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.