Skip to content
Snippets Groups Projects
Commit 39df2438 authored by Leonardo Brenner's avatar Leonardo Brenner
Browse files

First commit

parent 9beb0540
No related branches found
No related tags found
No related merge requests found
Showing
with 9753 additions and 0 deletions
//====================================================================================//
// //
// Arc class //
// //
//====================================================================================//
// This File: arc.h Language: C++ (xlC and CC) //
// Software: SIMULEAU //
//====================================================================================//
// Creation: 22/apr/16 by: Leonardo.Brenner@lsis.org //
// Last Change: 22/apr/16 by: Leonardo.Brenner@lsis.org //
//====================================================================================//
#ifndef ARC_H
#define ARC_H
class Arc
{
public:
Arc();
virtual ~Arc();
protected:
double weight; // weight associated to this arc
Node *input; // pointer to the input node
Node *output; // pointer to the input node
private:
};
#endif // ARC_H
//====================================================================================//
// //
// Batch class //
// //
//====================================================================================//
// This File: batch.cpp Language: C++ (xlC and CC) //
// Software: SIMULEAU //
//====================================================================================//
// Creation: 28/apr/16 by: Leonardo.Brenner@lsis.org //
// Last Change: 28/apr/16 by: Leonardo.Brenner@lsis.org //
//====================================================================================//
#include "simuleau.h"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Methods of the Batch class
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
Batch::Batch()
{
strcpy(name,"");
length = 0.0;
density = 0.0;
position = 0.0;
outputflow = 0.0;
}
//------------------------------------------------------------------------------
// Constructor
//------------------------------------------------------------------------------
Batch::Batch(char *_name)
{
strcpy(name,"_name");
length = 0.0;
density = 0.0;
position = 0.0;
outputflow = 0.0;
}
//------------------------------------------------------------------------------
// Initialized constructor
//------------------------------------------------------------------------------
Batch::Batch(double _length, double _density, double _position)
{
length = _length;
density = _density;
position = _position;
outputflow = 0.0;
}
//------------------------------------------------------------------------------
// Initialized constructor
//------------------------------------------------------------------------------
Batch::Batch(double _inputflow, double _speed)
{
length = 0.0;
density = _inputflow/_speed;
position = 0.0;
outputflow = 0.0;
}
//------------------------------------------------------------------------------
// Destructor
//------------------------------------------------------------------------------
Batch::~Batch()
{
//dtor
}
//------------------------------------------------------------------------------
// It returns the batch name
//------------------------------------------------------------------------------
char* Batch::GetName()
{
return (name);
}
//------------------------------------------------------------------------------
// Copy
//------------------------------------------------------------------------------
void Batch::Copy(const Batch &_batch)
{
strcpy(name, _batch.name);
length = _batch.length;
density = _batch.density;
position = _batch.position;
outputflow = _batch.outputflow;
}
//------------------------------------------------------------------------------
// IsEqual
//------------------------------------------------------------------------------
int Batch::IsEqual(const Batch &_batch)
{
if (abs(length - _batch.length) > PRF::prf.Min_Err())
return 0;
if (abs(density - _batch.density) > PRF::prf.Min_Err())
return 0;
if (abs(position - _batch.position) > PRF::prf.Min_Err())
return 0;
return 1;
}
//------------------------------------------------------------------------------
// It sets a new density
//------------------------------------------------------------------------------
void Batch::SetDensity(double _density)
{
density = _density;
}
//------------------------------------------------------------------------------
// It sets a new length
//------------------------------------------------------------------------------
void Batch::SetLength(double _length)
{
length = _length;
}
//------------------------------------------------------------------------------
// It sets a new position
//------------------------------------------------------------------------------
void Batch::SetPosition(double _position)
{
position = _position;
}
//------------------------------------------------------------------------------
// It moves the position
//------------------------------------------------------------------------------
void Batch::MovePosition(double _length)
{
position += _length;
}
//------------------------------------------------------------------------------
// It returns the density
//------------------------------------------------------------------------------
double Batch::GetDensity()
{
return (density);
}
//------------------------------------------------------------------------------
// It returns the length
//------------------------------------------------------------------------------
double Batch::GetLength()
{
return (length);
}
//------------------------------------------------------------------------------
// It returns the position
//------------------------------------------------------------------------------
double Batch::GetPosition()
{
return (position);
}
//------------------------------------------------------------------------------
// It computes and returns the output flow of a batch
//------------------------------------------------------------------------------
double Batch::GetOutputFlow(double _speed)
{
outputflow = density * _speed;
return (outputflow);
}
//------------------------------------------------------------------------------
// It applies the free behaviour at this batch
//------------------------------------------------------------------------------
void Batch::EvolveInFreeBehaviour(Simtime *_stime, BatchPlace *bp)
{
double newposition;
newposition = position + (bp->GetInstantaneousSpeed() * _stime->StepTime());
if ((position == 0.0) && (length == 0.0)){ //new batch, input in free behaviour
length = newposition;
position = newposition;
}
else{
if ((bp->GetLength() - position) < PRF::prf.Min_Err()){
length -= (bp->GetInstantaneousSpeed() * _stime->StepTime());
position = bp->GetLength();
}
else{
position = newposition;
}
}
}
//------------------------------------------------------------------------------
// It applies the accumulated behaviour to the outpout batch
//------------------------------------------------------------------------------
void Batch::EvolveInAccumulatedOuputBehaviour(Simtime *_stime, BatchPlace *bp, double _flow)
{
length = length - (_stime->StepTime() * _flow / bp->GetDensity());
}
//------------------------------------------------------------------------------
// It applies the free to accumulated behaviour in the accumulated batch
//------------------------------------------------------------------------------
void Batch::EvolveInFreeToAccumulatedBehaviourAccBatch(Simtime *_stime, BatchPlace *bp, double _flow)
{
length = (((bp->GetInstantaneousSpeed() * density - _flow) / ( bp->GetDensity() - density)) * _stime->StepTime());
density = bp->GetDensity();
}
//------------------------------------------------------------------------------
// It applies the free to accumulated behaviour in the free batch
//------------------------------------------------------------------------------
void Batch::EvolveInFreeToAccumulatedBehaviourFreeBatch(Simtime *_stime, BatchPlace *bp, double outputbatchlength, double _flow)
{
length = length + ((_flow - bp->GetInstantaneousSpeed() * bp->GetDensity()) / (bp->GetDensity() - density)) * _stime->StepTime() ;
position = bp->GetLength() - outputbatchlength;
}
//------------------------------------------------------------------------------
// It applies the partially accumulated behaviour in the accumulated batch
//------------------------------------------------------------------------------
void Batch::EvolveInPartiallyAccumulatedBehaviourAccBatch(Simtime *_stime, BatchPlace *bp, double outputbatchlength, double _flow)
{
length = ((density / (bp->GetDensity() - density)) * _stime->StepTime() *(bp->GetInstantaneousSpeed() - (_flow/bp->GetDensity()))) ;
density = bp->GetDensity();
position = bp->GetLength() - outputbatchlength;
}
//------------------------------------------------------------------------------
// It applies the partially accumulated behaviour in the free batch
//------------------------------------------------------------------------------
void Batch::EvolveInPartiallyAccumulatedBehaviourFreeBatch(Simtime *_stime, BatchPlace *bp, double outputbatchlength, double batch2length, double _flow)
{
length = length +((bp->GetDensity() / (density - bp->GetDensity())) * _stime->StepTime() * (bp->GetInstantaneousSpeed() - (_flow/bp->GetDensity()))) ;
position = bp->GetLength() - outputbatchlength - batch2length;
}
//------------------------------------------------------------------------------
// Print
//------------------------------------------------------------------------------
void Batch::Print(ostream &fout)
{
fout << " (" << length << ", " << density << ", " << position << ")" << endl;
}
//------------------------------------------------------------------------------
// Write
//------------------------------------------------------------------------------
void Batch::Write(ostream &fout)
{
fout << " (" << length << ", " << density << ", " << position << ")" << endl;
}
//====================================================================================//
// //
// Batch class //
// //
//====================================================================================//
// This File: batch.h Language: C++ (xlC and CC) //
// Software: SIMULEAU //
//====================================================================================//
// Creation: 28/apr/16 by: Leonardo.Brenner@lsis.org //
// Last Change: 28/apr/16 by: Leonardo.Brenner@lsis.org //
//====================================================================================//
#ifndef BATCH_H
#define BATCH_H
class Batch // batch.cpp
{
public:
Batch();
Batch(char *_name);
Batch(double _length, double _density, double _position);
Batch(double _inputflow, double _speed);
virtual ~Batch();
virtual batch_type IsA(){return Batch_bt;};
char* GetName();
void Copy(const Batch &_batch);
int IsEqual(const Batch &_batch);
// input functions
void SetDensity(double _density);
void SetLength(double _length);
void SetPosition(double _position);
void MovePosition(double _length);
// output functions
double GetDensity();
double GetLength();
double GetPosition();
double GetOutputFlow(double _speed);
// batch evolution functions
void EvolveInFreeBehaviour(Simtime *_stime, BatchPlace *bp); //RL
void EvolveInAccumulatedOuputBehaviour(Simtime *_stime, BatchPlace *bp, double _flow); //SA
void EvolveInFreeToAccumulatedBehaviourAccBatch(Simtime *_stime, BatchPlace *bp, double _flow); //RLAa
void EvolveInFreeToAccumulatedBehaviourFreeBatch(Simtime *_stime, BatchPlace *bp, double ouputbatchlength, double _flow); //RLAl
void EvolveInPartiallyAccumulatedBehaviourAccBatch(Simtime *_stime, BatchPlace *bp, double ouputbatchlength, double _flow); //RAPa1
void EvolveInPartiallyAccumulatedBehaviourFreeBatch(Simtime *_stime, BatchPlace *bp, double outputbatchlength, double batch2length, double _flow); //RAPl
//print function
virtual void Print(ostream &fout);
virtual void Write(ostream &fout);
protected:
simuleau_name name;
double length;
double density;
double position;
double outputflow;
private:
};
class ControllableBatch : public Batch // controllablebatch.cpp
{
public:
typedef void (ControllableBatch::*EvolveFunction)(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb);
public:
ControllableBatch();
ControllableBatch(char *_name);
ControllableBatch(double _length, double _density, double _position, double _speed);
ControllableBatch(double _inputflow, double _speed);
virtual ~ControllableBatch();
virtual batch_type IsA(){return Controllable_bt;};
void Copy(const ControllableBatch &_controllablebatch);
int IsEqual(const ControllableBatch &_controllablebatch);
// input functions
void SetSpeed(double _speed);
void SetState(ctrl_batch_state _state);
void SetBehaviour(ctrl_batch_behaviour _behaviour);
// output functions
double GetSpeed();
double GetFlow();
ctrl_batch_state GetState();
ctrl_batch_state GetState(TriangularBatchPlace *tbp);
char* GetStateName();
ctrl_batch_behaviour GetBehaviour();
char* GetBehaviourName();
int IsOutputControllableBatch(BatchPlace *bp);
int IsInContactWithByFront(ControllableBatch &cb);
int IsInContactWithByRear(ControllableBatch &cb);
// controllable batch evolution functions
void SetEvolveFunction(EvolveFunction _func);
void Evolve(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb);
void EvolveInFreeBehaviour(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInCongestingOutputBehaviour(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInFreeToCongestingBehaviourCongBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInFreeToCongestingBehaviourFreeBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInFreeToCongestingBehaviourMiddlePlaceWithContactCongBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInFreeToCongestingBehaviourMiddlePlaceWithContactFreeBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInUncongestingOutputBehaviour(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInUncongestingToFreeBehaviourCongBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
void EvolveInUncongestingToFreeBehaviourFreeBatch(Simtime *_stime, TriangularBatchPlace *tbp, ControllableBatch *pcb, ControllableBatch *ncb); //RL
//print function
void Print(ostream &fout);
void Write(ostream &fout);
protected:
double speed;
ctrl_batch_state state;
ctrl_batch_behaviour behaviour;
EvolveFunction evolvefunction;
private:
};
#endif // BATCH_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//====================================================================================//
// //
// Firingquantity class //
// //
//====================================================================================//
// This File: firingquantity.h Language: C++ (xlC and CC) //
// Software: SIMULEAU //
//====================================================================================//
// Creation: 29/apr/16 by: Leonardo.Brenner@lsis.org //
// Last Change: 29/apr/16 by: Leonardo.Brenner@lsis.org //
//====================================================================================//
#ifndef FIRINGQUANTITY_H
#define FIRINGQUANTITY_H
class FiringQuantity
{
public:
FiringQuantity();
virtual ~FiringQuantity();
void Copy(const FiringQuantity *_firingquantity);
// input functions
void SetAllFiringQuantities(double _firingquantity);
void SetCurrentFiringQuantity(double _firingquantity);
void SetSteadyFiringQuantity(double _firingquantity);
// output functions
double GetCurrentFiringQuantity();
double GetSteadyFiringQuantity();
//print
void Print(ostream &fout);
protected:
double firingquantity;
double currentfiringquantity;
double steadyfiringquantity;
private:
};
#endif // FIRINGQUANTITY_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment