Skip to content

Commit 6dab551

Browse files
committed
some small improvements
1 parent 44b606c commit 6dab551

File tree

6 files changed

+13
-32
lines changed

6 files changed

+13
-32
lines changed

include/dmsc/edge.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class InterSatelliteLink {
125125
float getMaxAngle() const { return max_angle; }
126126
const Satellite& getV1() const { return *v1; }
127127
const Satellite& getV2() const { return *v2; }
128-
const uint32_t getV1Idx() const { return v1_idx; }
129-
const uint32_t getV2Idx() const { return v2_idx; }
128+
uint32_t getV1Idx() const { return v1_idx; }
129+
uint32_t getV2Idx() const { return v2_idx; }
130130
float getRadiusCentralMass() const { return cm.radius_central_mass; }
131131

132132
private:

include/dmsc/instance.hpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,12 @@ class AdjacencyMatrix {
2727
};
2828

2929
AdjacencyMatrix() = delete;
30-
AdjacencyMatrix(const size_t size, const Item& default_value = Item());
30+
AdjacencyMatrix(const size_t size, const Item& default_value);
3131
std::vector<Item>& operator[](size_t row) { return matrix[row]; }
3232
const std::vector<Item>& operator[](size_t row) const { return matrix[row]; }
3333
void clear();
3434

3535
std::vector<std::vector<Item>> matrix;
36-
37-
// GETTER
38-
std::vector<Item> column(const size_t column) const;
39-
std::vector<Item> row(const size_t row) const;
4036
};
4137

4238
// ------------------------------------------------------------------------------------------------
@@ -115,13 +111,13 @@ class PhysicalInstance {
115111
const std::vector<Satellite>& getSatellites() const { return satellites; }
116112
const std::vector<InterSatelliteLink>& getISL() const { return intersatellite_links; }
117113
const AdjacencyMatrix& getAdjacencyMatrix() const { return adjacency_matrix; }
118-
const size_t islCount() const { return intersatellite_links.size(); }
119-
const size_t satelliteCount() const { return satellites.size(); }
114+
size_t islCount() const { return intersatellite_links.size(); }
115+
size_t satelliteCount() const { return satellites.size(); }
120116

121117
private:
122118
std::vector<Satellite> satellites;
123119
std::vector<InterSatelliteLink> intersatellite_links;
124-
AdjacencyMatrix adjacency_matrix = AdjacencyMatrix(0);
120+
AdjacencyMatrix adjacency_matrix = AdjacencyMatrix(0, AdjacencyMatrix::Item(~0u, ~0u));
125121
CentralMass cm;
126122
enum FileReadingMode { READ_INIT, READ_ORBIT, READ_EDGE }; // order must match blocks in file-format
127123

src/instance.cpp

+2-17
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,6 @@ void AdjacencyMatrix::clear() {
3636

3737
// ------------------------------------------------------------------------------------------------
3838

39-
std::vector<AdjacencyMatrix::Item> AdjacencyMatrix::column(const size_t column) const {
40-
std::vector<Item> result;
41-
result.reserve(matrix.size());
42-
for (int i = 0; i < matrix.size(); i++) {
43-
result.push_back(matrix[i][column]);
44-
}
45-
return result;
46-
}
47-
48-
// ------------------------------------------------------------------------------------------------
49-
50-
std::vector<AdjacencyMatrix::Item> AdjacencyMatrix::row(const size_t row) const { return matrix[row]; }
51-
52-
// ------------------------------------------------------------------------------------------------
53-
5439
// ========================
5540
// = Instance
5641
// ========================
@@ -286,7 +271,7 @@ void PhysicalInstance::removeInvalidISL() {
286271

287272
// ------------------------------------------------------------------------------------------------
288273

289-
float rad(const float deg) { return deg * 0.01745329251994329577f; }; // convert degrees to radians
290-
float deg(const float rad) { return rad * 57.2957795130823208768f; }; // convert radians to degrees
274+
float rad(const float deg) { return deg * 0.01745329251994329577f; } // convert degrees to radians
275+
float deg(const float rad) { return rad * 57.2957795130823208768f; } // convert radians to degrees
291276

292277
} // namespace dmsc

src/opengl_widgets.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void OpenGLWidget::recalculateOrbitPositions() {
319319
nmbr_vertecies = satellite_subscene->getObjectInfo().at(0).number_vertices;
320320
for (const Satellite& o : problem_instance.getSatellites()) {
321321
glm::vec3 offset = o.cartesian_coordinates(sim_time) / real_world_scale;
322-
for (int i = 0; i < nmbr_vertecies; i++) {
322+
for (size_t i = 0; i < nmbr_vertecies; i++) {
323323
positions.push_back(offset.x);
324324
positions.push_back(offset.y);
325325
positions.push_back(offset.z);
@@ -684,7 +684,7 @@ void OpenGLWidget::buildGUI() {
684684
ImGui::SetWindowSize(ImVec2(350, 300));
685685

686686
ImGui::PushItemWidth(ImGui::GetFontSize() * -12);
687-
char* btn_text = paused ? "Play" : "Pause";
687+
const char* btn_text = paused ? "Play" : "Pause";
688688
if (ImGui::Button(btn_text)) {
689689
paused = !paused;
690690
}

src/solver/greedy_next.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Solution GreedyNext::solve() {
2929
float t_next = INFINITY; // absolute time
3030

3131
// find best edge depending on the time passed
32-
for (int i = 0; i < remaining_edges.size(); i++) {
32+
for (size_t i = 0; i < remaining_edges.size(); i++) {
3333
const InterSatelliteLink& e = *remaining_edges.at(i);
3434
float next_communication = nextCommunication(e, curr_time);
3535

src/solver/greedy_next_khop.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace solver {
1111
*/
1212
struct GreedyNextKHop::Communication {
1313
ScheduledCommunication scheduled_communication = {~0u, ~0u};
14-
AdjacencyMatrix possible_paths = AdjacencyMatrix(0);
14+
AdjacencyMatrix possible_paths = AdjacencyMatrix(0, AdjacencyMatrix::Item(~0u, ~0u));
1515
uint32_t forward_idx = 0u; // index of current vertex for the forward direction (sat1 -> sat2)
1616
};
1717

@@ -46,7 +46,7 @@ Solution GreedyNextKHop::solve() {
4646
float t_next = INFINITY; // absolute time
4747

4848
// find best edge depending on the time passed
49-
for (int i = 0; i < remaining_communications.size(); i++) {
49+
for (uint32_t i = 0; i < remaining_communications.size(); i++) {
5050
const Communication& com = remaining_communications[i];
5151

5252
std::vector<AdjacencyMatrix::Item> possible_neighbours = com.possible_paths[com.forward_idx];

0 commit comments

Comments
 (0)