/** * Vector addition of this and other {@link ResourceRequirement}. */ public void add(ResourceRequirement other) { VectorAlgebra.addVector(this.resourceVector, other.resourceVector, 1., this.resourceVector); }
/** * @return true if input {@link ResourceRequirement} exceeds the hard bound long any dimension. If the parameter * orEqual is true, then matching along any dimension will also return true. */ public boolean exceedsHardBound(ResourceRequirement requirement, boolean orEqual) { return VectorAlgebra.exceedsVector(this.hardBound, requirement.getResourceVector(), orEqual); }
/** * Vector addition of this and other {@link ResourceRequirement}. */ public void subtract(ResourceRequirement other) { VectorAlgebra.addVector(this.resourceVector, other.resourceVector, -1., this.resourceVector); }
/** * @return true if input {@link ResourceRequirement} exceeds the soft bound long any dimension. If the parameter * orEqual is true, then matching along any dimension will also return true. */ public boolean exceedsSoftBound(ResourceRequirement requirement, boolean orEqual) { return VectorAlgebra.exceedsVector(this.softBound, requirement.getResourceVector(), orEqual); }
/** * @return a new {@link ResourcePool} which is a copy of this {@link ResourcePool} except its resource vector has been * reduced by the input {@link ResourceRequirement}. */ protected ResourcePool contractPool(ResourceRequirement requirement) { return new ResourcePool(VectorAlgebra.addVector(this.softBound, requirement.getResourceVector(), -1., null), VectorAlgebra.addVector(this.hardBound, requirement.getResourceVector(), -1., null), this.defaultResourceUse, this.dimensionIndex); }
@Test public void testExceedsVector() throws Exception { Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 3}, false)); Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{2, 0}, false)); Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 2}, true)); Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{1, 0}, true)); Assert.assertFalse(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 1}, false)); Assert.assertFalse(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{1, 2}, false)); } }
@Test public void testAddVector() throws Exception { Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, 1., null), new double[]{2, 5}); Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, 2., null), new double[]{3, 8}); Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, -1., null), new double[]{0, -1}); // Check it uses reuse vector double[] reuse = new double[]{1, 2}; VectorAlgebra.addVector(reuse, new double[]{1, 3}, 1., reuse); Assert.assertEquals(reuse, new double[]{2, 5}); }
/** * @return true if input {@link ResourceRequirement} exceeds the soft bound long any dimension. If the parameter * orEqual is true, then matching along any dimension will also return true. */ public boolean exceedsSoftBound(ResourceRequirement requirement, boolean orEqual) { return VectorAlgebra.exceedsVector(this.softBound, requirement.getResourceVector(), orEqual); }
public static ResourceRequirement add(ResourceRequirement r1, ResourceRequirement r2, ResourceRequirement reuse) { if (reuse == null) { reuse = new ResourceRequirement(r1.resourceVector.clone()); } VectorAlgebra.addVector(r1.resourceVector, r2.resourceVector, 1., reuse.resourceVector); return reuse; }
/** * @return true if input {@link ResourceRequirement} exceeds the hard bound long any dimension. If the parameter * orEqual is true, then matching along any dimension will also return true. */ public boolean exceedsHardBound(ResourceRequirement requirement, boolean orEqual) { return VectorAlgebra.exceedsVector(this.hardBound, requirement.getResourceVector(), orEqual); }
@Override public T next() { RequestWithResourceRequirement<T> nextElement = this.underlying.next(); VectorAlgebra.addVector(this.currentRequirement, nextElement.getResourceRequirement().getResourceVector(), 1.0, this.currentRequirement); return nextElement.getT(); }
/** * Vector addition of this and other {@link ResourceRequirement}. */ public void subtract(ResourceRequirement other) { VectorAlgebra.addVector(this.resourceVector, other.resourceVector, -1., this.resourceVector); }
/** * Vector addition of this and other {@link ResourceRequirement}. */ public void add(ResourceRequirement other) { VectorAlgebra.addVector(this.resourceVector, other.resourceVector, 1., this.resourceVector); }
/** * @return a new {@link ResourcePool} which is a copy of this {@link ResourcePool} except its resource vector has been * reduced by the input {@link ResourceRequirement}. */ protected ResourcePool contractPool(ResourceRequirement requirement) { return new ResourcePool(VectorAlgebra.addVector(this.softBound, requirement.getResourceVector(), -1., null), VectorAlgebra.addVector(this.hardBound, requirement.getResourceVector(), -1., null), this.defaultResourceUse, this.dimensionIndex); }
public static ResourceRequirement add(ResourceRequirement r1, ResourceRequirement r2, ResourceRequirement reuse) { if (reuse == null) { reuse = new ResourceRequirement(r1.resourceVector.clone()); } VectorAlgebra.addVector(r1.resourceVector, r2.resourceVector, 1., reuse.resourceVector); return reuse; }
@Override public T next() { RequestWithResourceRequirement<T> nextElement = this.underlying.next(); VectorAlgebra.addVector(this.currentRequirement, nextElement.getResourceRequirement().getResourceVector(), 1.0, this.currentRequirement); return nextElement.getT(); }