Commit 66612d42 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Enable a GridPositionDistribution with larger grids than actual nodes

(used for #cloudlet-evaluation)
parent ba6730d6
......@@ -46,6 +46,12 @@ public class GridPositionDistribution implements PlacementModel {
private int placedComponents = 0;
private PositionVector worldDimensions = null;
/**
* Allows us to create a "larger" grid, even if we only have a smaller number of nodes.
* Eg., create a 3*3 grid for only 2 nodes
*/
private int fakeNumberOfComponents = -1;
private Random random = Randoms
.getRandom(GridPositionDistribution.class);
......@@ -73,8 +79,15 @@ public class GridPositionDistribution implements PlacementModel {
public void setRandomOffset(boolean randInCell) {
this.randInCell = randInCell;
}
public void setFakeNumberOfComponents(int fakeNumberOfComponents) {
this.fakeNumberOfComponents = fakeNumberOfComponents;
}
private void calcPositions2D() {
if (fakeNumberOfComponents != -1) {
numberOfComponents = fakeNumberOfComponents;
}
float ratio = (float) (worldDimensions.getX() / worldDimensions.getY());
float ratio_1 = 1 / ratio;
int anz_x = (int) Math.ceil(Math.sqrt(ratio * numberOfComponents));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment