Ignore:
Timestamp:
12/18/24 13:28:59 (4 days ago)
Author:
ruud
Message:

All TimeDependent parties now support the nonlinear SumOfGroupsUtilitySpace. Example Nonlinear space in the computer domain

Location:
exampleparties/timedependentparty/src/test
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • exampleparties/timedependentparty/src/test/java/geniusweb/exampleparties/timedependentparty/ExtendedUtilSpaceTest.java

    r52 r53  
    11package geniusweb.exampleparties.timedependentparty;
    22
    3 import static org.junit.Assert.assertTrue;
     3import static org.junit.Assert.assertEquals;
    44
    55import java.io.IOException;
    6 import java.math.BigDecimal;
    76import java.nio.file.Files;
    87import java.nio.file.Paths;
     
    1918
    2019import geniusweb.profile.Profile;
    21 import geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace;
     20import geniusweb.profile.utilityspace.UtilitySpace;
    2221
    2322@RunWith(Parameterized.class)
    2423public class ExtendedUtilSpaceTest {
    2524        private final static ObjectMapper jackson = new ObjectMapper();
    26         private final static BigDecimal SMALL = new BigDecimal("0.0001");
     25        private final static double SMALL = 0.0001;
    2726
    2827        @Parameters
     
    3130                                { "src/test/resources/jobs/jobs1.json", 0.02 },
    3231                                { "src/test/resources/7issues/7issues1.json", 0.0055 },
    33                                 { "src/test/resources/9issues/9issues1.json", 0.0013 } });
     32                                { "src/test/resources/9issues/9issues1.json", 0.0013 },
     33                                // tolerance in computerbuy is quite small because approximation
     34                                // scales the space
     35                                { "src/test/resources/computer/computerbuy.json", 0.0016 } });
    3436        }
    3537
    3638        private String filename;
    37         private BigDecimal expectedTolerance;
     39        private double expectedTolerance;
    3840        private ExtendedUtilSpace space;
    3941
    4042        public ExtendedUtilSpaceTest(String filename, double expectedTolerance) {
    4143                this.filename = filename;
    42                 this.expectedTolerance = BigDecimal.valueOf(expectedTolerance);
     44                this.expectedTolerance = expectedTolerance;
    4345        }
    4446
     
    4648        public void before() throws IOException {
    4749                String file = new String(Files.readAllBytes(Paths.get(filename)));
    48                 LinearAdditiveUtilitySpace profile = (LinearAdditiveUtilitySpace) jackson
    49                                 .readValue(file, Profile.class);
     50                UtilitySpace profile = (UtilitySpace) jackson.readValue(file,
     51                                Profile.class);
    5052                space = new ExtendedUtilSpace(profile);
    5153        }
     
    5860        @Test
    5961        public void testTolerance() {
    60                 assertTrue(space.computeTolerance().subtract(expectedTolerance).abs()
    61                                 .compareTo(SMALL) < 0);
     62                assertEquals(expectedTolerance, space.computeTolerance().doubleValue(),
     63                                SMALL);
    6264        }
    6365}
Note: See TracChangeset for help on using the changeset viewer.