openttd updated to 1.5.0-beta2
--HG-- branch : openttd
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "demands.h"
|
||||
#include <list>
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
typedef std::list<NodeID> NodeList;
|
||||
|
||||
/**
|
||||
@@ -11,15 +13,7 @@ typedef std::list<NodeID> NodeList;
|
||||
*/
|
||||
class Scaler {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Scaler() : demand_per_node(0) {}
|
||||
|
||||
void SetDemands(LinkGraphJob &job, NodeID from, NodeID to, uint demand_forw);
|
||||
|
||||
protected:
|
||||
uint demand_per_node; ///< Mean demand associated with each node.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -32,7 +26,8 @@ public:
|
||||
* @param mod_size Size modifier to be used. Determines how much demands
|
||||
* increase with the supply of the remote station.
|
||||
*/
|
||||
inline SymmetricScaler(uint mod_size) : mod_size(mod_size), supply_sum(0)
|
||||
inline SymmetricScaler(uint mod_size) : mod_size(mod_size), supply_sum(0),
|
||||
demand_per_node(0)
|
||||
{}
|
||||
|
||||
/**
|
||||
@@ -80,8 +75,9 @@ public:
|
||||
void SetDemands(LinkGraphJob &job, NodeID from, NodeID to, uint demand_forw);
|
||||
|
||||
private:
|
||||
uint mod_size; ///< Size modifier. Determines how much demands increase with the supply of the remote station.
|
||||
uint supply_sum; ///< Sum of all supplies in the component.
|
||||
uint mod_size; ///< Size modifier. Determines how much demands increase with the supply of the remote station.
|
||||
uint supply_sum; ///< Sum of all supplies in the component.
|
||||
uint demand_per_node; ///< Mean demand associated with each node.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -90,37 +86,29 @@ private:
|
||||
class AsymmetricScaler : public Scaler {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
* Nothing to do here.
|
||||
* @param unused.
|
||||
*/
|
||||
inline AsymmetricScaler() : demand_sum(0) {}
|
||||
|
||||
/**
|
||||
* Count a node's demand into the sum of demands.
|
||||
* @param node The node to be counted.
|
||||
*/
|
||||
inline void AddNode(const Node &node)
|
||||
inline void AddNode(const Node &)
|
||||
{
|
||||
this->demand_sum += node.Demand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the mean demand per node using the sum of demands.
|
||||
* @param num_demands Number of accepting nodes.
|
||||
* Nothing to do here.
|
||||
* @param unused.
|
||||
*/
|
||||
inline void SetDemandPerNode(uint num_demands)
|
||||
inline void SetDemandPerNode(uint)
|
||||
{
|
||||
this->demand_per_node = max(this->demand_sum / num_demands, (uint)1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective supply of one node towards another one. In asymmetric
|
||||
* distribution the demand of the other node is weighed in.
|
||||
* Get the effective supply of one node towards another one.
|
||||
* @param from The supplying node.
|
||||
* @param to The receiving node.
|
||||
* @param unused.
|
||||
*/
|
||||
inline uint EffectiveSupply(const Node &from, const Node &to)
|
||||
inline uint EffectiveSupply(const Node &from, const Node &)
|
||||
{
|
||||
return max(from.Supply() * to.Demand() / this->demand_per_node, (uint)1);
|
||||
return from.Supply();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +118,6 @@ public:
|
||||
* @param to_anno Unused.
|
||||
*/
|
||||
inline bool HasDemandLeft(const Node &to) { return to.Demand() > 0; }
|
||||
|
||||
private:
|
||||
uint demand_sum; ///< Sum of all demands in the component.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -140,7 +125,7 @@ private:
|
||||
* this sets demands in both directions.
|
||||
* @param job The link graph job.
|
||||
* @param from_id The supplying node.
|
||||
* @þaram to_id The receiving node.
|
||||
* @param to_id The receiving node.
|
||||
* @param demand_forw Demand calculated for the "forward" direction.
|
||||
*/
|
||||
void SymmetricScaler::SetDemands(LinkGraphJob &job, NodeID from_id, NodeID to_id, uint demand_forw)
|
||||
@@ -163,7 +148,7 @@ void SymmetricScaler::SetDemands(LinkGraphJob &job, NodeID from_id, NodeID to_id
|
||||
* this only sets demand in the "forward" direction.
|
||||
* @param job The link graph job.
|
||||
* @param from_id The supplying node.
|
||||
* @þaram to_id The receiving node.
|
||||
* @param to_id The receiving node.
|
||||
* @param demand_forw Demand calculated for the "forward" direction.
|
||||
*/
|
||||
inline void Scaler::SetDemands(LinkGraphJob &job, NodeID from_id, NodeID to_id, uint demand_forw)
|
||||
@@ -225,7 +210,8 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
|
||||
|
||||
/* Scale the distance by mod_dist around max_distance */
|
||||
int32 distance = this->max_distance - (this->max_distance -
|
||||
(int32)job[from_id][to_id].Distance()) * this->mod_dist / 100;
|
||||
(int32)DistanceMaxPlusManhattan(job[from_id].XY(), job[to_id].XY())) *
|
||||
this->mod_dist / 100;
|
||||
|
||||
/* Scale the accuracy by distance around accuracy / 2 */
|
||||
int32 divisor = this->accuracy * (this->mod_dist - 50) / 100 +
|
||||
@@ -271,7 +257,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler)
|
||||
* @param job Job to calculate the demands for.
|
||||
*/
|
||||
DemandCalculator::DemandCalculator(LinkGraphJob &job) :
|
||||
max_distance(MapSizeX() + MapSizeY() - 2)
|
||||
max_distance(DistanceMaxPlusManhattan(TileXY(0,0), TileXY(MapMaxX(), MapMaxY())))
|
||||
{
|
||||
const LinkGraphSettings &settings = job.Settings();
|
||||
CargoID cargo = job.Cargo();
|
||||
|
||||
Reference in New Issue
Block a user