public boolean sendRMessages() throws PostServiceNotSetException{
        //System.out.println("Sono nella sendR");
        if (this.postservice == null){
            throw new PostServiceNotSetException();
        }

        boolean atLeastOneUpdated = false;

        switch (Athena.shuffleMessage){

            case 1:
                Object[] arrayf = this.getFunctions().toArray();
                arrayf = Utils.shuffleArrayFY(arrayf);

                for (Object nodeFunction : arrayf) {
                    Object[] arrayx = this.getVariablesOfFunction((NodeFunction)nodeFunction).toArray();
                    arrayx = Utils.shuffleArrayFY(arrayx);

                    // TODO: shuffling is DA WAY

                    for (Object nodeVariable : arrayx) {
                        //atLeastOneUpdated |= this.op.updateQ(variable, function, this.postservice);
                        atLeastOneUpdated |= this.op.updateR((NodeFunction)nodeFunction, (NodeVariable)nodeVariable, this.postservice);
                    }


                }
                break;

            case 0:
            default:

                Iterator<NodeFunction> iteratorf = this.getFunctions().iterator();
                NodeVariable variable = null;
                NodeFunction function = null;

                while (iteratorf.hasNext()){
                    function = iteratorf.next();
                    //System.out.println("Sono la funzione "+function.getId()+" dell'agente "+this.id());
                    // gotcha a variable, looking for its functions

                    //Iterator<NodeFunction> iteratorf = this.variableToFunctions.get(variable).iterator();
                    Iterator<NodeVariable> iteratorv = this.getVariablesOfFunction(function).iterator();
                    while (iteratorv.hasNext()){
                        variable = iteratorv.next();
                        //System.out.println("Sono la variabile "+variable.getId()+" dei vicini di "+function.getId());
                        // got variable, function
                        if (debug>=1) {
                                String dmethod = Thread.currentThread().getStackTrace()[1].getMethodName();
                                String dclass = Thread.currentThread().getStackTrace()[1].getClassName();
                                System.out.println("---------------------------------------");
                                System.out.println("[class: "+dclass+" method: " + dmethod+ "] " + "agent "+this+"  preparing R from " + function + " to " + variable);
                                System.out.println("---------------------------------------");
                        }
                       
                        atLeastOneUpdated |= this.op.updateR(function, variable, this.postservice);

                        if (debug>=1) {
                                String dmethod = Thread.currentThread().getStackTrace()[2].getMethodName();
                                String dclass = Thread.currentThread().getStackTrace()[2].getClassName();
                                System.out.println("---------------------------------------");
                                System.out.println("[class: "+dclass+" method: " + dmethod+ "] " + "messageR updated:");
                                MessageR mq = this.postservice.readRMessage(function, variable);
                                System.out.println("Sender "+ mq.getSender() + " Receiver " + mq.getReceiver() + " message "+ mq );
                                System.out.println("---------------------------------------");
                        }
                    }

                }
        }
        return atLeastOneUpdated;
    }