Commit 86e92847 authored by VAN TOLL Wouter's avatar VAN TOLL Wouter
Browse files

Merge branch 'performance-improvements' into 'master'

Bugfix #88 + Various performance improvements

See merge request !103
parents bf934f0f f2ccdfed
<?xml version="1.0" encoding="utf-8"?>
<Simulation delta_time="0.1" end_time="100">
<World type="Infinite" />
<Simulation delta_time="0.1" end_time="200">
<World type="Toric" width="60" height="60" />
<Policies file="policies/Karamouzas.xml" />
<Agents file="agents/OneWayFlow200.xml" />
</Simulation>
<?xml version="1.0" encoding="utf-8"?>
<Simulation delta_time="0.1" end_time="100">
<World type="Infinite" />
<Simulation delta_time="0.1" end_time="200">
<World type="Toric" width="60" height="60" />
<Policies file="policies/ORCA.xml" />
<Agents file="agents/OneWayFlow200.xml" />
</Simulation>
<?xml version="1.0" encoding="utf-8"?>
<Simulation delta_time="0.1" end_time="200">
<World type="Toric" width="60" height="60" />
<Policies file="policies/SocialForces.xml" />
<Agents file="agents/OneWayFlow200.xml" />
</Simulation>
<?xml version="1.0" encoding="utf-8"?>
<Simulation delta_time="0.1" end_time="200">
<World type="Toric" width="60" height="60" />
<Policies file="policies/VanToll.xml" />
<Agents file="agents/OneWayFlow200.xml" />
</Simulation>
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="gradient">
<costfunction coeff="20" range="100" name="TtcaDca" sigmaTtca="1" sigmaDca="0.3" sigmaAngle_goal="2" sigmaSpeed_goal="2" />
<costfunction coeff="20" range="5" name="TtcaDca" sigmaTtca="1" sigmaDca="0.3" sigmaAngle_goal="2" sigmaSpeed_goal="2" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="gradient">
<costfunction range="100" name="FOEAvoidance" coeff="3" />
<costfunction range="100" name="GoalReachingForce" />
<costfunction range="5" name="FOEAvoidance" coeff="3" />
<costfunction name="GoalReachingForce" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="regular" SamplingBase="zero" SamplingBaseDirection="preferred velocity" SamplingAngle="180" SpeedSamples="15" AngleSamples="19" SamplingRadius="maximum speed" RelaxationTime="0" IncludeBaseAsSample="true">
<costfunction range="100" name="Karamouzas" />
<costfunction range="5" name="Karamouzas" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="regular" SamplingBase="zero" SamplingBaseDirection="preferred velocity" SamplingAngle="180" SpeedSamples="5" AngleSamples="19" SamplingRadius="preferred speed" RelaxationTime="0.5">
<costfunction range="100" name="Moussaid" />
<costfunction range="5" name="Moussaid" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="global" RelaxationTime="0">
<costfunction range="100" name="ORCA" />
<costfunction range="5" name="ORCA" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="regular" SamplingBase="zero" SamplingBaseDirection="unit" SamplingAngle="360" SpeedSamples="4" AngleSamples="36" SamplingRadius="maximum speed" RelaxationTime="0.5">
<costfunction range="100" name="PLEdestrians" t_min="0.5" t_max="3" />
<costfunction range="5" name="PLEdestrians" t_min="0.5" t_max="3" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="regular" SamplingBase="zero" SamplingBaseDirection="unit" SamplingAngle="360" SpeedSamples="4" AngleSamples="36" SamplingRadius="maximum speed" RelaxationTime="0">
<costfunction range="100" name="Paris"/>
<costfunction range="5" name="Paris"/>
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="gradient" RelaxationTime="0.5">
<costfunction range="100" name="PowerLaw" />
<costfunction range="100" name="GoalReachingForce" />
<costfunction range="5" name="PowerLaw" />
<costfunction name="GoalReachingForce" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="random" SamplingBase="current velocity" SamplingBaseDirection="unit" SamplingAngle="360" RandomSamples="250" SamplingRadius="maximum acceleration" RelaxationTime="0">
<costfunction range="100" name="RVO" />
<costfunction range="5" name="RVO" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="gradient" RelaxationTime="0.5">
<costfunction range="100" name="SocialForcesAvoidance" />
<costfunction range="100" name="GoalReachingForce" />
<costfunction range="5" name="SocialForcesAvoidance" />
<costfunction name="GoalReachingForce" />
</Policy>
</Policies>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Policies>
<Policy id="0" OptimizationMethod="sampling" SamplingType="regular" SamplingBase="zero" SamplingBaseDirection="preferred velocity" SamplingAngle="180" SpeedSamples="2" AngleSamples="19" SamplingRadius="preferred speed" RelaxationTime="0.25">
<costfunction range="100" name="VanToll" />
<costfunction range="5" name="VanToll" />
</Policy>
</Policies>
\ No newline at end of file
......@@ -107,11 +107,11 @@ namespace ORCALibrary
/* Create agent ORCA lines. */
for (const PhantomAgent& other : agentNeighbors_)
{
if (distanceSquared(other.position, position_) > maxDistSq)
if (other.GetDistanceSquared() > maxDistSq)
continue;
const Vector2D& relativePosition = other.position - position_;
const Vector2D& relativeVelocity = velocity_ - other.velocity;
const Vector2D& relativePosition = other.GetPosition() - position_;
const Vector2D& relativeVelocity = velocity_ - other.GetVelocity();
const float distSq = relativePosition.sqrMagnitude();
const float combinedRadius = radius_ + other.realAgent->getRadius();
const float combinedRadiusSq = combinedRadius * combinedRadius;
......
......@@ -65,7 +65,7 @@ int main( int argc, char * argv[] )
{
std::cerr << "Input error: " << paramName << " is not a valid parameter name." << std::endl;
printUsageInfo(argv[0]);
return 0;
return -1;
}
if (paramName == "-i" || paramName == "-input")
......@@ -81,7 +81,7 @@ int main( int argc, char * argv[] )
{
std::cerr << "Input error: Please specify an input scenario." << std::endl;
printUsageInfo(argv[0]);
return 0;
return -1;
}
// number of threads must be at least 1
......@@ -89,7 +89,7 @@ int main( int argc, char * argv[] )
{
std::cerr << "Input error: Please specify a positive number of threads." << std::endl;
printUsageInfo(argv[0]);
return 0;
return -1;
}
// output folder may be empty; if so, show a warning
......@@ -100,18 +100,17 @@ int main( int argc, char * argv[] )
}
// run the simulation
CrowdSimulator* cs = CrowdSimulator::FromConfigFile(configFile, true);
if (cs != nullptr)
{
if (outputFolder != "")
cs->StartCSVOutput(outputFolder, false); // false = don't save any files until the simulation ends
cs->RunSimulationUntilEnd();
}
CrowdSimulator* cs = CrowdSimulator::FromConfigFile(configFile);
if (cs == nullptr) // the simulation could not be loaded (for reasons already written to the console)
return -1;
std::cout << "Simulation done" << std::endl;
cs->GetWorld()->SetNumberOfThreads(nrThreads);
if (outputFolder != "")
cs->StartCSVOutput(outputFolder, false); // false = don't save any files until the simulation ends
delete cs;
std::cout << "---------------" << std::endl;
// run the full simulation; show a progress bar and measure the time
cs->RunSimulationUntilEnd(true, true);
delete cs;
return 0;
}
......@@ -64,11 +64,11 @@ float FOEAvoidance::GetCost(const Vector2D& velocity, Agent* agent, const WorldB
// check neighboring agents
for (const PhantomAgent& neighbor : neighbors.first)
{
if (distanceSquared(Position, neighbor.position) > rangeSquared)
if (neighbor.GetDistanceSquared() > rangeSquared)
continue;
Vector2D Vel = RT * (neighbor.velocity - velocity);
Vector2D Pos = RT * (neighbor.position - Position);
Vector2D Vel = RT * (neighbor.GetVelocity() - velocity);
Vector2D Pos = RT * (neighbor.GetPosition() - Position);
if (Pos.y < MIN_DISTANCE || Vel.y > -MIN_VELOCITY)
continue;
......@@ -108,11 +108,11 @@ Vector2D FOEAvoidance::GetGradient(const Vector2D& velocity, Agent* agent, const
// check neighboring agents
for (const PhantomAgent& neighbor : neighbors.first)
{
if (distanceSquared(Position, neighbor.position) > rangeSquared)
if (neighbor.GetDistanceSquared() > rangeSquared)
continue;
Vector2D Vel = RT * (neighbor.velocity - velocity);
Vector2D Pos = RT * (neighbor.position - Position);
Vector2D Vel = RT * (neighbor.GetVelocity() - velocity);
Vector2D Pos = RT * (neighbor.GetPosition() - Position);
if (Pos.y < MIN_DISTANCE || Vel.y > -MIN_VELOCITY)
continue;
......
......@@ -35,7 +35,7 @@
class GoalReachingForce : public ForceBasedFunction
{
public:
GoalReachingForce() : ForceBasedFunction() {}
GoalReachingForce() : ForceBasedFunction() { range_ = 0; }
virtual ~GoalReachingForce() {}
const static std::string GetName() { return "GoalReachingForce"; }
......
......@@ -33,7 +33,7 @@ Vector2D ObjectInteractionForces::ComputeForce(Agent* agent, const WorldBase * w
const auto& neighbors = agent->getNeighbors();
for (const PhantomAgent& other : neighbors.first)
{
if (distanceSquared(other.position, Position) <= rangeSquared)
if (other.GetDistanceSquared() <= rangeSquared)
AgentForces += ComputeAgentInteractionForce(agent, other);
}
......
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