Changeset 8 for exampleparties
- Timestamp:
- 09/30/19 15:37:05 (5 years ago)
- Location:
- exampleparties
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
exampleparties/randomparty/src/test/java/geniusweb/exampleparties/randomparty/RandomPartyTest.java
r1 r8 44 44 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 45 45 import geniusweb.progress.ProgressRounds; 46 import geniusweb.references.Parameters; 46 47 import geniusweb.references.ProfileRef; 47 48 import geniusweb.references.ProtocolRef; … … 58 59 59 60 private RandomParty party; 60 private TestConnection connection = new TestConnection();61 private ProtocolRef protocol = mock(ProtocolRef.class);62 private ProgressRounds progress = mock(ProgressRounds.class);61 private final TestConnection connection = new TestConnection(); 62 private final ProtocolRef protocol = mock(ProtocolRef.class); 63 private final ProgressRounds progress = mock(ProgressRounds.class); 63 64 private Settings settings; 64 65 private LinearAdditiveUtilitySpace profile; 66 private final Parameters parameters = new Parameters(); 65 67 66 68 @Before … … 69 71 party = new RandomParty(); 70 72 settings = new Settings(new PartyId("party1"), 71 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress); 73 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress, 74 parameters); 72 75 73 76 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), -
exampleparties/randompartypy/src/test/java/geniusweb/exampleparties/randompartypy/RandomPartyTest.java
r1 r8 42 42 import geniusweb.progress.ProgressRounds; 43 43 import geniusweb.pythonadapter.PythonPartyAdapter; 44 import geniusweb.references.Parameters; 44 45 import geniusweb.references.ProfileRef; 45 46 import geniusweb.references.ProtocolRef; … … 56 57 private PythonPartyAdapter party; 57 58 private TestConnection connection = new TestConnection(); 58 private ProtocolRef protocol = mock(ProtocolRef.class);59 private ProgressRounds progress = mock(ProgressRounds.class);59 private final ProtocolRef protocol = mock(ProtocolRef.class); 60 private final ProgressRounds progress = mock(ProgressRounds.class); 60 61 private Settings settings; 62 private final Parameters parameters = new Parameters(); 61 63 62 64 private LinearAdditiveUtilitySpace profile; // the real profile … … 74 76 }; 75 77 settings = new Settings(new PartyId("party1"), 76 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress); 78 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress, 79 parameters); 77 80 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)), 78 81 StandardCharsets.UTF_8); -
exampleparties/timedependentparty/pom.xml
r6 r8 171 171 </executions> 172 172 </plugin> 173 174 <plugin> 175 <groupId>org.apache.maven.plugins</groupId> 176 <artifactId>maven-jar-plugin</artifactId> 177 <configuration> 178 <archive> 179 <manifest> 180 <mainClass>geniusweb.exampleparties.timedependentparty.TimeDependentParty</mainClass> 181 </manifest> 182 </archive> 183 </configuration> 184 </plugin> 173 185 174 186 <plugin> … … 212 224 </plugin> 213 225 214 226 <plugin> 227 <groupId>org.apache.maven.plugins</groupId> 228 <artifactId>maven-assembly-plugin</artifactId> 229 <version>2.4.1</version> 230 <configuration> 231 <!-- get all project dependencies --> 232 <descriptorRefs> 233 <descriptorRef>jar-with-dependencies</descriptorRef> 234 </descriptorRefs> 235 <archive> 236 <manifest> 237 <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 238 <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> 239 <mainClass>geniusweb.exampleparties.timedependentparty.TimeDependentParty</mainClass> 240 </manifest> 241 </archive> 242 </configuration> 243 <executions> 244 <execution> 245 <id>make-assembly</id> 246 <!-- bind to the packaging phase --> 247 <phase>package</phase> 248 <goals> 249 <goal>single</goal> 250 </goals> 251 </execution> 252 </executions> 253 </plugin> 215 254 216 255 </plugins> -
exampleparties/timedependentparty/src/main/java/geniusweb/exampleparties/timedependentparty/TimeDependentParty.java
r4 r8 39 39 * on bidspaces > 10000 bids. In special cases it may even run out of memory, 40 40 */ 41 public abstractclass TimeDependentParty extends DefaultParty {41 public class TimeDependentParty extends DefaultParty { 42 42 43 43 private static final BigDecimal DEC0001 = new BigDecimal("0.0001"); … … 49 49 private Bid lastReceivedBid = null; 50 50 private ExtendedUtilSpace extendedspace; 51 private double e = 1.2; 51 52 52 53 public TimeDependentParty() { … … 79 80 this.me = settings.getID(); 80 81 this.progress = settings.getProgress(); 82 Object newe = settings.getParemeters().get("e"); 83 if (newe != null) { 84 if (newe instanceof Double) { 85 this.e = (Double) newe; 86 } else { 87 getReporter().log(Level.WARNING, 88 "parameter e should be Double but found " 89 + newe); 90 } 91 } 92 81 93 } else if (info instanceof ActionDone) { 82 94 Action otheract = ((ActionDone) info).getAction(); … … 113 125 * 4. When e = 0, the agent plays hardball. 114 126 */ 115 public abstract double getE(); 127 public double getE() { 128 return e; 129 } 116 130 117 131 /******************* private support funcs ************************/ … … 177 191 .min(maxUtil).max(minUtil); 178 192 } 193 194 @Override 195 public String getDescription() { 196 return "Time-dependent conceder. Aims at utility u(t) = scale * t^(1/e) " 197 + "where t is the time (0=start, 1=end), e is a parameter (default 1.1), and scale such that u(0)=minimum and " 198 + "u(1) = maximum possible utility. "; 199 } 179 200 } -
exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/TimeDependentPartyTest.java
r3 r8 44 44 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace; 45 45 import geniusweb.progress.ProgressRounds; 46 import geniusweb.references.Parameters; 46 47 import geniusweb.references.ProfileRef; 47 48 import geniusweb.references.ProtocolRef; … … 61 62 private ProtocolRef protocol = mock(ProtocolRef.class); 62 63 private ProgressRounds progress = mock(ProgressRounds.class); 64 private Parameters parameters = new Parameters(); 63 65 private Settings settings; 64 66 private LinearAdditiveUtilitySpace profile; … … 80 82 }; 81 83 settings = new Settings(new PartyId("party1"), 82 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress); 84 new ProfileRef(new URI("file:" + PROFILE)), protocol, progress, 85 parameters); 83 86 84 87 String serialized = new String(Files.readAllBytes(Paths.get(PROFILE)),
Note:
See TracChangeset
for help on using the changeset viewer.