Merge branch 'master' into jgrpp

# Conflicts:
#	config.lib
#	src/linkgraph/demands.cpp
#	src/linkgraph/mcf.cpp
#	src/linkgraph/refresh.cpp
#	src/linkgraph/refresh.h
#	src/smallmap_gui.cpp
This commit is contained in:
Jonathan G Rennison
2016-07-24 10:16:55 +01:00
17 changed files with 144 additions and 114 deletions

View File

@@ -2,11 +2,11 @@
#include "../stdafx.h"
#include "demands.h"
#include <deque>
#include <queue>
#include "../safeguards.h"
typedef std::deque<NodeID> NodeList;
typedef std::queue<NodeID> NodeList;
/**
* Scale various things according to symmetric/asymmetric distribution.
@@ -172,11 +172,11 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
for (NodeID node = 0; node < job.Size(); node++) {
scaler.AddNode(job[node]);
if (job[node].Supply() > 0) {
supplies.push_back(node);
supplies.push(node);
num_supplies++;
}
if (job[node].Demand() > 0) {
demands.push_back(node);
demands.push(node);
num_demands++;
}
}
@@ -191,17 +191,17 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
while (!supplies.empty() && !demands.empty()) {
NodeID from_id = supplies.front();
supplies.pop_front();
supplies.pop();
for (uint i = 0; i < num_demands; ++i) {
assert(!demands.empty());
NodeID to_id = demands.front();
demands.pop_front();
demands.pop();
if (from_id == to_id) {
/* Only one node with supply and demand left */
if (demands.empty() && supplies.empty()) return;
demands.push_back(to_id);
demands.push(to_id);
continue;
}
@@ -236,7 +236,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
scaler.SetDemands(job, from_id, to_id, demand_forw);
if (scaler.HasDemandLeft(job[to_id])) {
demands.push_back(to_id);
demands.push(to_id);
} else {
num_demands--;
}
@@ -245,7 +245,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
}
if (job[from_id].UndeliveredSupply() != 0) {
supplies.push_back(from_id);
supplies.push(from_id);
} else {
num_supplies--;
}

View File

@@ -68,6 +68,7 @@ public:
*/
class CapacityAnnotation : public Path {
int cached_annotation;
public:
typedef int AnnotationValueType;

View File

@@ -72,9 +72,7 @@ LinkRefresher::LinkRefresher(Vehicle *vehicle, HopSet *seen_hops, bool allow_mer
vehicle(vehicle), seen_hops(seen_hops), cargo(CT_INVALID), allow_merge(allow_merge),
is_full_loading(is_full_loading)
{
for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
this->capacities[cargo_type] = 0;
}
memset(this->capacities, 0, sizeof(this->capacities));
/* Assemble list of capacities and set last loading stations to 0. */
for (Vehicle *v = this->vehicle; v != NULL; v = v->Next()) {
@@ -211,7 +209,6 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
/* Refresh the link and give it a minimum capacity. */
uint cargo_quantity = this->capacities[c];
if (cargo_quantity == 0) continue;
/* If not allowed to merge link graphs, make sure the stations are

View File

@@ -14,7 +14,7 @@
#include "../cargo_type.h"
#include "../vehicle_base.h"
#include <deque>
#include <vector>
#include <map>
#include <set>
@@ -79,7 +79,7 @@ protected:
bool operator<(const Hop &other) const;
};
typedef std::deque<RefitDesc> RefitList;
typedef std::vector<RefitDesc> RefitList;
typedef std::set<Hop> HopSet;
Vehicle *vehicle; ///< Vehicle for which the links should be refreshed.