-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutomatedSetup.java
More file actions
83 lines (69 loc) · 2.48 KB
/
AutomatedSetup.java
File metadata and controls
83 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class AutomatedSetup {
private int numNodes = 0;
private int width = 0;
private int length = 0;
private int transmissionRange = 0;
private int minPackets = 0;
private int maxPackets = 0;
private double battery = 0.0;
List<Node> nodeList;
public AutomatedSetup() {}
public void setVariables(){
// Getting user input
Scanner scan = new Scanner(System.in);
System.out.println("Please enter width of sensor network:");
width = scan.nextInt();
System.out.println("Please enter length of sensor network:");
length = scan.nextInt();
System.out.println("Please enter number of nodes in sensor network:");
numNodes = scan.nextInt();
System.out.println("Please enter transmission range:");
transmissionRange = scan.nextInt();
System.out.println("Please enter maximum number of data packets per node:");
maxPackets = scan.nextInt();
System.out.println("Please enter minimum number of data packets per node:");
minPackets = scan.nextInt();
System.out.println("Please enter the amount of battery attributed to robot in watts");
battery = scan.nextDouble();
scan.close();
}
public ListGraph createNetwork() {
ListGraph graph = new ListGraph(numNodes);
// Existing network creation logic
nodeList = new ArrayList<>(numNodes);
for (int i = 1; i <= numNodes; i++) {
Node newNode = new Node(i, width, length, minPackets, maxPackets);
nodeList.add(newNode);
}
for (int i = 0; i < numNodes; i++) {
for (int j = i + 1; j < numNodes; j++) {
if (nodeList.get(i).getDistance(nodeList.get(j)) <= transmissionRange) {
graph.addEdge(nodeList.get(i), nodeList.get(j));
}
}
}
for (int i = 1; i <= numNodes; i++) {
int prize = graph.calculatePrize(i, true);
Node node = Node.getNodeById(i);
node.setPrize(prize);
}
return graph;
}
public Robot createRobot(){
Robot robot = new Robot(battery, nodeList);
robot.setFeasibleNodes();
return robot;
}
public List<Node> getNodeList(){
return nodeList;
}
public int getWidth(){
return width;
}
public int getLength(){
return length;
}
}