Package de.timefinder.algo.constraint

Examples of de.timefinder.algo.constraint.EventOrderConstraint


            for (Event firstEvent : getEventDao().getAll()) {
                for (Event secEvent : getEventDao().getAll()) {
                    int i = Integer.parseInt(bReader.readLine());
                    if (i == 1) {
                        // add the constraint to the both event
                        EventOrderConstraint firstConstraint = firstEvent.getConstraint(EventOrderConstraint.class);
                        if (firstConstraint == null) {
                            firstConstraint = new EventOrderConstraint(firstEvent);
                            firstEvent.putConstraint(firstConstraint);
                        }
                        firstConstraint.addFollow(secEvent);

                        EventOrderConstraint secConstraint = secEvent.getConstraint(EventOrderConstraint.class);
                        if (secConstraint == null) {
                            secConstraint = new EventOrderConstraint(secEvent);
                            secEvent.putConstraint(secConstraint);
                        }
                        secConstraint.addBefore(firstEvent);
                    } else if (i == -1) {
                        // We could check now the priviously added followers and beforers,
                        // but this is not possible because '-1' could occur the
                        // first time (instead of expected '1')
                    }
View Full Code Here


        }
    }

    private Set<Assignment> createFollowsAssignments(Assignment ass, Collection<Assignment> allAssignments) {
        Event event = ass.getEvent();
        EventOrderConstraint oc = event.getConstraint(EventOrderConstraint.class);
        if (oc == null)
            return Collections.EMPTY_SET;

        Set<Assignment> res = FastSet.newInstance();
        for (Event ev : oc.getFollows()) {
            for (Assignment tmpAss : allAssignments) {
                if (tmpAss.getEvent() == ev) {
                    res.add(tmpAss);
                    break;
                }
View Full Code Here

        return res;
    }

    private Set<Assignment> createBeforesAssignments(Assignment ass, Collection<Assignment> allAssignments) {
        Event event = ass.getEvent();
        EventOrderConstraint oc = event.getConstraint(EventOrderConstraint.class);
        if (oc == null)
            return Collections.EMPTY_SET;

        Set<Assignment> res = FastSet.newInstance();
        for (Event ev : oc.getBefores()) {
            for (Assignment tmpAss : allAssignments) {
                if (tmpAss.getEvent() == ev) {
                    res.add(tmpAss);
                    break;
                }
View Full Code Here

        float[] oldColumn = origMatrix.getColumn(index);
        Set oldAvailableLocs = FastSet.newInstance();
        oldAvailableLocs.addAll(availableLocations);

        EventOrderConstraint oc = ass.getEvent().getConstraint(EventOrderConstraint.class);
        if (oc != null) {
            for (Event ev : oc.getFollows()) {
                Integer n = orderContainer.remove(ev);
                if (n > 1)
                    orderContainer.put(ev, n - 1);
            }
            for (Event ev : oc.getBefores()) {
                Integer n = orderContainer.remove(ev);
                if (n > 1)
                    orderContainer.put(ev, n - 1);
            }
        }
View Full Code Here

        assert check();
    }

    private void addToOrder(Assignment ass) {
        EventOrderConstraint oc = ass.getEvent().getConstraint(EventOrderConstraint.class);
        if (oc != null) {
            for (Event ev : oc.getFollows()) {
                Integer n = orderContainer.put(ev, 1);
                if (n != null)
                    orderContainer.put(ev, n + 1);
            }
            for (Event ev : oc.getBefores()) {
                Integer n = orderContainer.put(ev, 1);
                if (n != null)
                    orderContainer.put(ev, n + 1);
            }
        }
View Full Code Here

        loc1.addFeature(special);
        aManager = new AssignmentManager(0, allLocations);

        Assignment ass1 = newAssignment("1", 0, 1);
        Assignment ass2 = newAssignment("2", 0, 1);
        EventOrderConstraint oc1 = new EventOrderConstraint(ass1.getEvent());
        EventOrderConstraint oc2 = new EventOrderConstraint(ass2.getEvent());
        oc2.addFollow(newEvent("ev3"));

        ass1.getEvent().putConstraint(oc1);
        ass2.getEvent().putConstraint(oc2);
        ass2.getEvent().addFeature(special);
View Full Code Here

            }
        }
    }

    private void connect(Assignment prev, Assignment follow) {
        EventOrderConstraint oc = prev.getEvent().getConstraint(EventOrderConstraint.class);
        oc.addFollow(follow.getEvent());

        EventOrderConstraint oc2 = follow.getEvent().getConstraint(EventOrderConstraint.class);
        oc2.addBefore(prev.getEvent());
    }
View Full Code Here

    }

    @Override
    protected Assignment newAssignment(String str) {
        Assignment ass = super.newAssignment(str, 1, 1);
        ass.getEvent().putConstraint(new EventOrderConstraint(ass.getEvent()));
        return ass;
    }
View Full Code Here

                RasterConstraint rc = (RasterConstraint) constr;
                Writing w = getWriting(BitSet.class);
                el.setText(w.toString(rc.getRaster().getForbidden()));
                el.addAttribute("length", "" + rc.getRaster().getForbidden().getLength());
            } else if (constr instanceof EventOrderConstraint) {
                EventOrderConstraint eoc = (EventOrderConstraint) constr;
                el.addElement("event").addAttribute("ref", "" + eoc.getEvent().getId());
                for (Event ev : eoc.getBefores()) {
                    el.addElement("beforeEvent").addAttribute("ref", "" + ev.getId());
                }
                for (Event ev : eoc.getFollows()) {
                    el.addElement("followsEvent").addAttribute("ref", "" + ev.getId());
                }
            } else if (constr instanceof PersonITCRasterConstraint) {
                PersonITCRasterConstraint pc = (PersonITCRasterConstraint) constr;
                el.addElement("person").addAttribute("ref", "" + pc.getPerson().getId());
View Full Code Here

                        "First element in eventOrderConstraint must be the event!" + element.getPath());
                for (Object eocObj : element.elements()) {
                    Element eocEl = (Element) eocObj;
                    if ("event".equals(eocEl.getName())) {
                        Event ev = getObject(getRef(eocEl), Event.class);
                        constraint = new EventOrderConstraint(ev);
                    } else if ("beforeEvent".equals(eocEl.getName())) {
                        if (constraint == null)
                            throw excFirstEl;
                        Event ev = getObject(getRef(eocEl), Event.class);
                        ((EventOrderConstraint) constraint).addBefore(ev);
View Full Code Here

TOP

Related Classes of de.timefinder.algo.constraint.EventOrderConstraint

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.