Iterator bcit = a.getComparators().iterator();
while (bcit.hasNext())
{
//WARNING WARNING WARNING - assumes comparators are of the form (NamedFunction </>/<=/>= StaticFunction)
BinaryComparator bc = (BinaryComparator) bcit.next();
NamedFunction res = (NamedFunction) bc.first;
PrecedenceResourceGraph prg = (PrecedenceResourceGraph) graphs.get(res);
if (prg == null)
{
prg = new PrecedenceResourceGraph(stn);
graphs.put(res,prg);
}
state = (TemporalMetricState) states.get(a);
BigDecimal d = bc.second.getValue(state);
prg.addCondition(new BinaryComparator( bc.type, res, new NumberFunction(d)), a);
}
Iterator roit = a.getOperators().iterator();
while (roit.hasNext())
{
ResourceOperator ro = (ResourceOperator) roit.next();
NamedFunction res = (NamedFunction) ro.resource;
PrecedenceResourceGraph prg = (PrecedenceResourceGraph) graphs.get(res);
if (prg == null)
{
prg = new PrecedenceResourceGraph(stn);
graphs.put(res,prg);
}
prg.addOperator(new ResourceOperator( ro.type, res, ro.change.makeOnlyDurationDependent(state)), a);
}
}
Iterator git = graphs.keySet().iterator();
while (git.hasNext())
{
NamedFunction nf = (NamedFunction) git.next();
PrecedenceResourceGraph prg = (PrecedenceResourceGraph) graphs.get(nf);
prg.addOperator(new ResourceOperator(MetricSymbolStore.INCREASE, nf, new NumberFunction(nf.getValue(problem.getTemporalMetricInitialState()))), stn.START);
boolean changesMade = true;
while (changesMade)
{
changesMade = prg.meetConditions();
stn.constrain();