Menu

Updating preference weights

Problems
Anonymous
2015-12-15
2015-12-16
  • Anonymous

    Anonymous - 2015-12-15

    After one iteration, I want to update the preference weights of some agents. First, I

            getLaraComp().getBOMemory().clear();
    

    Second, I get the preference weight map and then start to put the new weights for the goals.

            Map<Class<? extends LaraPreference>, Double> preferences = getLaraComp().getPreferenceWeights();
    
            preferences.put(ComfortMaximization.class, 0.0);
            preferences.put(CostMinimization.class, 0.05);
            preferences.put(PollutionMinimization.class, 0.9);
            preferences.put(SecurityMaximization.class, 0.05);
    

    Third, I create a new Set for the behavioural options and add them accordingly with the new preferences.

            Set<AbstractConsumerBehaviouralOption<ConsumerAgent>> behaviouralOptions = new HashSet<AbstractConsumerBehaviouralOption<ConsumerAgent>>();
    
            behaviouralOptions.add(new DoNothing("donothing", this, preferences));
            behaviouralOptions.add(new BuyConventionalCar("buyconventionalcar", this, preferences));
            behaviouralOptions.add(new BuyHybridCar("buyhybridcar", this, preferences));
            behaviouralOptions.add(new BuyElectricCar("buyelectriccar", this, preferences));
            behaviouralOptions.add(new SellMyCar("sellmycar", this, preferences));
    

    Finally, memorise them.
    getLaraComp().getBOMemory().memoriseAll(behaviouralOptions);

    The problem that I have is that in the next iterations, when computing the scores for the BOs, it keeps doing it with the old values of the preference weight.

    Could you help on me on this? That is, how to make the new values be used for computing the new scores for the BOs?

    Thanks.

     
  • Holzhauer

    Holzhauer - 2015-12-16

    First, one needs to distinguish between BO preference utilities (that represent a BO's utlity towards defined preferences and usually differ from BO to BO) and agents' preferences. In the above example, the same set of preference utilities is assigned to all BOs, which is unlikely what is wanted. To assign the altered set of preferences to an agent, call getLaraComp().addPreferenceWeights(preferences);

    Manipulating the map that is returned by getLaraComp().getPreferenceWeights(); has no effect on its own since the method returns a copy of the underlying agent's preference map. Hope that helps!

     
  • Anonymous

    Anonymous - 2015-12-16

    Thanks! It works.

    But I would have another question: it is necessary to clear the BO memory before updating and set a new Set for the behavioural options so the BO memory memorizes it?

    that is, as you see above,

    1)
    getLaraComp().getBOMemory().clear();

    2)

                        Set<AbstractConsumerBehaviouralOption<ConsumerAgent>> behaviouralOptions = new HashSet<AbstractConsumerBehaviouralOption<ConsumerAgent>>();
    
            behaviouralOptions.add(new DoNothing("donothing", this, preferences));
            behaviouralOptions.add(new BuyConventionalCar("buyconventionalcar", this, preferences));
            behaviouralOptions.add(new BuyHybridCar("buyhybridcar", this, preferences));
            behaviouralOptions.add(new BuyElectricCar("buyelectriccar", this, preferences));
            behaviouralOptions.add(new SellMyCar("sellmycar", this, preferences));
            getLaraComp().getBOMemory().memoriseAll(behaviouralOptions);
    

    Thanks again!

     
  • Holzhauer

    Holzhauer - 2015-12-16

    Usually one does not have to clear the memory in order to update objects within. Rather, the proper type of memory (unfortunately they are not yet documented very well) should be used to accomplish the desired behaviour. In your case, the LDefaultLimitedCapacityOverwriteBoMemory would overwrite the BO with the same key when you memorise an updated BO.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.