public void execute(IOAVState state, IVariableAssignments assignments) { Object fn = assignments.getVariableValue("?fn"); int fncnt = ((Integer)state.getAttributeValue(fn, fibo_has_sequence)).intValue(); System.out.println("recurse for "+fncnt); Object fm = state.createRootObject(fibo_type); state.setAttributeValue(fm, fibo_has_value, Long.valueOf(-1)); state.setAttributeValue(fm, fibo_has_sequence, Integer.valueOf(fncnt-1)); } }, IPriorityEvaluator.PRIORITY_1));
/** * Get or create a clone of an oav object. * @param targetstate The target state. * @param handles The handles. * @param todo The todo list. * @param oldval The old object. */ protected Object getClonedOAVObject(IOAVState targetstate, Map handles, List todo, Object oldval) { Object newval = handles.get(oldval); if(newval==null) { if(rootobjects.contains(oldval)) newval = targetstate.createRootObject(getType(oldval)); else newval = targetstate.createObject(getType(oldval)); handles.put(oldval, newval); todo.add(oldval); } return newval; }
/** * Get or create a clone of an oav object. * @param targetstate The target state. * @param handles The handles. * @param todo The todo list. * @param oldval The old object. */ protected Object getClonedOAVObject(IOAVState targetstate, Map handles, List todo, Object oldval) { Object newval = handles.get(oldval); if(newval==null) { if(rootobjects.contains(oldval)) newval = targetstate.createRootObject(getType(oldval)); else newval = targetstate.createObject(getType(oldval)); handles.put(oldval, newval); todo.add(oldval); } return newval; }
/** * Create the state containing all possible combinations. */ public static IOAVState createState() { String[] names = new String[]{"Fred", "Joe", "Bob", "Tom"}; String[] colors = new String[]{"red", "blue", "plaid", "orange"}; Integer[] positions = new Integer[]{Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4)}; IOAVState state = OAVStateFactory.createOAVState(golfing_type_model); for(int i=0; i<names.length; i++) { for(int j=0; j<colors.length; j++) { for(int k=0; k<positions.length; k++) { Object golfer = state.createRootObject(golfer_type); state.setAttributeValue(golfer, golfer_has_name, names[i]); state.setAttributeValue(golfer, golfer_has_color, colors[j]); state.setAttributeValue(golfer, golfer_has_position, positions[k]); } } } return state; }
/** * Initialize the state with the given number of discs. */ protected static Object initState(int discs, IOAVState state, boolean showtowers) { // Setup Object agent = state.createRootObject(agent_type); for(int i=discs; i>0; i--) { Object disc = state.createObject(disc_type); state.setAttributeValue(disc, disc_has_size, Integer.valueOf(i)); state.addAttributeValue(agent, agent_has_tower_a, disc); } // Show Hanoi towers in JFrame. if(showtowers) showFrame(state, agent); return agent; }
Map todoafter = new HashMap(); if(rootobjects.contains(object)) handles.put(object, targetstate.createRootObject(getType(object))); else handles.put(object, targetstate.createObject(getType(object)));
Map todoafter = new HashMap(); if(rootobjects.contains(object)) handles.put(object, targetstate.createRootObject(getType(object))); else handles.put(object, targetstate.createObject(getType(object)));
public void execute(IOAVState state, IVariableAssignments assignments) { Integer id = (Integer)assignments.getVariableValue("?id"); String n1 = (String)assignments.getVariableValue("?n1"); Integer s = (Integer)assignments.getVariableValue("?s"); if(Manners.print) System.out.println("Make path: "+id+" "+n1+" "+s); Object path = state.createRootObject(Manners.path_type); state.setAttributeValue(path, Manners.path_has_id, id); state.setAttributeValue(path, Manners.path_has_name, n1); state.setAttributeValue(path, Manners.path_has_seat, s); } };
public void execute(IOAVState state, IVariableAssignments assignments) { Object f1 = assignments.getVariableValue("?f1"); Object n = assignments.getVariableValue("?n"); Object f3 = assignments.getVariableValue("?f3"); Integer c = (Integer)assignments.getVariableValue("?c"); System.out.println("Assign first seat: "+f1+" "+n+" "+f3+" "+c); Object seating = state.createRootObject(Manners.seating_type); state.setAttributeValue(seating, Manners.seating_has_seat1, Integer.valueOf(1)); state.setAttributeValue(seating, Manners.seating_has_name1, n); state.setAttributeValue(seating, Manners.seating_has_name2, n); state.setAttributeValue(seating, Manners.seating_has_seat2, Integer.valueOf(1)); state.setAttributeValue(seating, Manners.seating_has_id, c); state.setAttributeValue(seating, Manners.seating_has_pid, Integer.valueOf(0)); state.setAttributeValue(seating, Manners.seating_has_pathdone, Boolean.TRUE); Object path = state.createRootObject(Manners.path_type); state.setAttributeValue(path, Manners.path_has_id, c); state.setAttributeValue(path, Manners.path_has_name, n); state.setAttributeValue(path, Manners.path_has_seat, Integer.valueOf(1)); state.setAttributeValue(f3, Manners.count_has_c, Integer.valueOf(c.intValue()+1)); System.out.println("seat 1: "+n+" "+n+" 1 "+c+" 0 1"); state.setAttributeValue(f1, Manners.context_has_state, "assign_seats"); } };
ret = root? state.createRootObject((OAVObjectType)type): state.createObject((OAVObjectType)type); if(oavtype!=null) ret = root? state.createRootObject(oavtype): state.createObject(oavtype);
ret = root? state.createRootObject((OAVObjectType)type): state.createObject((OAVObjectType)type); if(oavtype!=null) ret = root? state.createRootObject(oavtype): state.createObject(oavtype);
Object f5 = assigments.getVariableValue("?f5"); Object seating = state.createRootObject(Manners.seating_type); state.setAttributeValue(seating, Manners.seating_has_seat1, seat2); state.setAttributeValue(seating, Manners.seating_has_name1, n2); state.setAttributeValue(seating, Manners.seating_has_pid, id); Object path = state.createRootObject(Manners.path_type); state.setAttributeValue(path, Manners.path_has_id, c); state.setAttributeValue(path, Manners.path_has_name, g2); state.setAttributeValue(path, Manners.path_has_seat, Integer.valueOf(seat2.intValue()+1)); Object chosen = state.createRootObject(Manners.chosen_type); state.setAttributeValue(chosen, Manners.chosen_has_id, id); state.setAttributeValue(chosen, Manners.chosen_has_name, g2);
IOAVState state = system.getState(); Object b1 = state.createRootObject(block_type); Object b2 = state.createRootObject(block_type); Object b3 = state.createRootObject(block_type); Object b4 = state.createRootObject(block_type); Object b5 = state.createRootObject(block_type);
ragent = state.createRootObject(OAVBDIRuntimeModel.agent_type); state.setAttributeValue(ragent, OAVBDIRuntimeModel.element_has_model, model.getHandle()); state.setAttributeValue(ragent, OAVBDIRuntimeModel.capability_has_configuration, config);
Object m = state.createRootObject(message_type); state.setAttributeValue(m, message_has_text, "Hello OAV (object, attribute, value) World!");
Object f50 = state.createRootObject(fibo_type); state.setAttributeValue(f50, fibo_has_value, Integer.valueOf(-1)); state.setAttributeValue(f50, fibo_has_sequence, Integer.valueOf(50));