From a1ebf36af551d6aeb06b559d98b7fa9cae9d66a4 Mon Sep 17 00:00:00 2001 From: gstamatakis Date: Sat, 30 Dec 2017 21:37:31 +0200 Subject: [PATCH] New agent added. --- javadoc/AgentCore/AgentAPI.html | 2 +- javadoc/AgentCore/ThrashAgent.html | 2 +- javadoc/Core/AgentAPI.html | 2 +- javadoc/Core/ThrashAgent.html | 2 +- javadoc/TimeAgent.html | 18 +++---- javadoc/allclasses-frame.html | 2 +- javadoc/allclasses-noframe.html | 2 +- javadoc/index-files/index-10.html | 4 +- javadoc/index-files/index-15.html | 4 +- javadoc/index-files/index-4.html | 20 ++++---- javadoc/overview-tree.html | 2 +- javadoc/package-frame.html | 2 +- javadoc/package-summary.html | 2 +- javadoc/package-tree.html | 2 +- javadoc/serialized-form.html | 2 +- src/BestAgent.java | 4 +- src/BestAgentWithoutMem.java | 2 +- src/Core/BidHistory.java | 18 ++----- src/Core/BidStrategy.java | 4 +- src/TimeAgent.java | 4 +- src/TimeAgentWithoutMem.java | 79 ++++++++++++++++++++++++++++++ 21 files changed, 126 insertions(+), 53 deletions(-) create mode 100644 src/TimeAgentWithoutMem.java diff --git a/javadoc/AgentCore/AgentAPI.html b/javadoc/AgentCore/AgentAPI.html index 0d00135..354db60 100644 --- a/javadoc/AgentCore/AgentAPI.html +++ b/javadoc/AgentCore/AgentAPI.html @@ -100,7 +100,7 @@

