Element newElement = element.addElement("constraints");
for (Constraint constr : co.getConstraints()) {
Element el = newElement.addElement(constr.getClass().getSimpleName());
el.addAttribute("weight", "" + constr.getWeight());
if (constr instanceof RasterConstraint) {
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());