RelativeEffectArgumentMaker implements ArgumentMaker { public double[] getArgument(double[][] data) { double[] x = data[d_bIdx]; if (d_wIdx >= 0) { x = new double[data[d_bIdx].length + data[d_wIdx].length]; System.arraycopy(data[d_bIdx], 0, x, 0, data[d_bIdx].length); System.arraycopy(data[d_wIdx], 0, x, data[d_bIdx].length, data[d_wIdx].length); } return d_matrix.operate(x); } RelativeEffectArgumentMaker(Parameterization pmtz, Study study, int bIdx, int wIdx); double[] getArgument(double[][] data);  }
@Test public void testGetArgumentConsistency() { double[] input = new double[] {-1.0, 1.0, 3.0}; double[] expected1 = new double[] {-1.0}; double[] expected2 = new double[] {3.0, 2.0}; double[] expected3 = new double[] {1.0}; double[] expected4 = new double[] {-1.0}; RelativeEffectArgumentMaker maker1a = new RelativeEffectArgumentMaker(d_consPmtz, d_s1, 0, -1); assertArrayEquals(expected1, maker1a.getArgument(new double[][] {input}), EPSILON); RelativeEffectArgumentMaker maker1b = new RelativeEffectArgumentMaker(d_consPmtz, d_s1, 1, -1); assertArrayEquals(expected1, maker1b.getArgument(new double[][] {null, input}), EPSILON); RelativeEffectArgumentMaker maker2 = new RelativeEffectArgumentMaker(d_consPmtz, d_s2, 0, -1); assertArrayEquals(expected2, maker2.getArgument(new double[][] {input}), EPSILON); RelativeEffectArgumentMaker maker3 = new RelativeEffectArgumentMaker(d_consPmtz, d_s3, 0, -1); assertArrayEquals(expected3, maker3.getArgument(new double[][] {input}), EPSILON); RelativeEffectArgumentMaker maker4 = new RelativeEffectArgumentMaker(d_consPmtz, d_s4, 0, -1); assertArrayEquals(expected4, maker4.getArgument(new double[][] {input}), EPSILON); }
@Test public void testGetArgumentInconsistency() { double[] basic = new double[] {-1.0, 1.0, 3.0}; double[] incons = new double[] {-0.5, 0.5}; double[] expected1 = new double[] {-1.0}; double[] expected2 = new double[] {3.0, 2.5}; double[] expected3 = new double[] {1.0}; double[] expected4 = new double[] {-1.5}; RelativeEffectArgumentMaker maker1a = new RelativeEffectArgumentMaker(d_incoPmtz, d_s1, 0, 1); assertArrayEquals(expected1, maker1a.getArgument(new double[][] {basic, incons}), EPSILON); RelativeEffectArgumentMaker maker1b = new RelativeEffectArgumentMaker(d_incoPmtz, d_s1, 2, 1); assertArrayEquals(expected1, maker1b.getArgument(new double[][] {null, incons, basic}), EPSILON); RelativeEffectArgumentMaker maker2 = new RelativeEffectArgumentMaker(d_incoPmtz, d_s2, 0, 1); assertArrayEquals(expected2, maker2.getArgument(new double[][] {basic, incons}), EPSILON); RelativeEffectArgumentMaker maker3 = new RelativeEffectArgumentMaker(d_incoPmtz, d_s3, 0, 1); assertArrayEquals(expected3, maker3.getArgument(new double[][] {basic, incons}), EPSILON); RelativeEffectArgumentMaker maker4 = new RelativeEffectArgumentMaker(d_incoPmtz, d_s4, 0, 1); assertArrayEquals(expected4, maker4.getArgument(new double[][] {basic, incons}), EPSILON); }
@Test public void testGetArgumentInconsistencyNone() { Network network = new Network(); network.getTreatments().addAll(d_s1.getTreatments()); network.getStudies().add(d_s1); InconsistencyParameterization pmtz = InconsistencyParameterization.create(network); double[] basic = new double[] {-1.0}; double[] incons = new double[] {}; RelativeEffectArgumentMaker maker0 = new RelativeEffectArgumentMaker(pmtz, d_s1, 0, 1); assertArrayEquals(basic, maker0.getArgument(new double[][] {basic, incons}), EPSILON); }