Interface AgentAPI

  • All Known Implementing Classes:
    -
    ThrashAgent, BestAgent, TimeAgent
    +
    ThrashAgent, BestAgent, TimeAgentWithoutMem


    diff --git a/javadoc/AgentCore/ThrashAgent.html b/javadoc/AgentCore/ThrashAgent.html index b1b10cc..bf0a80a 100644 --- a/javadoc/AgentCore/ThrashAgent.html +++ b/javadoc/AgentCore/ThrashAgent.html @@ -117,7 +117,7 @@

    Class ThrashAgent

    Direct Known Subclasses:
    -
    BestAgent, TimeAgent
    +
    BestAgent, TimeAgentWithoutMem


    diff --git a/javadoc/Core/AgentAPI.html b/javadoc/Core/AgentAPI.html index e281b81..b53bece 100644 --- a/javadoc/Core/AgentAPI.html +++ b/javadoc/Core/AgentAPI.html @@ -100,7 +100,7 @@

    Interface AgentAPI

  • All Known Implementing Classes:
    -
    BestAgent, ThrashAgent, Thresh1, TimeAgent
    +
    BestAgent, ThrashAgent, Thresh1, TimeAgentWithoutMem


    diff --git a/javadoc/Core/ThrashAgent.html b/javadoc/Core/ThrashAgent.html index f1d6edf..0f900df 100644 --- a/javadoc/Core/ThrashAgent.html +++ b/javadoc/Core/ThrashAgent.html @@ -117,7 +117,7 @@

    Class ThrashAgent

    Direct Known Subclasses:
    -
    BestAgent, Thresh1, TimeAgent
    +
    BestAgent, Thresh1, TimeAgentWithoutMem


    diff --git a/javadoc/TimeAgent.html b/javadoc/TimeAgent.html index b808dd0..65c16d0 100644 --- a/javadoc/TimeAgent.html +++ b/javadoc/TimeAgent.html @@ -3,7 +3,7 @@ -TimeAgent +TimeAgentWithoutMem @@ -52,7 +52,7 @@
  • Next Class
  • diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index b47ed66..a9c25ee 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -26,7 +26,7 @@

    All Classes

  • StrategyEnum
  • ThrashAgent
  • Thresh1
  • -
  • TimeAgent
  • +
  • TimeAgentWithoutMem
  • ValFreqEnum
  • diff --git a/javadoc/index-files/index-10.html b/javadoc/index-files/index-10.html index 062095c..36f00fb 100644 --- a/javadoc/index-files/index-10.html +++ b/javadoc/index-files/index-10.html @@ -83,9 +83,9 @@

    T

     
    Thresh1() - Constructor for class Thresh1
     
    -
    TimeAgent - Class in <Unnamed>
    +
    TimeAgentWithoutMem - Class in <Unnamed>
     
    -
    TimeAgent() - Constructor for class TimeAgent
    +
    TimeAgentWithoutMem() - Constructor for class TimeAgentWithoutMem
     
    A B C G I N O R S T U V  diff --git a/javadoc/index-files/index-15.html b/javadoc/index-files/index-15.html index d094e03..3a1f788 100644 --- a/javadoc/index-files/index-15.html +++ b/javadoc/index-files/index-15.html @@ -91,9 +91,9 @@

    T

     
    BestAgent() - Constructor for class BestAgent
     
    -
    TimeAgent - Class in <Unnamed>
    +
    TimeAgentWithoutMem - Class in <Unnamed>
     
    -
    TimeAgent() - Constructor for class TimeAgent
    +
    TimeAgentWithoutMem() - Constructor for class TimeAgentWithoutMem
     
    TimeBidHistory - Variable in class AgentCore.Opponent
     
    diff --git a/javadoc/index-files/index-4.html b/javadoc/index-files/index-4.html index bfd433e..2cc1ab1 100644 --- a/javadoc/index-files/index-4.html +++ b/javadoc/index-files/index-4.html @@ -81,7 +81,7 @@

    G

    getAgentStrategy() - Method in class Thresh1
     
    -
    getAgentStrategy() - Method in class TimeAgent
    +
    getAgentStrategy() - Method in class TimeAgentWithoutMem
     
    getBidHistory() - Method in class Bad.BadOpponent
     
    @@ -93,7 +93,7 @@

    G

    getBidUtilThreshold() - Method in class Thresh1
     
    -
    getBidUtilThreshold() - Method in class TimeAgent
    +
    getBidUtilThreshold() - Method in class TimeAgentWithoutMem
     
    getCool() - Method in class Utils.SimulatedAnnealingParams
     
    @@ -105,7 +105,7 @@

    G

    getCutoffValue() - Method in class Thresh1
     
    -
    getCutoffValue() - Method in class TimeAgent
    +
    getCutoffValue() - Method in class TimeAgentWithoutMem
     
    getDescription() - Method in class BadAgentImpl
     
    @@ -113,7 +113,7 @@

    G

     
    getDescription() - Method in class Thresh1
     
    -
    getDescription() - Method in class TimeAgent
    +
    getDescription() - Method in class TimeAgentWithoutMem
     
    getEndTemperature() - Method in class Utils.SimulatedAnnealingParams
     
    @@ -125,7 +125,7 @@

    G

    getFrequencyValueSelection() - Method in class Thresh1
     
    -
    getFrequencyValueSelection() - Method in class TimeAgent
    +
    getFrequencyValueSelection() - Method in class TimeAgentWithoutMem
     
    getMaxBid() - Method in class Core.BidStrategy
     
    @@ -137,7 +137,7 @@

    G

    getRand() - Method in class Thresh1
     
    -
    getRand() - Method in class TimeAgent
    +
    getRand() - Method in class TimeAgentWithoutMem
     
    getSearchingMethod() - Method in class BestAgent
     
    @@ -147,7 +147,7 @@

    G

    getSearchingMethod() - Method in class Thresh1
     
    -
    getSearchingMethod() - Method in class TimeAgent
    +
    getSearchingMethod() - Method in class TimeAgentWithoutMem
     
    getSimulatedAnnealingParams() - Method in class BestAgent
     
    @@ -157,7 +157,7 @@

    G

    getSimulatedAnnealingParams() - Method in class Thresh1
     
    -
    getSimulatedAnnealingParams() - Method in class TimeAgent
    +
    getSimulatedAnnealingParams() - Method in class TimeAgentWithoutMem
     
    getStartTemperature() - Method in class Utils.SimulatedAnnealingParams
     
    @@ -171,7 +171,7 @@

    G

    getTimeScalingFactor() - Method in class Thresh1
     
    -
    getTimeScalingFactor() - Method in class TimeAgent
    +
    getTimeScalingFactor() - Method in class TimeAgentWithoutMem
     
    getVetoVal() - Method in class BestAgent
     
    @@ -181,7 +181,7 @@

    G

    getVetoVal() - Method in class Thresh1
     
    -
    getVetoVal() - Method in class TimeAgent
    +
    getVetoVal() - Method in class TimeAgentWithoutMem
     
    A B C G I N O R S T U V  diff --git a/javadoc/overview-tree.html b/javadoc/overview-tree.html index 91ecf48..f715b3f 100644 --- a/javadoc/overview-tree.html +++ b/javadoc/overview-tree.html @@ -93,7 +93,7 @@

    Class Hierarchy

    diff --git a/javadoc/package-frame.html b/javadoc/package-frame.html index e18eb78..0d496fa 100644 --- a/javadoc/package-frame.html +++ b/javadoc/package-frame.html @@ -16,7 +16,7 @@

    Classes

  • BadAgentImpl
  • BestAgent
  • Thresh1
  • -
  • TimeAgent
  • +
  • TimeAgentWithoutMem
  • diff --git a/javadoc/package-summary.html b/javadoc/package-summary.html index 72c992b..30e3303 100644 --- a/javadoc/package-summary.html +++ b/javadoc/package-summary.html @@ -83,7 +83,7 @@

    Package <Unnamed>

      -TimeAgent +TimeAgentWithoutMem   diff --git a/javadoc/package-tree.html b/javadoc/package-tree.html index 1687823..0fe0ab1 100644 --- a/javadoc/package-tree.html +++ b/javadoc/package-tree.html @@ -91,7 +91,7 @@

    Class Hierarchy

    diff --git a/javadoc/serialized-form.html b/javadoc/serialized-form.html index 0f0288e..26ad020 100644 --- a/javadoc/serialized-form.html +++ b/javadoc/serialized-form.html @@ -94,7 +94,7 @@

    Class Thresh1 ex
  • -

    Class TimeAgent extends ThrashAgent implements Serializable

    +

    Class TimeAgentWithoutMem extends ThrashAgent implements Serializable

  • diff --git a/src/BestAgent.java b/src/BestAgent.java index db05f02..5afd38d 100644 --- a/src/BestAgent.java +++ b/src/BestAgent.java @@ -66,7 +66,7 @@ public boolean useHistory() { @Override public double getSoftConcessionThreshold() { - return 0.9; + return 0.70; } @Override @@ -76,7 +76,7 @@ public double getConcessionThreshold() { @Override public int getMemoryDepth() { - return 1; + return 3; } @Override diff --git a/src/BestAgentWithoutMem.java b/src/BestAgentWithoutMem.java index 0a9b2de..2b6cb12 100644 --- a/src/BestAgentWithoutMem.java +++ b/src/BestAgentWithoutMem.java @@ -71,7 +71,7 @@ public double getSoftConcessionThreshold() { @Override public double getConcessionThreshold() { - return 0.98; + return 0.99; } @Override diff --git a/src/Core/BidHistory.java b/src/Core/BidHistory.java index 63301fb..e04baba 100644 --- a/src/Core/BidHistory.java +++ b/src/Core/BidHistory.java @@ -2,20 +2,16 @@ import list.Tuple; import negotiator.AgentID; -import negotiator.Bid; import negotiator.parties.NegotiationInfo; import negotiator.persistent.StandardInfoList; import negotiator.persistent.StandardInfo; import negotiator.persistent.PersistentDataContainer; -import java.time.Instant; -import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Random; import static Core.ThrashAgent.MemoryDepth; -import static Core.ThrashAgent.bidHistory; import static Core.ThrashAgent.gLog; public class BidHistory { @@ -85,6 +81,10 @@ public Map getWorstOfferedUtils() { return this.worstOfferedUtils; } + public Map> getAcceptedUtils() { + return this.acceptedUtils; + } + public void setBestOppVals(Opponent opponent, AgentID sender) { try { opponent.BestOfferUtil = bestOfferedUtils.getOrDefault(sender.getName().split("@")[0], null); @@ -94,14 +94,6 @@ public void setBestOppVals(Opponent opponent, AgentID sender) { } public double getLuckyValue(AgentID partyId) { - double val = 1.0; - try { - for (int i : acceptedUtils.get(partyId.getName()).keySet()) { - val = Math.min(acceptedUtils.get(partyId.getName()).get(i), val); - } - } catch (Exception ignored) { - } - gLog.println("Lucky val for " + partyId.getName() + ": " + val); - return 1.0; + return getBestOfferedUtils().getOrDefault(partyId.getName(), 1.0); } } diff --git a/src/Core/BidStrategy.java b/src/Core/BidStrategy.java index 42a01d5..8b057bd 100644 --- a/src/Core/BidStrategy.java +++ b/src/Core/BidStrategy.java @@ -88,10 +88,12 @@ private double targetEnd(double time) { if (useHistory) { try { Map bests = bidHistory.getBestOfferedUtils(); + int cnt = 0; for (String val : bests.keySet()) { weightedAverage += bests.get(val); + cnt++; } - return weightedAverage; + return weightedAverage / cnt; } catch (Exception ignored) { } } diff --git a/src/TimeAgent.java b/src/TimeAgent.java index 57c45f1..b808234 100644 --- a/src/TimeAgent.java +++ b/src/TimeAgent.java @@ -54,7 +54,7 @@ public double getVetoVal() { @Override public boolean useHistory() { - return false; + return true; } @Override @@ -69,7 +69,7 @@ public double getSoftConcessionThreshold() { @Override public int getMemoryDepth() { - return 3; + return 1; } @Override diff --git a/src/TimeAgentWithoutMem.java b/src/TimeAgentWithoutMem.java new file mode 100644 index 0000000..e919618 --- /dev/null +++ b/src/TimeAgentWithoutMem.java @@ -0,0 +1,79 @@ +import Core.ThrashAgent; +import Utils.SearchMethodEnum; +import Utils.SimulatedAnnealingParams; +import Utils.StrategyEnum; +import Utils.ValFreqEnum; + +import java.util.Random; + +public class TimeAgentWithoutMem extends ThrashAgent { + @Override + public Random getRand() { + return new Random(); + } + + @Override + public StrategyEnum getAgentStrategy() { + return StrategyEnum.Time; + } + + @Override + public SearchMethodEnum getSearchingMethod() { + return SearchMethodEnum.SimulatedAnnealing; + } + + @Override + public ValFreqEnum getFrequencyValueSelection() { + return ValFreqEnum.ValueFreq; + } + + @Override + public SimulatedAnnealingParams getSimulatedAnnealingParams() { + return new SimulatedAnnealingParams(); + } + + @Override + public double getBidUtilThreshold() { + return 0.99; + } + + @Override + public double getTimeScalingFactor() { + return 1; + } + + @Override + public double getCutoffValue() { + return 1e-6; + } + + @Override + public double getVetoVal() { + return 0; + } + + @Override + public boolean useHistory() { + return false; + } + + @Override + public double getConcessionThreshold() { + return 0.98; + } + + @Override + public double getSoftConcessionThreshold() { + return 0.9; + } + + @Override + public int getMemoryDepth() { + return 3; + } + + @Override + public String getDescription() { + return "Ti SA Std"; + } +}