Package urban.model

Examples of urban.model.Agent



  private RuleGraph createRoot(Rule r, Data data) {
    RuleGraph result = null;
    {
      Agent aL = null;
      Agent bondA = null;
      Agent bondB = null;
      Site siteA = null;
      Site siteB = null;
     
      Iterator<Agent> rhsIt = data.rhs.iterator();
      Iterator<Agent> lhsIt = data.lhs.iterator();
      boolean reverse=false;
      while(lhsIt.hasNext() && rhsIt.hasNext()) {
        Agent a = lhsIt.next();
        Agent b = rhsIt.next();

        Iterator<Site> asIt = a.getSites().iterator();
        Iterator<Site> bsIt = b.getSites().iterator();
        while(asIt.hasNext() && bsIt.hasNext()){
          Site s = asIt.next();
          Site bs = bsIt.next();
         
          String m = s.getBindingMark();
          String n = bs.getBindingMark();
          if (m != null && !"?".equals(m) && !"_".equals(m)){
            if (data.first.containsKey(m))
              data.second.put(m, a);
            else
              data.first.put(m, a);
          }
          if ((m == null && n != null) || (n == null && m != null)){
            if (bondA != null){
              if(bondB != null)
                throw new IllegalArgumentException("Rule not supported: More than one bond formation dissallowed.");
              bondB = a;
              siteB = bs;
              if (m != null){
                data.first.remove(m);
                data.second.remove(m);
                reverse = true;
              }
            } else {
              bondA = a;
              siteA = bs;
            }
          }
         
          if (s.getState() != null && !s.getState().equals(bs.getState())){
            if (aL != null)
              throw new IllegalArgumentException("Rule not supported: More than one flip dissallowed.");
            aL = a;
          }
        } 
      }
      if (aL == null && bondA == null)
        throw new IllegalArgumentException("At least one site should differ");
      if (aL != null && bondA != null)
        throw new IllegalArgumentException("Rule not supported: Either flip or bond, not both.");       
       
      if (bondA == null){
        int indexOf = data.lhs.indexOf(aL);
        Agent aR = data.rhs.get(indexOf);
        result = data.rgArrays[indexOf] = new RuleGraph(new SiteNode(aL, aR));
        data.q.add(pairOf(aL, data.rgArrays[indexOf]));
      } else {
        result = new RuleGraph(new BondNode());
        int i=0;
View Full Code Here


        return s.getName();
    return null;
  }

  private static Agent getLinked(Agent aL, String m, Map<String, Agent> first, Map<String, Agent> second) {
    Agent agent = first.get(m);
    if (agent == null || agent == aL)
      agent = second.get(m);
    first.remove(m);
    second.remove(m);
    return agent;
View Full Code Here

  private static final Shape S1 = new Shape(A(f("0")));
  private static final Shape S2 = new Shape(A(f("0"),x(null)));
  private static final Shape S3 = new Shape(A(f("0"),x("_")));

  private static Set<Agent> A(Site... all) {
    return Collections.singleton(new Agent("A",Arrays.asList(all)));
  }
View Full Code Here

public class RateCalculatorTest {
  private static final Shape S1 = new Shape(A_f("0"));

  private static Set<Agent> A_f(String string) {
    return Collections.singleton(new Agent("A",Collections.singleton(new Site("A","f",string,null))));
  }
View Full Code Here

TOP

Related Classes of urban.model.Agent

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.