├── src ├── Devices │ ├── Device.cpp │ ├── Amplifiers │ │ ├── BoosterAmplifier.cpp │ │ ├── InLineAmplifier.cpp │ │ ├── EDFA.cpp │ │ ├── Amplifier.cpp │ │ └── PreAmplifier.cpp │ ├── Regenerator.cpp │ ├── Fiber.cpp │ └── Splitter.cpp ├── GeneralPurposeAlgorithms │ ├── IntegrationMethods │ │ ├── IntegrationMethod.cpp │ │ └── TrapezoidalRule.cpp │ ├── NSGA-II │ │ └── NSGA2_Parameter.cpp │ └── GA │ │ ├── GA_Individual.cpp │ │ └── GA_Generation.cpp ├── GeneralClasses │ ├── Transmittances │ │ ├── Transmittance.cpp │ │ ├── ConstantTransmittance.cpp │ │ ├── GaussianFilter.cpp │ │ ├── GaussianPassbandFilter.cpp │ │ └── GaussianStopbandFilter.cpp │ ├── TransmissionBitrate.cpp │ └── Power.cpp ├── RMSA │ ├── RegeneratorPlacementAlgorithms │ │ ├── Empty_RegeneratorPlacementAlgorithm.cpp │ │ ├── MultiObjectiveRegeneratorPlacement │ │ │ ├── NSGA2_Parameter_NumberOfRegenerators.cpp │ │ │ ├── NSGA2_Parameter_CapEx.cpp │ │ │ └── NSGA2_Parameter_OpEx.cpp │ │ ├── NX_RegeneratorPlacement.cpp │ │ └── DistanceAdaptative.cpp │ ├── RoutingAlgorithms │ │ └── Costs │ │ │ ├── MinimumHops.cpp │ │ │ ├── ShortestPath.cpp │ │ │ ├── LengthOccupationRoutingContiguity.cpp │ │ │ ├── LengthOccupationRoutingAvailability.cpp │ │ │ └── PowerSeriesRouting │ │ │ ├── Costs │ │ │ ├── Cost_Contiguity.cpp │ │ │ ├── Cost_NormalizedContiguity.cpp │ │ │ ├── Cost_Distance.cpp │ │ │ ├── Cost_Availability.cpp │ │ │ ├── Cost_Occupability.cpp │ │ │ ├── Cost_ModulationScheme.cpp │ │ │ ├── Cost_Bitrate.cpp │ │ │ ├── Cost_OrigDestIndex.cpp │ │ │ ├── Cost_Slots.cpp │ │ │ ├── Cost.cpp │ │ │ └── Cost_LinkLength.cpp │ │ │ └── PSRVariants │ │ │ ├── AdaptativeWeighingRouting.cpp │ │ │ ├── TensorialPowerSeriesRouting.cpp │ │ │ └── MatricialPowerSeriesRouting.cpp │ └── SpectrumAssignmentAlgorithms │ │ ├── FFE │ │ ├── FFE_GA.cpp │ │ └── FFE_Generation.cpp │ │ ├── FirstFit.cpp │ │ ├── BestFit.cpp │ │ └── RandomFit.cpp ├── Calls │ ├── Event.cpp │ └── Call.cpp ├── main.cpp └── Structure │ └── Slot.cpp ├── .astylerc ├── README.md ├── include ├── GeneralPurposeAlgorithms │ ├── PSO.h │ ├── NSGA-2.h │ ├── IntegrationMethods │ │ ├── TrapezoidalRule.h │ │ └── IntegrationMethod.h │ ├── NSGA-II │ │ ├── NSGA2_Parameter.h │ │ └── NSGA2_Generation.h │ ├── GA │ │ └── GA_Generation.h │ └── PSO │ │ └── PSO_Particle.h ├── Calls.h ├── Structure.h ├── Devices.h ├── Devices │ ├── Amplifiers.h │ ├── Amplifiers │ │ ├── EDFA.h │ │ ├── BoosterAmplifier.h │ │ ├── InLineAmplifier.h │ │ ├── PreAmplifier.h │ │ └── Amplifier.h │ ├── Regenerator.h │ ├── Fiber.h │ ├── Splitter.h │ └── SSS.h ├── RMSA │ ├── RoutingAlgorithms.h │ ├── RoutingAlgorithms │ │ ├── Costs │ │ │ ├── PowerSeriesRouting │ │ │ │ ├── PSRVariants.h │ │ │ │ ├── Costs.h │ │ │ │ ├── PSRVariants │ │ │ │ │ ├── AdaptativeWeighingRouting.h │ │ │ │ │ ├── MatricialPowerSeriesRouting.h │ │ │ │ │ ├── TensorialPowerSeriesRouting.h │ │ │ │ │ └── LocalPowerSeriesRouting.h │ │ │ │ └── Costs │ │ │ │ │ ├── Cost_Occupability.h │ │ │ │ │ ├── Cost_Availability.h │ │ │ │ │ ├── Cost_Distance.h │ │ │ │ │ ├── Cost_Slots.h │ │ │ │ │ ├── Cost_Bitrate.h │ │ │ │ │ ├── Cost_Contiguity.h │ │ │ │ │ ├── Cost_ModulationScheme.h │ │ │ │ │ ├── Cost_OrigDestIndex.h │ │ │ │ │ ├── Cost_LinkLength.h │ │ │ │ │ ├── Cost_NormalizedContiguity.h │ │ │ │ │ └── Cost_HopDistance.h │ │ │ ├── MinimumHops.h │ │ │ ├── ShortestPath.h │ │ │ ├── LengthOccupationRoutingContiguity.h │ │ │ └── LengthOccupationRoutingAvailability.h │ │ ├── Algorithms │ │ │ ├── Dijkstra_RoutingAlgorithm.h │ │ │ ├── BellmanFord_RoutingAlgorithm.h │ │ │ └── Yen_RoutingAlgorithm.h │ │ ├── RoutingCost.h │ │ └── RoutingAlgorithm.h │ ├── RegeneratorPlacementAlgorithms │ │ ├── MultiObjectiveRegeneratorPlacement │ │ │ ├── NSGA2_Parameters.h │ │ │ ├── NSGA2_Parameter_CapEx.h │ │ │ ├── NSGA2_Parameter_NumberOfRegenerators.h │ │ │ ├── NSGA2_Parameter_BlockingProbability.h │ │ │ └── NSGA2_Parameter_OpEx.h │ │ ├── NodalDegreeFirst.h │ │ ├── DistanceAdaptative.h │ │ ├── Empty_RegeneratorPlacementAlgorithm.h │ │ ├── SignalQualityPrediction │ │ │ ├── SQP_NetworkSimulation.h │ │ │ ├── SignalQualityPrediction_Variants.h │ │ │ └── SignalQualityPrediction.h │ │ ├── NX_RegeneratorPlacement.h │ │ ├── MostUsed.h │ │ ├── NX_MostSimultaneouslyUsed.h │ │ └── MostSimultaneouslyUsed.h │ ├── RegeneratorAssignmentAlgorithms.h │ ├── RoutingCosts.h │ ├── SpectrumAssignmentAlgorithms │ │ ├── FFE │ │ │ ├── FFE_Generation.h │ │ │ ├── FFE_Individual.h │ │ │ ├── FFE_GA.h │ │ │ └── FirstFitEvolutionary.h │ │ ├── FirstFit.h │ │ ├── RandomFit.h │ │ ├── BestFit.h │ │ ├── MostUsedSA.h │ │ ├── LeastUsed.h │ │ └── ExactFit.h │ ├── SpectrumAssignmentAlgorithms.h │ ├── RegeneratorPlacementAlgorithms.h │ └── RegeneratorAssignmentAlgorithms │ │ ├── ShortestCostRegeneratorAssignment.h │ │ ├── FirstLongestReach.h │ │ └── FirstNarrowestSpectrum.h ├── GeneralClasses │ ├── RandomGenerator.h │ ├── Transmittances │ │ ├── ConstantTransmittance.h │ │ ├── GaussianPassbandFilter.h │ │ ├── GaussianStopbandFilter.h │ │ ├── GaussianFilter.h │ │ └── Transmittance.h │ ├── LinkSpectralDensity.h │ ├── PhysicalConstants.h │ └── TransmissionBitrate.h ├── RMSA.h ├── GeneralClasses.h ├── SimulationTypes.h ├── SimulationTypes │ ├── Simulation_FFE_Optimization.h │ ├── Simulation_NetworkLoad.h │ ├── Simulation_TransparencyAnalysis.h │ ├── Simulation_PowerRatioThreshold.h │ ├── Simulation_StatisticalTrend.h │ └── Simulation_RegeneratorNumber.h ├── Structure │ └── Slot.h └── Calls │ └── Event.h ├── .gitlab-ci.yml ├── data └── topologies │ ├── P2P4 │ ├── Top2 │ ├── Top1 │ ├── NSFNet │ ├── PacificBell │ └── German ├── .travis.yml ├── tests ├── Calls │ ├── CallTest.cpp │ ├── EventTest.cpp │ └── CallGeneratorTest.cpp ├── Devices │ ├── FiberTest.cpp │ └── SplitterTest.cpp ├── Structure │ └── SlotTest.cpp ├── GeneralClasses │ ├── TransmissionBitrateTest.cpp │ ├── ModulationSchemeTest.cpp │ ├── SpectralDensityTest.cpp │ └── GainTest.cpp ├── GeneralPurposeAlgorithms │ └── IntegrationMethods │ │ └── TrapezoidalRuleTest.cpp └── crosstalkTest.cpp └── .gitignore /src/Devices/Device.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace Devices; 4 | 5 | Device::Device(DeviceType DevType) : DevType(DevType) 6 | { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /.astylerc: -------------------------------------------------------------------------------- 1 | --lineend=linux 2 | --mode=c 3 | --max-code-length=110 4 | 5 | --style=vtk 6 | 7 | --add-brackets 8 | 9 | --break-after-logical 10 | --pad-oper 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SimEON 2 | Simulator for Elastic Optical Networks 3 | 4 | For details, please refer to our article, https://link.springer.com/article/10.1007/s11107-017-0697-9 5 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/PSO.h: -------------------------------------------------------------------------------- 1 | #ifndef PSO_H 2 | #define PSO_H 3 | 4 | #include "PSO/ParticleSwarmOptimization.h" 5 | #include "PSO/PSO_Particle.h" 6 | 7 | #endif // PSO_H 8 | 9 | -------------------------------------------------------------------------------- /include/Calls.h: -------------------------------------------------------------------------------- 1 | #ifndef CALLS_H 2 | #define CALLS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif // CALLS_H 9 | 10 | -------------------------------------------------------------------------------- /include/Structure.h: -------------------------------------------------------------------------------- 1 | #ifndef STRUCTURE_H 2 | #define STRUCTURE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #endif // STRUCTURE_H 10 | 11 | -------------------------------------------------------------------------------- /src/GeneralPurposeAlgorithms/IntegrationMethods/IntegrationMethod.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralPurposeAlgorithms/IntegrationMethods/IntegrationMethod.h" 2 | 3 | using namespace NumericMethods; 4 | 5 | IntegrationMethod::IntegrationMethod() 6 | { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | before_script: 2 | - apt-get update -y 3 | - apt-get -y --fix-missing install libboost-all-dev gcc g++ libarmadillo-dev qt5-qmake qt5-default libgtest-dev 4 | 5 | build: 6 | script: 7 | - qmake adamant-broccoli.pro 8 | - make install 9 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/NSGA-2.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA_II_H 2 | #define NSGA_II_H 3 | 4 | #include "NSGA-II/NSGA2.h" 5 | #include "NSGA-II/NSGA2_Generation.h" 6 | #include "NSGA-II/NSGA2_Individual.h" 7 | #include "NSGA-II/NSGA2_Parameter.h" 8 | 9 | #endif // NSGA_II_H 10 | 11 | -------------------------------------------------------------------------------- /include/Devices.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICES_H 2 | #define DEVICES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #endif // DEVICES_H 12 | 13 | -------------------------------------------------------------------------------- /src/GeneralClasses/Transmittances/Transmittance.cpp: -------------------------------------------------------------------------------- 1 | #include "GeneralClasses/Transmittances/Transmittance.h" 2 | 3 | using namespace TF; 4 | 5 | Transmittance::Transmittance(Gain scale) : scale(scale) 6 | { 7 | 8 | } 9 | 10 | Gain &Transmittance::get_Gain() 11 | { 12 | return scale; 13 | } 14 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers.h: -------------------------------------------------------------------------------- 1 | #ifndef AMPLIFIERS_H 2 | #define AMPLIFIERS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #endif // AMPLIFIERS_H 11 | 12 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef ROUTINGALGORITHMS_H 2 | #define ROUTINGALGORITHMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif // ROUTINGALGORITHMS_H 9 | 10 | -------------------------------------------------------------------------------- /src/GeneralClasses/Transmittances/ConstantTransmittance.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralClasses/Transmittances/ConstantTransmittance.h" 2 | 3 | using namespace TF; 4 | 5 | ConstantTransmittance::ConstantTransmittance(Gain scale) : Transmittance(scale) 6 | { 7 | 8 | } 9 | 10 | Gain &ConstantTransmittance::get_TransmittanceAt(double) 11 | { 12 | return scale; 13 | } 14 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants.h: -------------------------------------------------------------------------------- 1 | #ifndef PSRVARIANTS_H 2 | #define PSRVARIANTS_H 3 | 4 | #include "PSRVariants/AdaptativeWeighingRouting.h" 5 | #include "PSRVariants/LocalPowerSeriesRouting.h" 6 | #include "PSRVariants/MatricialPowerSeriesRouting.h" 7 | #include "PSRVariants/TensorialPowerSeriesRouting.h" 8 | 9 | #endif // PSRVARIANTS_H 10 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameters.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETERS_H 2 | #define NSGA2_PARAMETERS_H 3 | 4 | #include "NSGA2_Parameter_BlockingProbability.h" 5 | #include "NSGA2_Parameter_CapEx.h" 6 | #include "NSGA2_Parameter_NumberOfRegenerators.h" 7 | #include "NSGA2_Parameter_OpEx.h" 8 | 9 | #endif // NSGA2_PARAMETERS_H 10 | -------------------------------------------------------------------------------- /data/topologies/P2P4: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | 9 | [links] 10 | 11 | # -> = ORIGIN DESTINATION LENGTH 12 | -> = 1 2 200 13 | -> = 2 1 200 14 | -> = 2 3 200 15 | -> = 3 2 200 16 | -> = 3 4 200 17 | -> = 4 3 200 18 | -------------------------------------------------------------------------------- /include/GeneralClasses/RandomGenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOMGENERATOR 2 | #define RANDOMGENERATOR 3 | 4 | #include 5 | 6 | /** 7 | * @brief random_generator is the random engine used to generate random numbers, 8 | * with several probabilist distributions, through the whole simulator. 9 | */ 10 | static std::default_random_engine random_generator(0); 11 | 12 | #endif // RANDOMGENERATOR 13 | 14 | -------------------------------------------------------------------------------- /include/RMSA.h: -------------------------------------------------------------------------------- 1 | #ifndef RMSA_H 2 | #define RMSA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #endif // RMSA_H 13 | 14 | -------------------------------------------------------------------------------- /include/GeneralClasses/Transmittances/ConstantTransmittance.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTANTTRANSMITTANCE_H 2 | #define CONSTANTTRANSMITTANCE_H 3 | 4 | #include "Transmittance.h" 5 | 6 | namespace TF 7 | { 8 | class ConstantTransmittance : public Transmittance 9 | { 10 | public: 11 | ConstantTransmittance(Gain scale); 12 | 13 | Gain& get_TransmittanceAt(double); 14 | }; 15 | } 16 | 17 | #endif // CONSTANTTRANSMITTANCE_H 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | addons: 4 | apt: 5 | sources: 6 | - ubuntu-toolchain-r-test 7 | packages: 8 | - libboost-all-dev 9 | - libboost-random-dev 10 | - gcc-4.8 11 | - g++-4.8 12 | - libarmadillo-dev 13 | - libgtest-dev 14 | 15 | script: 16 | - qmake adamant-broccoli.pro 17 | - sed -i 's/= gcc/= gcc-4.8/g' Makefile 18 | - sed -i 's/= g++/= g++-4.8/g' Makefile 19 | - make 20 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorAssignmentAlgorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef REGENERATORASSIGNMENTALGORITHMS_H 2 | #define REGENERATORASSIGNMENTALGORITHMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif // REGENERATORASSIGNMENTALGORITHMS_H 9 | 10 | -------------------------------------------------------------------------------- /include/GeneralClasses.h: -------------------------------------------------------------------------------- 1 | #ifndef GENERALCLASSES_H 2 | #define GENERALCLASSES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #endif // GENERALCLASSES_H 13 | 14 | -------------------------------------------------------------------------------- /include/RMSA/RoutingCosts.h: -------------------------------------------------------------------------------- 1 | #ifndef ROUTINGCOSTS_H 2 | #define ROUTINGCOSTS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #endif // ROUTINGCOSTS_H 11 | -------------------------------------------------------------------------------- /src/Devices/Amplifiers/BoosterAmplifier.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | 6 | BoosterAmplifier::BoosterAmplifier() : EDFA(-SSS::SSSLoss) 7 | { 8 | 9 | } 10 | 11 | Gain &BoosterAmplifier::get_Gain() 12 | { 13 | return AmplifierGain; 14 | } 15 | 16 | std::shared_ptr BoosterAmplifier::clone() 17 | { 18 | return std::shared_ptr(new BoosterAmplifier(*this)); 19 | } 20 | -------------------------------------------------------------------------------- /src/Devices/Amplifiers/InLineAmplifier.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | 6 | InLineAmplifier::InLineAmplifier(Fiber &Segment) : EDFA(-Segment.get_Gain()) 7 | { 8 | 9 | } 10 | 11 | Gain &InLineAmplifier::get_Gain() 12 | { 13 | return AmplifierGain; 14 | } 15 | 16 | std::shared_ptr InLineAmplifier::clone() 17 | { 18 | return std::shared_ptr(new InLineAmplifier(*this)); 19 | } 20 | -------------------------------------------------------------------------------- /src/GeneralPurposeAlgorithms/NSGA-II/NSGA2_Parameter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace NSGA_II; 4 | 5 | NSGA2_Parameter::NSGA2_Parameter(std::vector gene) : 6 | isEvaluated(false), value(-1), gene(gene) 7 | { 8 | 9 | } 10 | 11 | bool NSGA2_Parameter::operator ==(const NSGA2_Parameter &other) const 12 | { 13 | return value == other.value; 14 | } 15 | 16 | void NSGA2_Parameter::setValue(double val) 17 | { 18 | isEvaluated = true; 19 | value = val; 20 | } 21 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/Empty_RegeneratorPlacementAlgorithm.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/RegeneratorPlacementAlgorithms/Empty_RegeneratorPlacementAlgorithm.h" 2 | 3 | using namespace RMSA::RP; 4 | 5 | Empty_RegeneratorPlacementAlgorithm::Empty_RegeneratorPlacementAlgorithm 6 | (std::shared_ptr T) : RegeneratorPlacementAlgorithm(T) 7 | { 8 | 9 | } 10 | 11 | void Empty_RegeneratorPlacementAlgorithm::load() 12 | { 13 | 14 | } 15 | 16 | void Empty_RegeneratorPlacementAlgorithm::placeRegenerators(unsigned, unsigned) 17 | { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/GeneralClasses/Transmittances/GaussianFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "GeneralClasses/Transmittances/GaussianFilter.h" 2 | #include 3 | 4 | using namespace TF; 5 | 6 | GaussianFilter::GaussianFilter(double centerFreq, unsigned int filterOrder, Gain scale) : 7 | Transmittance(scale), centerFreq(centerFreq), filterOrder(filterOrder) 8 | { 9 | 10 | } 11 | 12 | double &GaussianFilter::get_CenterFreq() 13 | { 14 | return centerFreq; 15 | } 16 | 17 | unsigned int &GaussianFilter::get_FilterOrder() 18 | { 19 | return filterOrder; 20 | } 21 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Generation.h: -------------------------------------------------------------------------------- 1 | #ifndef FFE_GENERATION_H 2 | #define FFE_GENERATION_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/GA/GA_Generation.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | namespace FFE 11 | { 12 | class FFE_GA; 13 | 14 | class FFE_Generation : public GeneticAlgorithm::GA_Generation 15 | { 16 | public: 17 | FFE_Generation(FFE_GA *GA); 18 | FFE_GA *GA; 19 | 20 | void breed(unsigned int a, unsigned int b, std::shared_ptr dest); 21 | }; 22 | } 23 | } 24 | } 25 | 26 | #endif // FFE_GENERATION_H 27 | -------------------------------------------------------------------------------- /include/SimulationTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATIONTYPES_H 2 | #define SIMULATIONTYPES_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif // SIMULATIONTYPES_H 14 | 15 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef SPECTRUMASSIGNMENTALGORITHMS_H 2 | #define SPECTRUMASSIGNMENTALGORITHMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #endif // SPECTRUMASSIGNMENTALGORITHMS_H 13 | 14 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs.h: -------------------------------------------------------------------------------- 1 | #ifndef COSTS 2 | #define COSTS 3 | 4 | #include "Costs/Cost_Availability.h" 5 | #include "Costs/Cost_Bitrate.h" 6 | #include "Costs/Cost_Contiguity.h" 7 | #include "Costs/Cost_Distance.h" 8 | #include "Costs/Cost_HopDistance.h" 9 | #include "Costs/Cost_LinkLength.h" 10 | #include "Costs/Cost_ModulationScheme.h" 11 | #include "Costs/Cost_Noise.h" 12 | #include "Costs/Cost_NormalizedContiguity.h" 13 | #include "Costs/Cost_NormalizedNoise.h" 14 | #include "Costs/Cost_Occupability.h" 15 | #include "Costs/Cost_OrigDestIndex.h" 16 | #include "Costs/Cost_Slots.h" 17 | 18 | #endif // COSTS 19 | 20 | -------------------------------------------------------------------------------- /src/Devices/Amplifiers/EDFA.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | 6 | Gain EDFA::NoiseFigure = Gain(5); 7 | 8 | EDFA::EDFA(Gain G) : Amplifier(G) 9 | { 10 | set_Gain(G); 11 | } 12 | 13 | void EDFA::calculate_NoisePower() 14 | { 15 | //This is the ASE Noise Modelling. 16 | double Noise = 0.5 * PhysicalConstants::numPolarizations * 17 | PhysicalConstants::h * PhysicalConstants::freq * PhysicalConstants::BRef * 18 | NoiseFigure.in_Linear() * (AmplifierGain.in_Linear() - 1); 19 | NoisePower = Power(Noise, Power::Watt); 20 | } 21 | -------------------------------------------------------------------------------- /src/Calls/Event.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Event::Event(double t, Event_Type Type, std::shared_ptr Parent) : 5 | t(t), 6 | Type(Type), 7 | Parent(Parent) 8 | { 9 | #ifdef RUN_ASSERTIONS 10 | if (t < 0) 11 | { 12 | std::cerr << "Occural time should be positive." << std::endl; 13 | abort(); 14 | } 15 | #endif 16 | } 17 | 18 | bool Event::operator >(const Event &E) const 19 | { 20 | return (t > E.t); 21 | } 22 | 23 | bool Event::operator <(const Event &E) const 24 | { 25 | return (t < E.t); 26 | } 27 | 28 | bool Event::operator ==(const Event &E) const 29 | { 30 | return (t == E.t); 31 | } 32 | -------------------------------------------------------------------------------- /src/Calls/Call.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | Call::Call(std::weak_ptr Origin, 5 | std::weak_ptr Destination, 6 | TransmissionBitrate Bitrate) : 7 | Origin(Origin), 8 | Destination(Destination), 9 | Bitrate(Bitrate), 10 | Status(Not_Evaluated), 11 | Scheme(ModulationScheme(0, Gain(0))), 12 | blockingReason(0x0) 13 | { 14 | 15 | } 16 | 17 | Call::Call(std::weak_ptr Origin, 18 | std::weak_ptr Destination, 19 | TransmissionBitrate Bitrate, 20 | ModulationScheme Scheme) : 21 | Call(Origin, Destination, Bitrate) 22 | { 23 | this->Scheme = Scheme; 24 | } 25 | -------------------------------------------------------------------------------- /src/GeneralClasses/Transmittances/GaussianPassbandFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralClasses/Transmittances/GaussianPassbandFilter.h" 2 | 3 | using namespace TF; 4 | 5 | GaussianPassbandFilter::GaussianPassbandFilter 6 | (double centerFreq, unsigned int filterOrder, Gain scale) : 7 | GaussianFilter(centerFreq, filterOrder, scale) 8 | { 9 | 10 | } 11 | 12 | Gain &GaussianPassbandFilter::get_TransmittanceAt(double freq) 13 | { 14 | if (!calculatedGains.count(freq)) 15 | { 16 | Gain G(std::exp2l(- pow(2 * (freq - centerFreq) / BW_3dB, 2 * filterOrder)), Gain::Linear); 17 | calculatedGains.emplace(freq, scale + G); 18 | } 19 | return calculatedGains.at(freq); 20 | } 21 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/MinimumHops.h: -------------------------------------------------------------------------------- 1 | #ifndef MINIMUMHOPS_H 2 | #define MINIMUMHOPS_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | /** 11 | * @brief The MinimumHops class represents the Minimum Hops routing algorithm. 12 | * The link cost of each link is 1. 13 | */ 14 | class MinimumHops : public RoutingCost 15 | { 16 | public: 17 | MinimumHops(std::shared_ptr T); 18 | 19 | double get_Cost(std::weak_ptr link, std::shared_ptr); 20 | void load() 21 | { 22 | RoutingCost::load(); 23 | } 24 | void save(std::string); 25 | void print(); 26 | }; 27 | } 28 | } 29 | 30 | #endif // MINIMUMHOPS_H 31 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Individual.h: -------------------------------------------------------------------------------- 1 | #ifndef FFE_INDIVIDUAL_H 2 | #define FFE_INDIVIDUAL_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/GA/GA_Individual.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | namespace FFE 11 | { 12 | 13 | class FFE_Generation; 14 | 15 | class FFE_Individual : public GeneticAlgorithm::GA_Individual 16 | { 17 | public: 18 | FFE_Individual(FFE_Generation *G); 19 | 20 | void createIndividual(); 21 | int createGene(unsigned int g); 22 | std::shared_ptr clone(); 23 | void eval(); 24 | GA_Individual& mutate(); 25 | 26 | private: 27 | FFE_Generation *G; 28 | }; 29 | } 30 | } 31 | } 32 | 33 | #endif // FFE_INDIVIDUAL_H 34 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Algorithms/Dijkstra_RoutingAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef DIJKSTRA_ROUTINGALGORITHM_H 2 | #define DIJKSTRA_ROUTINGALGORITHM_H 3 | 4 | #include "../RoutingAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | class Dijkstra_RoutingAlgorithm : public RoutingAlgorithm 11 | { 12 | public: 13 | Dijkstra_RoutingAlgorithm(std::shared_ptr T, 14 | RoutingCost::RoutingCosts RoutCost, 15 | bool runLoad); 16 | std::vector>> route(std::shared_ptr C); 17 | 18 | void load() {} 19 | void save(std::string name); 20 | void print(); 21 | }; 22 | } 23 | } 24 | 25 | #endif // DIJKSTRA_ROUTINGALGORITHM_H 26 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/ShortestPath.h: -------------------------------------------------------------------------------- 1 | #ifndef SHORTESTPATH_H 2 | #define SHORTESTPATH_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | /** 11 | * @brief The ShortestPath class represents the Shortest Path routing algorithm. 12 | * The link cost of each link is its length. 13 | */ 14 | class ShortestPath : public RoutingCost 15 | { 16 | public: 17 | ShortestPath(std::shared_ptr T); 18 | 19 | double get_Cost(std::weak_ptr link, std::shared_ptr); 20 | void load() 21 | { 22 | RoutingCost::load(); 23 | } 24 | void save(std::string); 25 | void print(); 26 | }; 27 | } 28 | } 29 | 30 | #endif // SHORTESTPATH_H 31 | -------------------------------------------------------------------------------- /src/GeneralClasses/Transmittances/GaussianStopbandFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralClasses/Transmittances/GaussianStopbandFilter.h" 2 | 3 | using namespace TF; 4 | 5 | GaussianStopbandFilter::GaussianStopbandFilter 6 | (double centerFreq, unsigned int filterOrder, Gain scale) : 7 | GaussianFilter(centerFreq, filterOrder, scale) 8 | { 9 | 10 | } 11 | 12 | Gain &GaussianStopbandFilter::get_TransmittanceAt(double freq) 13 | { 14 | if (!calculatedGains.count(freq)) 15 | { 16 | Gain G(std::exp2l(- pow(2 * (freq - centerFreq) / BW_3dB, 2 * filterOrder)), Gain::Linear); 17 | calculatedGains.emplace(freq, Gain(1.0 - G.in_Linear(), Gain::Linear) + scale); 18 | } 19 | return calculatedGains.at(freq); 20 | } 21 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers/EDFA.h: -------------------------------------------------------------------------------- 1 | #ifndef EDFA_H 2 | #define EDFA_H 3 | 4 | #include 5 | 6 | namespace Devices 7 | { 8 | /** 9 | * @brief The EDFA class represents an erbium doped fiber amplifier. This class 10 | * of amplifiers has a ASE noise power modelling. 11 | */ 12 | class EDFA : public Amplifier 13 | { 14 | public: 15 | /** 16 | * @brief EDFA is the standard constructor of a EDFA. 17 | * @param G is the Gain of this amplifier. 18 | */ 19 | EDFA(Gain G); 20 | 21 | private: 22 | void calculate_NoisePower(); 23 | 24 | /** 25 | * @brief NoiseFigure is the noise figure of the amplifiers. 26 | */ 27 | static Gain NoiseFigure; 28 | }; 29 | } 30 | 31 | #endif // EDFA_H 32 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "SimulationTypes.h" 2 | #include 3 | 4 | namespace Simulations 5 | { 6 | bool parallelism_enabled = true; 7 | } 8 | 9 | bool considerAseNoise = false; 10 | bool considerFilterImperfection = false; 11 | 12 | #ifdef RUN_TESTS 13 | int main(int argc, char **argv) 14 | { 15 | ::testing::InitGoogleTest(&argc, argv); 16 | if (RUN_ALL_TESTS()) 17 | { 18 | return -1; 19 | } 20 | #else 21 | int main() 22 | { 23 | #endif 24 | 25 | std::cout << "\t* * * SIMULATOR OF SLICE OPTICAL NETWORKS * * *" 26 | << std::endl; 27 | 28 | auto simulation = Simulations::SimulationType::create(); 29 | simulation->print(); 30 | simulation->run(); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/MinimumHops.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | MinimumHops::MinimumHops(std::shared_ptr T) : 7 | RoutingCost(T, MH) 8 | { 9 | 10 | } 11 | 12 | double MinimumHops::get_Cost( 13 | std::weak_ptr link, 14 | std::shared_ptr) 15 | { 16 | if (!link.lock()->is_LinkActive()) 17 | { 18 | return std::numeric_limits::max(); 19 | } 20 | 21 | return 1; 22 | } 23 | 24 | void MinimumHops::save(std::string SimConfigFileName) 25 | { 26 | RoutingCost::save(SimConfigFileName); 27 | } 28 | 29 | void MinimumHops::print() 30 | { 31 | RoutingCost::print(); 32 | } 33 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Algorithms/BellmanFord_RoutingAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef BELLMANFORD_ROUTINGALGORITHM_H 2 | #define BELLMANFORD_ROUTINGALGORITHM_H 3 | 4 | #include "../RoutingAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | class BellmanFord_RoutingAlgorithm : public RoutingAlgorithm 11 | { 12 | public: 13 | BellmanFord_RoutingAlgorithm(std::shared_ptr T, 14 | RoutingCost::RoutingCosts Cost, 15 | bool runLoad); 16 | std::vector>> route(std::shared_ptr C); 17 | 18 | void load() {} 19 | void save(std::string); 20 | void print(); 21 | }; 22 | } 23 | } 24 | 25 | #endif // BELLMANFORD_ROUTINGALGORITHM_H 26 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/FirstFit.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRSTFIT_H 2 | #define FIRSTFIT_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The FirstFit class represents the First Fit spectrum assignment algorithm. 12 | * It tries to allocate the requisition on the first block of slots that are capable 13 | * of containing the requisition. 14 | */ 15 | class FirstFit : public SpectrumAssignmentAlgorithm 16 | { 17 | public: 18 | FirstFit(std::shared_ptr T); 19 | 20 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 21 | void load() {} 22 | void save(std::string); 23 | }; 24 | } 25 | } 26 | 27 | #endif // FIRSTFIT_H 28 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/ShortestPath.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | ShortestPath::ShortestPath(std::shared_ptr T) : 7 | RoutingCost(T, SP) 8 | { 9 | 10 | } 11 | 12 | double ShortestPath::get_Cost( 13 | std::weak_ptr link, 14 | std::shared_ptr) 15 | { 16 | if (!link.lock()->is_LinkActive()) 17 | { 18 | return std::numeric_limits::max(); 19 | } 20 | 21 | return link.lock()->Length; 22 | } 23 | 24 | void ShortestPath::save(std::string SimConfigFileName) 25 | { 26 | RoutingCost::save(SimConfigFileName); 27 | } 28 | 29 | void ShortestPath::print() 30 | { 31 | RoutingCost::print(); 32 | } 33 | -------------------------------------------------------------------------------- /include/GeneralClasses/LinkSpectralDensity.h: -------------------------------------------------------------------------------- 1 | #ifndef LINKSPECTRALDENSITY_H 2 | #define LINKSPECTRALDENSITY_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class LinkSpectralDensity 12 | { 13 | public: 14 | LinkSpectralDensity(std::vector>); 15 | std::vector> LinkSlots; 16 | void updateLink(SpectralDensity, std::vector>); 17 | std::vector> S; 18 | static unsigned long numFrequencySamples; 19 | std::shared_ptr slice 20 | (std::vector> usedSlots); 21 | }; 22 | 23 | #endif // LINKSPECTRALDENSITY_H 24 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/NodalDegreeFirst.h: -------------------------------------------------------------------------------- 1 | #ifndef NODALDEGREEFIRST_H 2 | #define NODALDEGREEFIRST_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace RP 9 | { 10 | /** 11 | * @brief The NodalDegreeFirst class implements the Nodal Degree First (NDF) 12 | * regenerator placement algorithm. 13 | */ 14 | class NodalDegreeFirst : public NX_RegeneratorPlacement 15 | { 16 | public: 17 | /** 18 | * @brief NodalDegreeFirst is the standard constructor. 19 | * @param T is a pointer to the Topology. 20 | */ 21 | NodalDegreeFirst(std::shared_ptr T); 22 | 23 | void placeRegenerators(unsigned N, unsigned X); 24 | void load(); 25 | }; 26 | } 27 | } 28 | 29 | #endif // NODALDEGREEFIRST_H 30 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/DistanceAdaptative.h: -------------------------------------------------------------------------------- 1 | #ifndef DISTANCEADAPTATIVE_H 2 | #define DISTANCEADAPTATIVE_H 3 | 4 | #include "RegeneratorPlacementAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace RP 9 | { 10 | /** 11 | * @brief The DistanceAdaptative class implements the Distance Adaptative RP algorithm. 12 | * 13 | * It distributes the regenerators proportionally to the length of the links 14 | * connected to each node. 15 | */ 16 | class DistanceAdaptative : public RegeneratorPlacementAlgorithm 17 | { 18 | public: 19 | DistanceAdaptative(std::shared_ptr T); 20 | void load(); 21 | void placeRegenerators(unsigned NumTotalReg = 0, unsigned = 0); 22 | 23 | private: 24 | static int DA_NumTotalRegenerators; 25 | }; 26 | } 27 | } 28 | 29 | #endif // DISTANCEADAPTATIVE_H 30 | -------------------------------------------------------------------------------- /tests/Calls/CallTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/Calls/Call.h" 4 | #include "include/Structure/Node.h" 5 | #include 6 | 7 | TEST(CallTest, Constructor) 8 | { 9 | //Setting up 10 | std::shared_ptr N1 = std::make_shared(1); 11 | std::shared_ptr N2 = std::make_shared(2); 12 | TransmissionBitrate BR(100E9); 13 | 14 | //Testing 15 | std::shared_ptr C = std::make_shared(N1, N2, BR); 16 | EXPECT_EQ(*(C->Origin.lock()), *N1) << "Source node not being correctly set."; 17 | EXPECT_EQ(*(C->Destination.lock()), *N2) << "Destination node not being correctly set."; 18 | EXPECT_EQ(C->Bitrate, BR) << "Bitrate being correctly set."; 19 | EXPECT_EQ(C->Status, Call::Not_Evaluated) << "A call should start as non-evaluated."; 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/IntegrationMethods/TrapezoidalRule.h: -------------------------------------------------------------------------------- 1 | #ifndef TRAPEZOIDALRULE_H 2 | #define TRAPEZOIDALRULE_H 3 | 4 | #include 5 | 6 | namespace NumericMethods 7 | { 8 | /** 9 | * @brief The TrapezoidalRule class represents the Trapezoidal Rule numerical integration method. 10 | */ 11 | class TrapezoidalRule : public IntegrationMethod 12 | { 13 | public: 14 | /** 15 | * @brief TrapezoidalRule is a constructor for a TrapezoidalRule object. 16 | */ 17 | TrapezoidalRule(); 18 | /** 19 | * @brief calculate is used to compute the TrapezoidalRule integration method. 20 | * @return the result of the calculations. 21 | */ 22 | double calculate(const arma::mat &, const double&); 23 | }; 24 | } 25 | 26 | #endif // TRAPEZOIDALRULE_H 27 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms.h: -------------------------------------------------------------------------------- 1 | #ifndef REGENERATORPLACEMENTALGORITHMS_H 2 | #define REGENERATORPLACEMENTALGORITHMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #endif // REGENERATORPLACEMENTALGORITHMS_H 14 | 15 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/RandomFit.h: -------------------------------------------------------------------------------- 1 | #ifndef RANDOMFIT_H 2 | #define RANDOMFIT_H 3 | 4 | #include "SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The RandomFit class represents the Random Fit spectrum assignment algorithm. 12 | * It tries to allocate the requisition on a block of slots randomly chosen. 13 | */ 14 | class RandomFit : public SpectrumAssignmentAlgorithm 15 | { 16 | public: 17 | /** 18 | * @brief RandomFit is the standard constructor for the Random Fit SA algorithm. 19 | * @param T is the topology. 20 | */ 21 | RandomFit(std::shared_ptr T); 22 | 23 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 24 | void load() {} 25 | void save(std::string); 26 | }; 27 | } 28 | } 29 | 30 | #endif // RANDOMFIT_H 31 | -------------------------------------------------------------------------------- /src/GeneralPurposeAlgorithms/IntegrationMethods/TrapezoidalRule.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralPurposeAlgorithms/IntegrationMethods/TrapezoidalRule.h" 2 | 3 | using namespace NumericMethods; 4 | 5 | TrapezoidalRule::TrapezoidalRule() 6 | { 7 | 8 | } 9 | 10 | double TrapezoidalRule::calculate(arma::mat const &YPoints, const double &XRange) 11 | { 12 | #ifdef RUN_ASSERTIONS 13 | if (YPoints.empty()) 14 | { 15 | std::cerr << "Cannot integrate empty vector." << std::endl; 16 | abort(); 17 | } 18 | #endif 19 | double Result, Sum = 0, h; 20 | h = XRange / (YPoints.size() - 1); 21 | for(size_t Cont = 1; Cont <= (YPoints.size() - 2); Cont++) 22 | { 23 | Sum += YPoints.at(Cont); 24 | } 25 | 26 | Result = (h / 2) * (YPoints.at(YPoints.size() - 1) + YPoints.at(0) + 2 * Sum); 27 | return Result; 28 | } 29 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_NumberOfRegenerators.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_NumberOfRegenerators.h" 2 | #include "include/SimulationTypes/Simulation_NSGA2_RegnPlac.h" 3 | 4 | using namespace RMSA::RP::MORP; 5 | 6 | NSGA2_Parameter_NumberOfRegenerators::NSGA2_Parameter_NumberOfRegenerators 7 | (std::vector gene, Simulations::Simulation_NSGA2_RegnPlac &) : 8 | NSGA2_Parameter(gene) 9 | { 10 | 11 | } 12 | 13 | double NSGA2_Parameter_NumberOfRegenerators::evaluate() 14 | { 15 | if (!isEvaluated) 16 | { 17 | value = 0; 18 | for (auto &g : gene) 19 | { 20 | value += g; 21 | } 22 | isEvaluated = true; 23 | } 24 | 25 | return value; 26 | } 27 | -------------------------------------------------------------------------------- /data/topologies/Top2: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | node = 5 transparent ss 0 9 | node = 6 transparent ss 0 10 | node = 7 transparent ss 0 11 | node = 8 transparent ss 0 12 | 13 | [links] 14 | 15 | # -> = ORIGIN DESTINATION LENGTH 16 | -> = 1 2 1200 17 | -> = 1 3 1200 18 | -> = 1 5 600 19 | -> = 2 1 1200 20 | -> = 2 4 1200 21 | -> = 2 6 600 22 | -> = 3 1 1200 23 | -> = 3 4 1200 24 | -> = 3 7 600 25 | -> = 4 2 1200 26 | -> = 4 3 1200 27 | -> = 4 8 600 28 | -> = 5 1 600 29 | -> = 5 6 700 30 | -> = 5 7 700 31 | -> = 6 2 600 32 | -> = 6 5 700 33 | -> = 6 8 700 34 | -> = 7 3 600 35 | -> = 7 5 700 36 | -> = 7 8 700 37 | -> = 8 4 600 38 | -> = 8 6 700 39 | -> = 8 7 700 40 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_GA.h: -------------------------------------------------------------------------------- 1 | #ifndef FFE_GA_H 2 | #define FFE_GA_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/GA/GA.h" 5 | 6 | class Topology; 7 | 8 | namespace Simulations 9 | { 10 | class Simulation_FFE_Optimization; 11 | } 12 | 13 | namespace RMSA 14 | { 15 | namespace SA 16 | { 17 | namespace FFE 18 | { 19 | 20 | class FFE_Generation; 21 | class FFE_Individual; 22 | 23 | class FFE_GA : public GeneticAlgorithm::GA 24 | { 25 | friend class FFE_Generation; 26 | friend class FFE_Individual; 27 | 28 | public: 29 | FFE_GA(Simulations::Simulation_FFE_Optimization &Sim); 30 | void createInitialGeneration(); 31 | std::shared_ptr createEmptyGeneration(); 32 | 33 | private: 34 | Simulations::Simulation_FFE_Optimization &Sim; 35 | }; 36 | } 37 | } 38 | } 39 | 40 | #endif // FFE_GA_H 41 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/BestFit.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTIGUITYFIT_H 2 | #define CONTIGUITYFIT_H 3 | 4 | #include "SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The BestFit class represents the Best Fit spectrum assignment algorithm. 12 | * It will allocate the requisition on the smallest possible block that can contain 13 | * the requisition. 14 | */ 15 | class BestFit : public SpectrumAssignmentAlgorithm 16 | { 17 | public: 18 | /** 19 | * @brief BestFit is the standard constructor to the Best Fit SA algorithm. 20 | * @param T is the Topology. 21 | */ 22 | BestFit(std::shared_ptr T); 23 | 24 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 25 | void load() {} 26 | void save(std::string); 27 | }; 28 | } 29 | } 30 | 31 | #endif // CONTIGUITYFIT_H 32 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/MostUsedSA.h: -------------------------------------------------------------------------------- 1 | #ifndef MOSTUSED_H 2 | #define MOSTUSED_H 3 | 4 | #include "SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The MostUsed class represents the Most Used spectrum assignment algorithm. 12 | * It tries to allocate the requistion on the block of slots that are used the most 13 | * on the entire network. 14 | */ 15 | class MostUsed : public SpectrumAssignmentAlgorithm 16 | { 17 | public: 18 | /** 19 | * @brief MostUsed is the standard constructor for the Most Used SA algorithm 20 | * @param T is the Topology. 21 | */ 22 | MostUsed(std::shared_ptr T); 23 | 24 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 25 | void load() {} 26 | void save(std::string); 27 | }; 28 | } 29 | } 30 | 31 | #endif // MOSTUSED_H 32 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/Empty_RegeneratorPlacementAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef EMPTY_REGENERATORPLACEMENTALGORITHM_H 2 | #define EMPTY_REGENERATORPLACEMENTALGORITHM_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace RP 9 | { 10 | /** 11 | * @brief The Empty_RegeneratorPlacementAlgorithm class is a dummy RP algorithm. 12 | * 13 | * Use this when the regenerators were already set directly through the topology. 14 | * This RP algorithm won't mess with it. 15 | */ 16 | class Empty_RegeneratorPlacementAlgorithm : public RegeneratorPlacementAlgorithm 17 | { 18 | public: 19 | Empty_RegeneratorPlacementAlgorithm(std::shared_ptr T); 20 | 21 | void placeRegenerators(unsigned, unsigned); 22 | void load(); 23 | }; 24 | } 25 | } 26 | 27 | #endif // EMPTY_REGENERATORPLACEMENTALGORITHM_H 28 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/LeastUsed.h: -------------------------------------------------------------------------------- 1 | #ifndef LEASTUSED_H 2 | #define LEASTUSED_H 3 | 4 | #include "SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The LeastUsed class represents the Least Used spectrum assignment algorithm. 12 | * It tries to allocate the requistion on the block of slots that are used the least 13 | * on the entire network. 14 | */ 15 | class LeastUsed : public SpectrumAssignmentAlgorithm 16 | { 17 | public: 18 | /** 19 | * @brief LeastUsed is the standard constructor for the Least Used SA algorithm 20 | * @param T is the Topology. 21 | */ 22 | LeastUsed(std::shared_ptr T); 23 | 24 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 25 | void load() {} 26 | void save(std::string); 27 | }; 28 | } 29 | } 30 | 31 | #endif // LEASTUSED_H 32 | -------------------------------------------------------------------------------- /include/GeneralClasses/Transmittances/GaussianPassbandFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef GAUSSIANPASSBANDFILTER_H 2 | #define GAUSSIANPASSBANDFILTER_H 3 | 4 | #include "GaussianFilter.h" 5 | 6 | namespace TF 7 | { 8 | /** 9 | * @brief The GaussianPassbandFilter class represents the transmittance of a 10 | * passband Gaussian filter. 11 | */ 12 | class GaussianPassbandFilter : public GaussianFilter 13 | { 14 | public: 15 | /** 16 | * @brief GaussianPassbandFilter is a constructor for a GaussianPassbandFilter. 17 | * @param centerFreq is the central frequency of this filter. 18 | * @param filterOrder is the order of the gaussian filter. 19 | * @param scale is the scale of this filter. 20 | */ 21 | GaussianPassbandFilter(double centerFreq, unsigned int filterOrder, Gain scale); 22 | Gain& get_TransmittanceAt(double freq); 23 | }; 24 | } 25 | 26 | #endif // GAUSSIANPASSBANDFILTER_H 27 | -------------------------------------------------------------------------------- /include/GeneralClasses/Transmittances/GaussianStopbandFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef GAUSSIANSTOPBANDFILTER_H 2 | #define GAUSSIANSTOPBANDFILTER_H 3 | 4 | #include "GaussianFilter.h" 5 | 6 | namespace TF 7 | { 8 | /** 9 | * @brief The GaussianStopbandFilter class represents the transmittance of a 10 | * stopband Gaussian filter. 11 | */ 12 | class GaussianStopbandFilter : public GaussianFilter 13 | { 14 | public: 15 | /** 16 | * @brief GaussianStopbandFilter is a constructor for a GaussianStopbandFilter. 17 | * @param centerFreq is the central frequency of this filter. 18 | * @param filterOrder is the order of the gaussian filter. 19 | * @param scale is the scale of this filter. 20 | */ 21 | GaussianStopbandFilter(double centerFreq, unsigned int filterOrder, Gain scale); 22 | Gain& get_TransmittanceAt(double freq); 23 | }; 24 | } 25 | 26 | #endif // GAUSSIANSTOPBANDFILTER_H 27 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers/BoosterAmplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef BOOSTERAMPLIFIER_H 2 | #define BOOSTERAMPLIFIER_H 3 | 4 | #include 5 | 6 | namespace Devices 7 | { 8 | /** 9 | * @brief The BoosterAmplifier class represents a booster amplifier. In the 10 | * considered architecture it is on the node's exit. 11 | * 12 | * This amplifier compensates for the loss on the SSS device in the node's exit. 13 | */ 14 | class BoosterAmplifier : public EDFA 15 | { 16 | public: 17 | /** 18 | * @brief AT is the type of amplifier. 19 | */ 20 | static constexpr AmplifierType AT = Amplifier::BoosterAmplifierType; 21 | /** 22 | * @brief BoosterAmplifier is the standard constructor for a BoosterAmplifier. 23 | */ 24 | BoosterAmplifier(); 25 | 26 | Gain &get_Gain(); 27 | 28 | std::shared_ptr clone(); 29 | }; 30 | } 31 | 32 | #endif // BOOSTERAMPLIFIER_H 33 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/ExactFit.h: -------------------------------------------------------------------------------- 1 | #ifndef EXACTFIT_H 2 | #define EXACTFIT_H 3 | 4 | #include "SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | /** 11 | * @brief The ExactFit class represents the Exact Fit spectrum assignment algorithm. 12 | * It tries to allocate the requisition of N slots on a block with exactly N slots. If 13 | * such block doesn't exist, then it calls FirstFit. 14 | */ 15 | class ExactFit : public SpectrumAssignmentAlgorithm 16 | { 17 | public: 18 | /** 19 | * @brief ExactFit is the standard constructor to the Exact Fit SA algorithm. 20 | * @param T is the Topology. 21 | */ 22 | ExactFit(std::shared_ptr T); 23 | 24 | mapSlots assignSlots(std::shared_ptr C, TransparentSegment Seg); 25 | void load() {} 26 | void save(std::string); 27 | }; 28 | } 29 | } 30 | 31 | #endif // EXACTFIT_H 32 | -------------------------------------------------------------------------------- /include/Devices/Regenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef REGENERATOR_H 2 | #define REGENERATOR_H 3 | 4 | #include "Device.h" 5 | 6 | namespace Devices 7 | { 8 | /** 9 | * @brief The Regenerator class represents a electronic regenerator. 10 | */ 11 | class Regenerator : public Device 12 | { 13 | public: 14 | /** 15 | * @brief Regenerator is the constructor for a regenerator device. 16 | */ 17 | Regenerator(); 18 | 19 | Gain &get_Gain(); 20 | Power &get_Noise(); 21 | std::shared_ptr get_TransferFunction(double); 22 | double get_CapEx(); 23 | double get_OpEx(); 24 | 25 | std::shared_ptr clone(); 26 | 27 | private: 28 | Gain RegeneratorGain; 29 | Power RegeneratorNoise; 30 | /** 31 | * @brief deviceTF is the device's transfer function. 32 | */ 33 | std::shared_ptr deviceTF; 34 | }; 35 | } 36 | 37 | #endif // REGENERATOR_H 38 | -------------------------------------------------------------------------------- /src/Devices/Amplifiers/Amplifier.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | using namespace TF; 6 | 7 | Amplifier::Amplifier(Gain G) : Device(Device::AmplifierDevice), 8 | AmplifierGain(G), NoisePower(0) 9 | { 10 | deviceTF = std::make_shared(G); 11 | } 12 | 13 | Power &Amplifier::get_Noise() 14 | { 15 | return NoisePower; 16 | } 17 | 18 | void Amplifier::set_Gain(Gain G) 19 | { 20 | AmplifierGain = G; 21 | deviceTF = std::make_shared(G); 22 | calculate_NoisePower(); 23 | } 24 | 25 | double Amplifier::get_CapEx() 26 | { 27 | return 0; 28 | } 29 | 30 | double Amplifier::get_OpEx() 31 | { 32 | return 0.1; 33 | } 34 | 35 | std::shared_ptr Amplifier::get_TransferFunction(double) 36 | { 37 | return deviceTF; 38 | } 39 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/AdaptativeWeighingRouting.h: -------------------------------------------------------------------------------- 1 | #ifndef ADAPTATIVEWEIGHINGROUTING_H 2 | #define ADAPTATIVEWEIGHINGROUTING_H 3 | 4 | #include "../PowerSeriesRouting.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | /** 13 | * @brief The AdaptativeWeighingRouting class represents the Adaptative 14 | * Weighing Routing algorithm. It is a type of PSR algorithm. Its cost is a power 15 | * series with only exponent 1. 16 | */ 17 | class AdaptativeWeighingRouting : public PowerSeriesRouting 18 | { 19 | public: 20 | AdaptativeWeighingRouting(std::shared_ptr T); 21 | AdaptativeWeighingRouting(std::shared_ptr T, 22 | std::vector> Costs); 23 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 24 | }; 25 | } 26 | } 27 | } 28 | 29 | #endif // ADAPTATIVEWEIGHINGROUTING_H 30 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/LengthOccupationRoutingContiguity.h: -------------------------------------------------------------------------------- 1 | #ifndef LENGTHOCCUPATIONROUTINGCONTIGUITY_H 2 | #define LENGTHOCCUPATIONROUTINGCONTIGUITY_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | /** 11 | * @brief The LengthOccupationRoutingContiguity class represents the Length and 12 | * Occupation Routing algorithm (contiguity variant). Its link cost is a 13 | * ponderation with the link length and its contiguity. 14 | */ 15 | class LengthOccupationRoutingContiguity : public RoutingCost 16 | { 17 | public: 18 | LengthOccupationRoutingContiguity(std::shared_ptr T); 19 | 20 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 21 | 22 | void load() 23 | { 24 | RoutingCost::load(); 25 | } 26 | void save(std::string); 27 | void print(); 28 | }; 29 | } 30 | } 31 | 32 | #endif // LENGTHOCCUPATIONROUTINGCONTIGUITY_H 33 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/IntegrationMethods/IntegrationMethod.h: -------------------------------------------------------------------------------- 1 | #ifndef INTEGRATIONMETHOD_H 2 | #define INTEGRATIONMETHOD_H 3 | 4 | #include 5 | 6 | //! Contains miscelaneous numeric methods required by the simulator. 7 | namespace NumericMethods 8 | { 9 | /** 10 | * @brief The IntegrationMethod class represents a numerical integration method. 11 | */ 12 | class IntegrationMethod 13 | { 14 | public: 15 | /** 16 | * @brief IntegrationMethod is a constructor for an IntegrationMethod. 17 | */ 18 | IntegrationMethod(); 19 | /** 20 | * @brief calculate is used to compute the IntegrationMethod. 21 | * @param YPoints are the points being integrated. 22 | * @param XRange is the length of the interval being integrated on. 23 | * @return the result of the calculations. 24 | */ 25 | virtual double calculate(arma::mat const &YPoints, const double &XRange) = 0; 26 | }; 27 | } 28 | 29 | #endif // INTEGRATIONMETHOD_H 30 | -------------------------------------------------------------------------------- /src/Devices/Regenerator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | using namespace TF; 6 | 7 | Regenerator::Regenerator() : Device(Device::RegeneratorDevice), 8 | RegeneratorGain(Gain(0)), RegeneratorNoise(Power(0, Power::Watt)) 9 | { 10 | deviceTF = std::make_shared(get_Gain()); 11 | } 12 | 13 | Gain &Regenerator::get_Gain() 14 | { 15 | return RegeneratorGain; 16 | } 17 | 18 | Power &Regenerator::get_Noise() 19 | { 20 | return RegeneratorNoise; 21 | } 22 | 23 | double Regenerator::get_CapEx() 24 | { 25 | return 1.0; 26 | } 27 | 28 | double Regenerator::get_OpEx() 29 | { 30 | return 0.2; 31 | } 32 | 33 | std::shared_ptr Regenerator::clone() 34 | { 35 | return std::shared_ptr(new Regenerator()); 36 | } 37 | 38 | std::shared_ptr Regenerator::get_TransferFunction(double) 39 | { 40 | return deviceTF; 41 | } 42 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/SignalQualityPrediction/SQP_NetworkSimulation.h: -------------------------------------------------------------------------------- 1 | #ifndef SQP_NETWORKSIMULATION_H 2 | #define SQP_NETWORKSIMULATION_H 3 | 4 | #include 5 | #include "SignalQualityPrediction.h" 6 | 7 | namespace RMSA 8 | { 9 | namespace RP 10 | { 11 | namespace SQP 12 | { 13 | class SQP_NetworkSimulation : public Simulations::NetworkSimulation 14 | { 15 | friend class SignalQualityPrediction; 16 | public: 17 | SQP_NetworkSimulation(std::shared_ptr Generator, 18 | std::shared_ptr RMSA, 19 | long unsigned NumMaxCalls, 20 | SignalQualityPrediction *SQP); 21 | 22 | void run(); 23 | 24 | private: 25 | SignalQualityPrediction *SQP; 26 | void implement_call(std::shared_ptr evt); 27 | 28 | std::vector NodeUsage; 29 | }; 30 | } 31 | } 32 | } 33 | 34 | #endif // SQP_NETWORKSIMULATION_H 35 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/MatricialPowerSeriesRouting.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRICIALPOWERSERIESROUTING_H 2 | #define MATRICIALPOWERSERIESROUTING_H 3 | 4 | #include "../PowerSeriesRouting.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | /** 13 | * @brief The MatricialPowerSeriesRouting class is the standard Power Series Routing 14 | * algorithm. Its cost is a truncated power series of carefully chosen costs. 15 | */ 16 | class MatricialPowerSeriesRouting : public PowerSeriesRouting 17 | { 18 | public: 19 | MatricialPowerSeriesRouting(std::shared_ptr T); 20 | MatricialPowerSeriesRouting(std::shared_ptr T, 21 | std::vector> Costs); 22 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 23 | 24 | std::map, double> cache; 25 | }; 26 | } 27 | } 28 | } 29 | 30 | #endif // MATRICIALPOWERSERIESROUTING_H 31 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_CapEx.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETER_CAPEX_H 2 | #define NSGA2_PARAMETER_CAPEX_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/NSGA-2.h" 5 | 6 | namespace Simulations 7 | { 8 | class Simulation_NSGA2_RegnPlac; 9 | } 10 | 11 | namespace RMSA 12 | { 13 | namespace RP 14 | { 15 | namespace MORP 16 | { 17 | /** 18 | * @brief The NSGA2_Parameter_CapEx class is a parameter to the MORP algorithm, 19 | * that implements the CapEx cost parameter. 20 | */ 21 | class NSGA2_Parameter_CapEx : public NSGA_II::NSGA2_Parameter 22 | { 23 | public: 24 | NSGA2_Parameter_CapEx(std::vector gene, 25 | Simulations::Simulation_NSGA2_RegnPlac &Sim); 26 | double evaluate(); 27 | std::string get_ParamName() 28 | { 29 | return "CapEx"; 30 | } 31 | 32 | private: 33 | Simulations::Simulation_NSGA2_RegnPlac &Sim; 34 | }; 35 | } 36 | } 37 | } 38 | 39 | #endif // NSGA2_PARAMETER_CAPEX_H 40 | -------------------------------------------------------------------------------- /src/Devices/Fiber.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace Devices; 5 | using namespace TF; 6 | 7 | double Fiber::alphaFiber = 0.22; 8 | 9 | Fiber::Fiber(double SpanLength) : 10 | Device(Device::FiberDevice), NetLoss(- SpanLength * alphaFiber, Gain::dB), 11 | NoisePower(0, Power::Watt) 12 | { 13 | this->SpanLength = SpanLength; 14 | deviceTF = std::make_shared(get_Gain()); 15 | } 16 | 17 | Gain &Fiber::get_Gain() 18 | { 19 | return NetLoss; 20 | } 21 | 22 | Power &Fiber::get_Noise() 23 | { 24 | return NoisePower; 25 | } 26 | 27 | std::shared_ptr Fiber::clone() 28 | { 29 | return std::shared_ptr(new Fiber(*this)); 30 | } 31 | 32 | double Fiber::get_CapEx() 33 | { 34 | return 0; 35 | } 36 | 37 | double Fiber::get_OpEx() 38 | { 39 | return 0; 40 | } 41 | 42 | std::shared_ptr Fiber::get_TransferFunction(double) 43 | { 44 | return deviceTF; 45 | } 46 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorAssignmentAlgorithms/ShortestCostRegeneratorAssignment.h: -------------------------------------------------------------------------------- 1 | #ifndef SHORTESTCOSTREGENERATORASSIGNMENT_H 2 | #define SHORTESTCOSTREGENERATORASSIGNMENT_H 3 | 4 | #include "RegeneratorAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace RA 9 | { 10 | class ShortestCostRegeneratorAssignment : public RegeneratorAssignmentAlgorithm 11 | { 12 | public: 13 | ShortestCostRegeneratorAssignment(std::shared_ptr T, 14 | std::set Schemes); 15 | std::vector assignRegenerators( 16 | std::shared_ptr, std::vector>); 17 | void load(); 18 | void save(std::string); 19 | 20 | private: 21 | double get_Cost(const TransparentSegment &segment, 22 | std::vector>, 23 | std::shared_ptr C); 24 | 25 | static bool hasLoaded; 26 | static double dcLevel; 27 | }; 28 | } 29 | } 30 | 31 | #endif // SHORTESTCOSTREGENERATORASSIGNMENT_H 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used to ignore files which are generated 2 | # ---------------------------------------------------------------------------- 3 | 4 | .ignore 5 | *~ 6 | *.autosave 7 | *.a 8 | *.core 9 | *.moc 10 | *.o 11 | *.objc*.orig 12 | *.rej 13 | *.so 14 | *.so.* 15 | *_pch.h.cpp 16 | *_resource.rc 17 | *.qm 18 | .#* 19 | *.*# 20 | core 21 | !core/ 22 | tags 23 | .DS_Store 24 | *.debug 25 | Makefile* 26 | *.prl 27 | *.app 28 | moc_*.cpp 29 | ui_*.h 30 | qrc_*.cpp 31 | Thumbs.db 32 | *.resource*.rc 33 | /.qmake.cache 34 | /.qmake.stash 35 | 36 | # qtcreator generated files 37 | *.pro.user* 38 | 39 | # xemacs temporary files 40 | *.flc 41 | 42 | # Vim temporary files 43 | .*.swp 44 | 45 | # Visual Studio generated files 46 | *.ib_pdb_indexing*.idb 47 | *.ilk 48 | *.pdb 49 | *.sln 50 | *.suo 51 | *.vcproj 52 | *vcproj.*.*.user 53 | *.ncb 54 | *.sdf 55 | *.opensdf 56 | *.vcxproj 57 | *vcxproj.* 58 | 59 | # MinGW generated files 60 | *.Debug 61 | *.Release 62 | 63 | # Python byte code 64 | *.pyc 65 | 66 | # Binaries 67 | # -------- 68 | *.dll 69 | *.exe -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/LengthOccupationRoutingAvailability.h: -------------------------------------------------------------------------------- 1 | #ifndef LENGTHOCCUPATIONROUTINGAVAILABILITY_H 2 | #define LENGTHOCCUPATIONROUTINGAVAILABILITY_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | /** 11 | * @brief The LengthOccupationRoutingAvailability class represents the Length and 12 | * Occupation Routing algorithm (availability variant). Its link cost is a 13 | * ponderation with the link length and its availability. 14 | */ 15 | class LengthOccupationRoutingAvailability : public RoutingCost 16 | { 17 | public: 18 | LengthOccupationRoutingAvailability(std::shared_ptr T); 19 | 20 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 21 | std::vector>> route(std::shared_ptr C); 22 | void load() 23 | { 24 | RoutingCost::load(); 25 | } 26 | void save(std::string); 27 | void print(); 28 | }; 29 | } 30 | } 31 | 32 | #endif // LENGTHOCCUPATIONROUTINGAVAILABILITY_H 33 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_NumberOfRegenerators.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETER_NUMBEROFREGENERATORS_H 2 | #define NSGA2_PARAMETER_NUMBEROFREGENERATORS_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/NSGA-2.h" 5 | 6 | namespace Simulations 7 | { 8 | class Simulation_NSGA2_RegnPlac; 9 | } 10 | 11 | namespace RMSA 12 | { 13 | namespace RP 14 | { 15 | namespace MORP 16 | { 17 | /** 18 | * @brief The NSGA2_Parameter_NumberOfRegenerators class is a parameter to the 19 | * MORP algorithm, that implements the number of electronic regenerators parameter. 20 | */ 21 | class NSGA2_Parameter_NumberOfRegenerators : public NSGA_II::NSGA2_Parameter 22 | { 23 | public: 24 | NSGA2_Parameter_NumberOfRegenerators 25 | (std::vector gene, Simulations::Simulation_NSGA2_RegnPlac &Sim); 26 | double evaluate(); 27 | std::string get_ParamName() 28 | { 29 | return "Number of Regenerators"; 30 | } 31 | }; 32 | } 33 | } 34 | } 35 | 36 | #endif // NSGA2_PARAMETER_NUMBEROFREGENERATORS_H 37 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/LengthOccupationRoutingContiguity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace RMSA::ROUT; 6 | 7 | LengthOccupationRoutingContiguity::LengthOccupationRoutingContiguity( 8 | std::shared_ptr T) : RoutingCost(T, LORc) 9 | { 10 | 11 | } 12 | 13 | double LengthOccupationRoutingContiguity::get_Cost( 14 | std::weak_ptr link, 15 | std::shared_ptr C) 16 | { 17 | if (!link.lock()->is_LinkActive()) 18 | { 19 | return std::numeric_limits::max(); 20 | } 21 | 22 | return 1 + 23 | (link.lock()->Length / T->get_LengthLongestLink()) + 24 | (1.0 / (link.lock()->get_Contiguity(C) + 1)); 25 | } 26 | 27 | void LengthOccupationRoutingContiguity::save(std::string SimConfigFileName) 28 | { 29 | RoutingCost::save(SimConfigFileName); 30 | } 31 | 32 | void LengthOccupationRoutingContiguity::print() 33 | { 34 | RoutingCost::print(); 35 | } 36 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/LengthOccupationRoutingAvailability.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace RMSA::ROUT; 6 | 7 | LengthOccupationRoutingAvailability::LengthOccupationRoutingAvailability( 8 | std::shared_ptr T) : 9 | RoutingCost(T, LORa) 10 | { 11 | 12 | } 13 | 14 | double LengthOccupationRoutingAvailability::get_Cost( 15 | std::weak_ptr link, 16 | std::shared_ptr) 17 | { 18 | if (!link.lock()->is_LinkActive()) 19 | { 20 | return std::numeric_limits::max(); 21 | } 22 | 23 | return 1.0 + link.lock()->Length / T->get_LengthLongestLink() - 24 | link.lock()->get_Availability() / (double) Link::NumSlots; 25 | } 26 | 27 | void LengthOccupationRoutingAvailability::save(std::string SimConfigFileName) 28 | { 29 | RoutingCost::save(SimConfigFileName); 30 | } 31 | 32 | void LengthOccupationRoutingAvailability::print() 33 | { 34 | RoutingCost::print(); 35 | } 36 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers/InLineAmplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEAMPLIFIER_H 2 | #define LINEAMPLIFIER_H 3 | 4 | #include 5 | 6 | namespace Devices 7 | { 8 | class Fiber; 9 | } 10 | 11 | namespace Devices { 12 | /** 13 | * @brief The InLineAmplifier class represents an In-Line Amplifier. 14 | * 15 | * Those amplifiers are scattered through the fiber. Each amplifier compensates 16 | * for the loss in the precedent fiber segment. 17 | */ 18 | class InLineAmplifier : public EDFA 19 | { 20 | public: 21 | /** 22 | * @brief AT is the type of amplifier. 23 | */ 24 | static constexpr AmplifierType AT = Amplifier::InLineAmplifierType; 25 | /** 26 | * @brief InLineAmplifier is the standard constructor for a InLineAmplifier. 27 | * @param Segment is a pointer to the precedent Fiber segment. This amplifier 28 | * will compensate for the loss in such segment. 29 | */ 30 | InLineAmplifier(Fiber &Segment); 31 | 32 | Gain &get_Gain(); 33 | 34 | std::shared_ptr clone(); 35 | 36 | }; 37 | } 38 | 39 | #endif // LINEAMPLIFIER_H 40 | -------------------------------------------------------------------------------- /src/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_GA.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_GA.h" 2 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Generation.h" 3 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Individual.h" 4 | #include "include/SimulationTypes/Simulation_FFE_Optimization.h" 5 | #include "include/Structure/Link.h" 6 | 7 | using namespace RMSA::SA::FFE; 8 | using namespace GeneticAlgorithm; 9 | 10 | FFE_GA::FFE_GA(Simulations::Simulation_FFE_Optimization &Sim) : GA(), Sim(Sim) 11 | { 12 | 13 | } 14 | 15 | void FFE_GA::createInitialGeneration() 16 | { 17 | auto initialEvol = std::make_shared(this); 18 | 19 | for (unsigned i = 0; i < numIndiv; ++i) 20 | { 21 | initialEvol->people.push_back(std::make_shared 22 | (initialEvol.get())); 23 | } 24 | 25 | evolution.push_back(initialEvol); 26 | } 27 | 28 | std::shared_ptr FFE_GA::createEmptyGeneration() 29 | { 30 | return std::make_shared(this); 31 | } 32 | -------------------------------------------------------------------------------- /include/GeneralClasses/PhysicalConstants.h: -------------------------------------------------------------------------------- 1 | #ifndef PHYSICALCONSTANTS_H 2 | #define PHYSICALCONSTANTS_H 3 | 4 | /** 5 | * @brief The PhysicalConstants class stores physical constants. 6 | */ 7 | class PhysicalConstants 8 | { 9 | public: 10 | /** 11 | * @brief c is the light's velocity. 12 | */ 13 | constexpr static double c = 299792458; 14 | /** 15 | * @brief h is the Planck's constant. 16 | */ 17 | constexpr static double h = 6.62606957E-34; 18 | /** 19 | * @brief lambda is the light's wavelength. 20 | */ 21 | constexpr static double lambda = 1550E-9; 22 | /** 23 | * @brief freq is the light's frequency; 24 | */ 25 | constexpr static double freq = 193.4E12; 26 | /** 27 | * @brief BRef is the reference bandwidth. 28 | */ 29 | static constexpr double BRef = 12.5E9; 30 | /** 31 | * @brief numPolarizations is used to choose whether 32 | * one or two polarizations are used to transmit the signal. 33 | */ 34 | constexpr static int numPolarizations = 2; 35 | }; 36 | 37 | #endif // PHYSICALCONSTANTS_H 38 | 39 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Algorithms/Yen_RoutingAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef YEN_ROUTINGALGORITHM_H 2 | #define YEN_ROUTINGALGORITHM_H 3 | 4 | #include "../RoutingAlgorithm.h" 5 | #include "include/RMSA/RoutingAlgorithms/Algorithms/Dijkstra_RoutingAlgorithm.h" 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | class Yen_RoutingAlgorithm : public RoutingAlgorithm 12 | { 13 | public: 14 | Yen_RoutingAlgorithm(std::shared_ptr T, 15 | RoutingCost::RoutingCosts Cost, 16 | bool runLoad); 17 | std::vector>> route(std::shared_ptr C); 18 | 19 | void load(); 20 | void save(std::string); 21 | void print(); 22 | /** 23 | * @brief kShortestPaths is the number of shortest paths that will be searched 24 | * by the KSP Algorithms, like Yen on Eppstein, if one of them is choosed. 25 | */ 26 | static unsigned int kShortestPaths; 27 | static bool hasLoaded; 28 | 29 | private: 30 | std::shared_ptr Dijkstra; 31 | }; 32 | } 33 | } 34 | 35 | #endif // YEN_ROUTINGALGORITHM_H 36 | -------------------------------------------------------------------------------- /include/Devices/Fiber.h: -------------------------------------------------------------------------------- 1 | #ifndef FIBER_H 2 | #define FIBER_H 3 | 4 | #include 5 | 6 | namespace Devices 7 | { 8 | /** 9 | * @brief The Fiber class represents a Fiber segment. 10 | */ 11 | class Fiber : public Device 12 | { 13 | public: 14 | /** 15 | * @brief alphaFiber is the fiber loss coefficient, measured in dB per 16 | * kilometer. 17 | */ 18 | static double alphaFiber; 19 | /** 20 | * @brief Fiber is the constructor for a Fiber device. 21 | * @param SpanLength is the length of the fiber, in kilometers. 22 | */ 23 | Fiber(double SpanLength); 24 | 25 | Gain &get_Gain(); 26 | Power &get_Noise(); 27 | std::shared_ptr get_TransferFunction(double); 28 | double get_CapEx(); 29 | double get_OpEx(); 30 | 31 | std::shared_ptr clone(); 32 | 33 | private: 34 | double SpanLength; 35 | Gain NetLoss; 36 | Power NoisePower; 37 | /** 38 | * @brief deviceTF is the device's transfer function. 39 | */ 40 | std::shared_ptr deviceTF; 41 | }; 42 | } 43 | 44 | #endif // FIBER_H 45 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_BlockingProbability.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETER_BLOCKINGPROBABILITY_H 2 | #define NSGA2_PARAMETER_BLOCKINGPROBABILITY_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/NSGA-2.h" 5 | 6 | namespace Simulations 7 | { 8 | class Simulation_NSGA2_RegnPlac; 9 | } 10 | 11 | namespace RMSA 12 | { 13 | namespace RP 14 | { 15 | namespace MORP 16 | { 17 | /** 18 | * @brief The NSGA2_Parameter_BlockingProbability class is a parameter to the 19 | * MORP algorithm, that implements the Call Request Blocking Probability parameter. 20 | */ 21 | class NSGA2_Parameter_BlockingProbability : public NSGA_II::NSGA2_Parameter 22 | { 23 | public: 24 | NSGA2_Parameter_BlockingProbability 25 | (std::vector gene, Simulations::Simulation_NSGA2_RegnPlac &Sim); 26 | double evaluate(); 27 | std::string get_ParamName() 28 | { 29 | return "Blocking Probability"; 30 | } 31 | 32 | private: 33 | Simulations::Simulation_NSGA2_RegnPlac &Sim; 34 | }; 35 | } 36 | } 37 | } 38 | 39 | #endif // NSGA2_PARAMETER_BLOCKINGPROBABILITY_H 40 | -------------------------------------------------------------------------------- /tests/Devices/FiberTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/Devices/Fiber.h" 4 | #include 5 | 6 | TEST(DevicesTest, FiberTest) 7 | { 8 | Devices::Fiber Fiber1(200); 9 | EXPECT_EQ(Fiber1.get_TransferFunction(1000)->get_TransmittanceAt(123), Fiber1.get_Gain()) << "Transfer function gain not being correctly set."; 10 | 11 | Devices::Fiber Fiber2(100); 12 | EXPECT_NE(Fiber1.get_Gain(), Fiber2.get_Gain()) << "Fiber loss not being correctly set."; 13 | EXPECT_EQ(Fiber1.get_Gain().in_dB(), 2 * Fiber2.get_Gain().in_dB()) << "Fiber gain should scale linearly."; 14 | 15 | std::shared_ptr Fiber3 = Fiber1.clone(); 16 | EXPECT_EQ(Fiber1.get_Gain(), Fiber3->get_Gain()) << "Fiber cloning not working correctly: gain unequal."; 17 | EXPECT_EQ(Fiber1.get_Noise(), Fiber3->get_Noise()) << "Fiber cloning not working correctly: noise unequal."; 18 | EXPECT_EQ(Fiber1.get_CapEx(), Fiber3->get_CapEx()) << "Fiber cloning not working correctly: CapEx unequal."; 19 | EXPECT_EQ(Fiber1.get_OpEx(), Fiber3->get_OpEx()) << "Fiber cloning not working correctly: OpEx unequal."; 20 | } 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_OpEx.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETER_OPEX_H 2 | #define NSGA2_PARAMETER_OPEX_H 3 | 4 | #include "include/GeneralPurposeAlgorithms/NSGA-2.h" 5 | 6 | namespace Simulations 7 | { 8 | class Simulation_NSGA2_RegnPlac; 9 | } 10 | 11 | namespace RMSA 12 | { 13 | namespace RP 14 | { 15 | //! Parameters that can be used by the MultiObjective Regenerator Placement algorithm. 16 | namespace MORP 17 | { 18 | /** 19 | * @brief The NSGA2_Parameter_OpEx class is a parameter to the MORP algorithm, 20 | * that implements the OpEx cost parameter. 21 | */ 22 | class NSGA2_Parameter_OpEx : public NSGA_II::NSGA2_Parameter 23 | { 24 | friend class Simulations::Simulation_NSGA2_RegnPlac; 25 | 26 | public: 27 | NSGA2_Parameter_OpEx(std::vector gene, 28 | Simulations::Simulation_NSGA2_RegnPlac &Sim); 29 | double evaluate(); 30 | std::string get_ParamName() 31 | { 32 | return "OpEx"; 33 | } 34 | 35 | private: 36 | Simulations::Simulation_NSGA2_RegnPlac &Sim; 37 | }; 38 | } 39 | } 40 | } 41 | 42 | #endif // NSGA2_PARAMETER_OPEX_H 43 | -------------------------------------------------------------------------------- /include/GeneralClasses/Transmittances/GaussianFilter.h: -------------------------------------------------------------------------------- 1 | #ifndef GAUSSIANFILTER_H 2 | #define GAUSSIANFILTER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace TF 8 | { 9 | /** 10 | * @brief The GaussianFilter class represents the transmittance of a Gaussian filter. 11 | */ 12 | class GaussianFilter : public Transmittance 13 | { 14 | public: 15 | /** 16 | * @brief GaussianFilter is a constructor for a GaussianFilter. 17 | * @param centerFreq is the central frequency of this filter. 18 | * @param filterOrder is the order of the gaussian filter. 19 | * @param scale is the scale of this filter. 20 | */ 21 | GaussianFilter(double centerFreq, unsigned int filterOrder, Gain scale); 22 | /** 23 | * @brief BW_3dB is the bandwidth of optical filter at 3dB. 24 | */ 25 | static constexpr double BW_3dB = 41e9; 26 | 27 | double &get_CenterFreq(); 28 | unsigned int &get_FilterOrder(); 29 | 30 | protected: 31 | double centerFreq; 32 | unsigned int filterOrder; 33 | std::map calculatedGains; 34 | }; 35 | } 36 | 37 | #endif // GAUSSIANFILTER_H 38 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Occupability.h: -------------------------------------------------------------------------------- 1 | #ifndef COST_OCCUPABILITY_H 2 | #define COST_OCCUPABILITY_H 3 | 4 | #include "Cost.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | /** 13 | * @brief The cOccupability class has, as cost, the number of occupied slots 14 | * on each link, normalized by the number of slots on each link. 15 | */ 16 | class cOccupability : public Cost 17 | { 18 | public: 19 | /** 20 | * @brief cOccupability is the standard constructor for the cOccupability cost. 21 | * @param NMin is the minimum exponent to the cost. 22 | * @param NMax is the maximum exponent to the cost. 23 | * @param T is the topology. 24 | */ 25 | cOccupability(int NMin, int NMax, std::shared_ptr T); 26 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr); 27 | double getUnitCost(std::weak_ptr link, std::shared_ptr); 28 | 29 | private: 30 | void createCache(); 31 | arma::mat cache; 32 | std::map unitCache; 33 | }; 34 | 35 | } 36 | } 37 | } 38 | 39 | #endif // COST_OCCUPABILITY_H 40 | 41 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/TensorialPowerSeriesRouting.h: -------------------------------------------------------------------------------- 1 | #ifndef TENSORIALPOWERSERIESROUTING_H 2 | #define TENSORIALPOWERSERIESROUTING_H 3 | 4 | #include "../PowerSeriesRouting.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | /** 13 | * @brief The TensorialPowerSeriesRouting class is a type of Power Series Routing 14 | * algorithm. Differently from MatricialPowerSeriesRouting, this PSR uses the 15 | * Krönecker product to produce, from a reduced set of coefficients, the large set 16 | * required to calculate the power series. 17 | */ 18 | class TensorialPowerSeriesRouting : public PowerSeriesRouting 19 | { 20 | public: 21 | TensorialPowerSeriesRouting(std::shared_ptr T); 22 | TensorialPowerSeriesRouting(std::shared_ptr T, 23 | std::vector> Costs); 24 | 25 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 26 | 27 | private: 28 | arma::mat coefs_matrix; 29 | void calculate_CoefsMatrix(); 30 | }; 31 | } 32 | } 33 | } 34 | 35 | #endif // TENSORIALPOWERSERIESROUTING_H 36 | -------------------------------------------------------------------------------- /include/RMSA/SpectrumAssignmentAlgorithms/FFE/FirstFitEvolutionary.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRSTFITEVOLUTIONARY_H 2 | #define FIRSTFITEVOLUTIONARY_H 3 | 4 | #include "../SpectrumAssignmentAlgorithm.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace SA 9 | { 10 | namespace FFE 11 | { 12 | class FirstFitEvolutionary : public SpectrumAssignmentAlgorithm 13 | { 14 | public: 15 | FirstFitEvolutionary(std::shared_ptr T); 16 | 17 | void load(); 18 | void save(std::string); 19 | std::map, 20 | std::vector>, 21 | std::owner_less>> 22 | assignSlots(std::shared_ptr C, TransparentSegment Seg); 23 | 24 | void setSlotsList(std::map > newSlotsList); 25 | static void setDefaultSlotsList(std::map > newSlotsList); 26 | 27 | private: 28 | static bool hasLoaded; 29 | bool hasSetSlots; 30 | static std::map> defaultSlotsList; 31 | 32 | static bool initDefaultList(std::string); 33 | 34 | std::map> slotsList; 35 | }; 36 | } 37 | } 38 | } 39 | 40 | #endif // FIRSTFITEVOLUTIONARY_H 41 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Availability.h: -------------------------------------------------------------------------------- 1 | #ifndef COST_AVAILABILITY 2 | #define COST_AVAILABILITY 3 | 4 | #include "Cost.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | 13 | /** 14 | * @brief The cAvailability class has, as cost, the number of free slots on 15 | * each link, normalized by the number of slots on each link. 16 | */ 17 | class cAvailability : public Cost 18 | { 19 | public: 20 | /** 21 | * @brief cAvailability is the standard constructor for the cAvailability cost. 22 | * @param NMin is the minimum exponent to the cost. 23 | * @param NMax is the maximum exponent to the cost. 24 | * @param T is the topology. 25 | */ 26 | cAvailability(int NMin, int NMax, std::shared_ptr T); 27 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr); 28 | double getUnitCost(std::weak_ptr link, std::shared_ptr); 29 | 30 | private: 31 | void createCache(); 32 | 33 | arma::mat cache; 34 | 35 | std::map unitCache; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif // COST_AVAILABILITY 43 | 44 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Distance.h: -------------------------------------------------------------------------------- 1 | #ifndef COST_DISTANCE 2 | #define COST_DISTANCE 3 | 4 | #include "Cost.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | namespace PSR 12 | { 13 | /** 14 | * @brief The cDistance class has, as cost, the length of the link, normalized 15 | * by the length of the longest link of the topology. 16 | */ 17 | class cDistance : public Cost 18 | { 19 | public: 20 | /** 21 | * @brief cDistance is the standard constructor for the cDistance cost. 22 | * @param NMin is the minimum exponent to the cost. 23 | * @param NMax is the maximum exponent to the cost. 24 | * @param T is the topology. 25 | */ 26 | cDistance(int NMin, int NMax, std::shared_ptr T); 27 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr); 28 | double getUnitCost(std::weak_ptr link, std::shared_ptr); 29 | 30 | private: 31 | void createCache(); 32 | std::map, arma::rowvec> cache; 33 | std::map, double> unitCache; 34 | }; 35 | 36 | } 37 | } 38 | } 39 | 40 | #endif // COST_DISTANCE 41 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Slots.h: -------------------------------------------------------------------------------- 1 | #ifndef CSLOTS_H 2 | #define CSLOTS_H 3 | 4 | #include "Cost.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | namespace PSR 12 | { 13 | 14 | /** 15 | * @brief The cSlots class has, as cost, the quantity of slots required by this 16 | * connection, normalized by the highest possible amount of slots required by 17 | * any connection. 18 | */ 19 | class cSlots : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cSlots is the standard constructor for the cSlots cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cSlots(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr, std::shared_ptr); 30 | double getUnitCost(std::weak_ptr, std::shared_ptr); 31 | 32 | private: 33 | void createCache(); 34 | std::map cache; 35 | std::map unitCache; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif // CSLOTS_H 43 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Bitrate.h: -------------------------------------------------------------------------------- 1 | #ifndef BITRATE_H 2 | #define BITRATE_H 3 | 4 | #include "Cost.h" 5 | #include 6 | #include 7 | 8 | namespace RMSA 9 | { 10 | namespace ROUT 11 | { 12 | namespace PSR 13 | { 14 | 15 | /** 16 | * @brief The cBitrate class has, as cost, the bitrate of the call, normalized 17 | * by the greatest bitrate possible. 18 | */ 19 | class cBitrate : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cBitrate is the standard constructor for the cBitrate cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cBitrate(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr, std::shared_ptr C); 30 | double getUnitCost(std::weak_ptr, std::shared_ptr C); 31 | 32 | private: 33 | void createCache(); 34 | std::map cache; 35 | std::map unitCache; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif // BITRATE_H 43 | -------------------------------------------------------------------------------- /tests/Structure/SlotTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "Structure/Slot.h" 4 | #include 5 | 6 | TEST(SlotTest, Constructor) 7 | { 8 | Slot S1(1); 9 | EXPECT_TRUE(S1.isFree) << "Slot should start as free."; 10 | 11 | Slot S2(S1); 12 | EXPECT_TRUE(S2.isFree) << "Slot should start as free."; 13 | EXPECT_EQ(S1.numSlot, S2.numSlot) << "Copy constructor not working as it should."; 14 | EXPECT_EQ(S1.isFree, S2.isFree) << "Copy constructor not working as it should."; 15 | 16 | Slot S3 = S1; 17 | EXPECT_TRUE(S3.isFree) << "Slot should start as free."; 18 | EXPECT_EQ(S1.numSlot, S3.numSlot) << "Assignment operator not working as it should."; 19 | EXPECT_EQ(S1.isFree, S3.isFree) << "Assignment operator not working as it should."; 20 | } 21 | 22 | TEST(SlotTest, Operations) 23 | { 24 | Slot S1(1); 25 | Slot S2(S1); 26 | 27 | S1.useSlot(); 28 | EXPECT_FALSE(S1.isFree) << "Slot should be occupied."; 29 | EXPECT_TRUE(S2.isFree) << "Slot should be free."; 30 | 31 | S1.freeSlot(); 32 | EXPECT_TRUE(S1.isFree) << "Slot should be free."; 33 | EXPECT_TRUE(S2.isFree) << "Slot should be free."; 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_CapEx.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_CapEx.h" 2 | #include "include/SimulationTypes/Simulation_NSGA2_RegnPlac.h" 3 | 4 | using namespace RMSA::RP::MORP; 5 | 6 | NSGA2_Parameter_CapEx::NSGA2_Parameter_CapEx 7 | (std::vector gene, Simulations::Simulation_NSGA2_RegnPlac &Sim) : 8 | NSGA2_Parameter(gene), Sim(Sim) 9 | { 10 | 11 | } 12 | 13 | double NSGA2_Parameter_CapEx::evaluate() 14 | { 15 | if (!isEvaluated) 16 | { 17 | Topology T(*Sim.T); 18 | 19 | for (size_t i = 0; i < gene.size(); i++) 20 | { 21 | if (gene[i] != 0) 22 | { 23 | T.Nodes[i]->set_NodeType(Node::TranslucentNode); 24 | } 25 | else 26 | { 27 | T.Nodes[i]->set_NodeType(Node::TransparentNode); 28 | } 29 | 30 | T.Nodes[i]->set_NumRegenerators(gene[i]); 31 | } 32 | 33 | value = T.get_CapEx(); 34 | isEvaluated = true; 35 | } 36 | 37 | return value; 38 | } 39 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_OpEx.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/RegeneratorPlacementAlgorithms/MultiObjectiveRegeneratorPlacement/NSGA2_Parameter_OpEx.h" 2 | #include "include/SimulationTypes/Simulation_NSGA2_RegnPlac.h" 3 | 4 | using namespace RMSA::RP::MORP; 5 | 6 | NSGA2_Parameter_OpEx::NSGA2_Parameter_OpEx(std::vector gene, 7 | Simulations::Simulation_NSGA2_RegnPlac &Sim) : 8 | NSGA2_Parameter(gene), Sim(Sim) 9 | { 10 | 11 | } 12 | 13 | double NSGA2_Parameter_OpEx::evaluate() 14 | { 15 | if (!isEvaluated) 16 | { 17 | Topology T(*Sim.T); 18 | 19 | for (size_t i = 0; i < gene.size(); i++) 20 | { 21 | if (gene[i] != 0) 22 | { 23 | T.Nodes[i]->set_NodeType(Node::TranslucentNode); 24 | } 25 | else 26 | { 27 | T.Nodes[i]->set_NodeType(Node::TransparentNode); 28 | } 29 | 30 | T.Nodes[i]->set_NumRegenerators(gene[i]); 31 | } 32 | 33 | value = T.get_OpEx(); 34 | isEvaluated = true; 35 | } 36 | 37 | return value; 38 | } 39 | -------------------------------------------------------------------------------- /src/Devices/Amplifiers/PreAmplifier.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace Devices; 7 | 8 | PreAmplifier::PreAmplifier(Fiber &Segment, Node &Destination) : EDFA(Gain(0)) , 9 | Destination(Destination), Segment(Segment) 10 | { 11 | numPorts = Destination.Links.size(); 12 | 13 | if (Destination.get_NodeArch() == Node::SwitchingSelect) 14 | { 15 | set_Gain(-SSS::SSSLoss - Segment.get_Gain()); 16 | } 17 | else 18 | { 19 | set_Gain( - Gain(1.0 / (numPorts + 1), Gain::Linear) - Segment.get_Gain()); 20 | } 21 | } 22 | 23 | Gain &PreAmplifier::get_Gain() 24 | { 25 | if (Destination.get_NodeArch() == Node::BroadcastAndSelect && 26 | Destination.Links.size() != numPorts) 27 | { 28 | numPorts = Destination.Links.size(); 29 | set_Gain( - Gain(1.0 / (numPorts + 1), Gain::Linear) - Segment.get_Gain()); 30 | } 31 | 32 | return AmplifierGain; 33 | } 34 | 35 | std::shared_ptr PreAmplifier::clone() 36 | { 37 | return std::shared_ptr(new PreAmplifier(*this)); 38 | } 39 | -------------------------------------------------------------------------------- /include/GeneralClasses/Transmittances/Transmittance.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSMITTANCE_H 2 | #define TRANSMITTANCE_H 3 | 4 | #include 5 | #include 6 | #include "include/GeneralClasses/Gain.h" 7 | 8 | 9 | //! Contains models for the transmittance of optical devices. 10 | namespace TF 11 | { 12 | /** 13 | * @brief The Transmittance class represents a transmittance of an optical device. 14 | */ 15 | class Transmittance 16 | { 17 | public: 18 | /** 19 | * @brief Transmittance is a constructor for a Transmittance. 20 | * @param scale is the result of the gains and losses over this transmittance. 21 | */ 22 | Transmittance(Gain scale); 23 | /** 24 | * @brief get_TransmittanceAt returns the value of this transmittance at 25 | * a frequency @param freq. 26 | * @param freq is the frequency where the transmittance is calculated. 27 | * @return the value of the transmittance at @param freq. 28 | */ 29 | virtual Gain& get_TransmittanceAt(double freq) = 0; 30 | Gain &get_Gain(); 31 | 32 | protected: 33 | /** 34 | * @brief scale is the result of the gains and losses over this transmittance. 35 | */ 36 | Gain scale; 37 | }; 38 | } 39 | 40 | #endif // TRANSMITTANCE_H 41 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/LocalPowerSeriesRouting.h: -------------------------------------------------------------------------------- 1 | #ifndef LOCALPOWERSERIESROUTING_H 2 | #define LOCALPOWERSERIESROUTING_H 3 | 4 | #include "../PowerSeriesRouting.h" 5 | #include 6 | #include 7 | 8 | namespace RMSA 9 | { 10 | namespace ROUT 11 | { 12 | namespace PSR 13 | { 14 | /** 15 | * @brief The LocalPowerSeriesRouting class represents the Local variant of the 16 | * Power Series Routing algorithm. Its similar to the MatricialPowerSeriesRouting, 17 | * but the set of coefficients to the power series is unique to each source 18 | * destination pair. 19 | */ 20 | class LocalPowerSeriesRouting : public PowerSeriesRouting 21 | { 22 | public: 23 | LocalPowerSeriesRouting(std::shared_ptr T); 24 | LocalPowerSeriesRouting(std::shared_ptr T, 25 | std::vector> Costs); 26 | double get_Cost(std::weak_ptr link, std::shared_ptr C); 27 | 28 | private: 29 | void calculateCoefficients(std::pair); 30 | std::map, arma::mat> coef_matrices; 31 | std::vector> origDestPairs; 32 | }; 33 | } 34 | } 35 | } 36 | 37 | #endif // LOCALPOWERSERIESROUTING_H 38 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Contiguity.h: -------------------------------------------------------------------------------- 1 | #ifndef COST_CONTIGUITY_H 2 | #define COST_CONTIGUITY_H 3 | 4 | #include "Cost.h" 5 | 6 | namespace RMSA 7 | { 8 | namespace ROUT 9 | { 10 | namespace PSR 11 | { 12 | 13 | /** 14 | * @brief The cContiguity class has, as cost, the contiguity measure of the 15 | * link. It only works on transparent networks. If sr is the number of 16 | * possible allocations of the call C in the Link link, then this cost is 17 | * 1.0 / (sr + 1). 18 | */ 19 | class cContiguity : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cContiguity is the standard constructor for the cContiguity cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cContiguity(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr C); 30 | double getUnitCost(std::weak_ptr link, std::shared_ptr C); 31 | 32 | private: 33 | void createCache(); 34 | arma::mat cache; 35 | std::map unitCache; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif // COST_CONTIGUITY_H 43 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers/PreAmplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef PREAMPLIFIER_H 2 | #define PREAMPLIFIER_H 3 | 4 | #include 5 | 6 | class Node; 7 | 8 | namespace Devices 9 | { 10 | class Fiber; 11 | } 12 | 13 | namespace Devices 14 | { 15 | /** 16 | * @brief The PreAmplifier class represents a Pre-Amplifier. 17 | * 18 | * In the current architecture such amplifier is on the node's entrance. It 19 | * compensates for the loss in the precedent fiber segment and for the loss in 20 | * the succedent switching element (either a SSS or a Splitter). 21 | */ 22 | class PreAmplifier : public EDFA 23 | { 24 | public: 25 | /** 26 | * @brief AT is the type of amplifier. 27 | */ 28 | static constexpr AmplifierType AT = Amplifier::PreAmplifierType; 29 | /** 30 | * @brief PreAmplifier is the standard constructor for a pre-amplifier 31 | * @param Segment is the precedent fiber segment. 32 | * @param Node is the owner Node of this PreAmplifier. 33 | */ 34 | PreAmplifier(Fiber &Segment, Node &Node); 35 | 36 | Gain &get_Gain(); 37 | std::shared_ptr clone(); 38 | 39 | private: 40 | unsigned numPorts; 41 | Node &Destination; 42 | Fiber &Segment; 43 | }; 44 | } 45 | 46 | #endif // PREAMPLIFIER_H 47 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Contiguity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | PSR::cContiguity::cContiguity(int NMin, int NMax, std::shared_ptr T) : 7 | Cost(NMin, NMax, T, Cost::contiguity) 8 | { 9 | cache = arma::ones(Link::NumSlots + 1, NMax - NMin + 1); 10 | createCache(); 11 | } 12 | 13 | arma::rowvec PSR::cContiguity::getCost(std::weak_ptr link, 14 | std::shared_ptr C) 15 | { 16 | return cache.row(link.lock()->get_Contiguity(C)); 17 | } 18 | 19 | double PSR::cContiguity::getUnitCost(std::weak_ptr link, std::shared_ptr C) 20 | { 21 | return unitCache[link.lock()->get_Contiguity(C)]; 22 | } 23 | 24 | void PSR::cContiguity::createCache() 25 | { 26 | for (int contig = 0; contig <= Link::NumSlots; contig++) 27 | { 28 | int expo = 0; 29 | double unitCost = 1.0 / (contig + 1); 30 | 31 | unitCache[contig] = unitCost; 32 | for (int n = NMin; n <= NMax; n++) 33 | { 34 | cache(contig, expo++) = pow(unitCost, n); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/GeneralClasses/TransmissionBitrateTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/GeneralClasses/TransmissionBitrate.h" 4 | #include 5 | 6 | TEST(TransmissionBitrateTest, Constructors) 7 | { 8 | TransmissionBitrate BR1(25E9); 9 | TransmissionBitrate BR2(BR1); 10 | 11 | EXPECT_EQ(BR1, BR2) << "Copy constructor not working as it should."; 12 | } 13 | 14 | TEST(TransmissionBitrateTest, Operations) 15 | { 16 | TransmissionBitrate BR1(10E9); 17 | TransmissionBitrate BR2(10E9); 18 | TransmissionBitrate BR3(100E9); 19 | 20 | EXPECT_EQ(BR1, BR2) << "A bitrate of " << BR1 << " should be equal to a bitrate of " << BR2 << "."; 21 | EXPECT_NE(BR1, BR3) << "A bitrate of " << BR1 << " should not be equal to a bitrate of " << BR3 << "."; 22 | 23 | EXPECT_LT(BR1, BR3) << "A bitrate of " << BR1 << " should be less than a bitrate of " << BR3 << "."; 24 | EXPECT_LE(BR1, BR3) << "A bitrate of " << BR1 << " should be less than or equal to a bitrate of " << BR3 << "."; 25 | EXPECT_GT(BR3, BR1) << "A bitrate of " << BR3 << " should be greater than a bitrate of " << BR1 << "."; 26 | EXPECT_GE(BR3, BR1) << "A bitrate of " << BR3 << " should be greater than or equal to a bitrate of " << BR1 << "."; 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorAssignmentAlgorithms/FirstLongestReach.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRSTLONGESTREACH_H 2 | #define FIRSTLONGESTREACH_H 3 | 4 | #include 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace RA 10 | { 11 | /** 12 | * @brief The FirstLongestReach class implements the First Longest Reach 13 | * RegeneratorAssignmentAlgorithm. 14 | * 15 | * This algorithm tries to perform the regeneration (if it is needed) as far as 16 | * possible from the source node. 17 | */ 18 | class FirstLongestReach : public RegeneratorAssignmentAlgorithm 19 | { 20 | public: 21 | /** 22 | * @brief FirstLongestReach is the standard constructor. 23 | * @param T is a pointer to the Topology. 24 | * @param ModulationSchemes is a set containing the possible ModulationScheme. 25 | */ 26 | FirstLongestReach(std::shared_ptr T, 27 | std::set ModulationSchemes); 28 | 29 | std::vector assignRegenerators( 30 | std::shared_ptr C, 31 | std::vector > Links); 32 | void load() {} 33 | void save(std::string); 34 | }; 35 | } 36 | } 37 | 38 | #endif // FIRSTLONGESTREACH_H 39 | -------------------------------------------------------------------------------- /data/topologies/Top1: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | node = 5 transparent ss 0 9 | node = 6 transparent ss 0 10 | node = 7 transparent ss 0 11 | node = 8 transparent ss 0 12 | node = 9 transparent ss 0 13 | node = 10 transparent ss 0 14 | node = 11 transparent ss 0 15 | node = 12 transparent ss 0 16 | 17 | [links] 18 | 19 | # -> = ORIGIN DESTINATION LENGTH 20 | -> = 1 2 730 21 | -> = 1 3 340 22 | -> = 2 1 730 23 | -> = 2 4 690 24 | -> = 2 5 620 25 | -> = 2 6 1830 26 | -> = 3 1 340 27 | -> = 3 4 540 28 | -> = 3 8 740 29 | -> = 4 2 690 30 | -> = 4 3 540 31 | -> = 4 9 200 32 | -> = 5 2 620 33 | -> = 5 7 870 34 | -> = 5 10 840 35 | -> = 6 2 1830 36 | -> = 6 7 370 37 | -> = 7 5 870 38 | -> = 7 6 370 39 | -> = 7 11 1100 40 | -> = 8 3 740 41 | -> = 8 9 280 42 | -> = 8 12 180 43 | -> = 9 4 200 44 | -> = 9 8 280 45 | -> = 9 10 440 46 | -> = 9 12 160 47 | -> = 10 5 840 48 | -> = 10 9 440 49 | -> = 10 11 830 50 | -> = 10 12 500 51 | -> = 11 7 1100 52 | -> = 11 10 830 53 | -> = 11 12 1330 54 | -> = 12 8 180 55 | -> = 12 9 160 56 | -> = 12 10 500 57 | -> = 12 11 1330 58 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_ModulationScheme.h: -------------------------------------------------------------------------------- 1 | #ifndef CMODULATIONSCHEME_H 2 | #define CMODULATIONSCHEME_H 3 | 4 | #include "Cost.h" 5 | #include 6 | #include 7 | 8 | namespace RMSA 9 | { 10 | namespace ROUT 11 | { 12 | namespace PSR 13 | { 14 | 15 | /** 16 | * @brief The cModulationScheme class has, as cost, the modulation scheme used 17 | * by this connection, normalized by the greatest modulation scheme available. 18 | */ 19 | class cModulationScheme : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cModulationScheme is the standard constructor for the cModulationScheme cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cModulationScheme(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr, std::shared_ptr); 30 | double getUnitCost(std::weak_ptr, std::shared_ptr); 31 | 32 | private: 33 | void createCache(); 34 | std::map cache; 35 | std::map unitCache; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif // CMODULATIONSCHEME_H 43 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_NormalizedContiguity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | PSR::cNormContiguity::cNormContiguity( 7 | int NMin, int NMax, std::shared_ptr T) : 8 | Cost(NMin, NMax, T, Cost::normcontiguity) 9 | { 10 | cache = arma::ones(Link::NumSlots + 1, NMax - NMin + 1); 11 | createCache(); 12 | } 13 | 14 | arma::rowvec PSR::cNormContiguity::getCost(std::weak_ptr link, 15 | std::shared_ptr C) 16 | { 17 | return cache.row(link.lock()->get_Contiguity(C)); 18 | } 19 | 20 | double PSR::cNormContiguity::getUnitCost(std::weak_ptr link, std::shared_ptr C) 21 | { 22 | return unitCache[link.lock()->get_Contiguity(C)]; 23 | } 24 | 25 | void PSR::cNormContiguity::createCache() 26 | { 27 | for (int contig = 0; contig <= Link::NumSlots; contig++) 28 | { 29 | int expo = 0; 30 | double unitCost = contig / (1.0 * Link::NumSlots); 31 | 32 | unitCache[contig] = unitCost; 33 | for (int n = NMin; n <= NMax; n++) 34 | { 35 | cache(contig, expo++) = pow(unitCost, n); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorAssignmentAlgorithms/FirstNarrowestSpectrum.h: -------------------------------------------------------------------------------- 1 | #ifndef FIRSTNARROWESTSPECTRUM_H 2 | #define FIRSTNARROWESTSPECTRUM_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace RA 9 | { 10 | /** 11 | * @brief The FirstNarrowestSpectrum class implements the First Narrowest Spectrum 12 | * RegeneratorAssignmentAlgorithm. 13 | * 14 | * The algorithm tries to save spectrum in the network by always trying to use 15 | * the highest allowed spectral efficiency modulation format in the TransparentSegment. 16 | */ 17 | class FirstNarrowestSpectrum : public RegeneratorAssignmentAlgorithm 18 | { 19 | public: 20 | /** 21 | * @brief FirstNarrowestSpectrum is the standard constructor. 22 | * @param T is a pointer to the Topology. 23 | * @param Schemes is a vector containing the possible ModulationScheme. 24 | */ 25 | FirstNarrowestSpectrum(std::shared_ptr T, 26 | std::set Schemes); 27 | std::vector assignRegenerators( 28 | std::shared_ptr C, 29 | std::vector> Links); 30 | void load() {} 31 | void save(std::string); 32 | }; 33 | } 34 | } 35 | 36 | #endif // FIRSTNARROWESTSPECTRUM_H 37 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Distance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::ROUT; 8 | 9 | PSR::cDistance::cDistance(int NMin, int NMax, std::shared_ptr T) : 10 | Cost(NMin, NMax, T, Cost::distance) 11 | { 12 | createCache(); 13 | } 14 | 15 | arma::rowvec PSR::cDistance::getCost(std::weak_ptr link, 16 | std::shared_ptr) 17 | { 18 | return cache.at(link.lock()); 19 | } 20 | 21 | double PSR::cDistance::getUnitCost(std::weak_ptr link, std::shared_ptr) 22 | { 23 | return unitCache[link.lock()]; 24 | } 25 | 26 | void PSR::cDistance::createCache() 27 | { 28 | for (auto link : T->Links) 29 | { 30 | cache.emplace(link.second, arma::ones(NMax - NMin + 1)); 31 | 32 | int expo = 0; 33 | double unitCost = link.second->Length / T->get_LengthLongestLink(); 34 | 35 | unitCache[link.second] = unitCost; 36 | for (int n = NMin; n <= NMax; n++) 37 | { 38 | cache.at(link.second)(expo++) = pow(unitCost, n); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/NX_RegeneratorPlacement.h: -------------------------------------------------------------------------------- 1 | #ifndef NX_REGENERATORPLACEMENT_H 2 | #define NX_REGENERATORPLACEMENT_H 3 | 4 | #include 5 | 6 | namespace RMSA 7 | { 8 | namespace RP 9 | { 10 | /** 11 | * @brief The NX_RegeneratorPlacement class is a type of RegeneratorPlacementAlgorithm. 12 | */ 13 | class NX_RegeneratorPlacement : public RegeneratorPlacementAlgorithm 14 | { 15 | public: 16 | /** 17 | * @brief NX_RegeneratorPlacement is the standard constructor. 18 | * @param T is a pointer to the Topology. 19 | */ 20 | NX_RegeneratorPlacement(std::shared_ptr T); 21 | 22 | /** 23 | * @brief placeRegenerators inserts the regenerators in the network. 24 | * @param N is the number of translucent nodes. 25 | * @param X is the number of regenerators per translucent node. 26 | */ 27 | virtual void placeRegenerators(unsigned N = NX_N, unsigned X = NX_X) = 0; 28 | 29 | virtual void load() = 0; 30 | 31 | /** 32 | * @brief NX_N is the number of translucent nodes. 33 | */ 34 | unsigned static NX_N; 35 | /** 36 | * @brief NX_X is the number of regenerators per node. 37 | */ 38 | unsigned static NX_X; 39 | }; 40 | } 41 | } 42 | 43 | #endif // NX_REGENERATORPLACEMENT_H 44 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Availability.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace RMSA::ROUT; 7 | 8 | PSR::cAvailability::cAvailability(int NMin, int NMax, 9 | std::shared_ptr T) 10 | : Cost(NMin, NMax, T, Cost::availability) 11 | { 12 | cache = arma::ones(Link::NumSlots + 1, NMax - NMin + 1); 13 | createCache(); 14 | } 15 | 16 | arma::rowvec PSR::cAvailability::getCost(std::weak_ptr link, 17 | std::shared_ptr) 18 | { 19 | return cache.row(link.lock()->get_Availability()); 20 | } 21 | 22 | double PSR::cAvailability::getUnitCost(std::weak_ptr link, std::shared_ptr) 23 | { 24 | return unitCache[link.lock()->get_Availability()]; 25 | } 26 | 27 | void PSR::cAvailability::createCache() 28 | { 29 | for (int avail = 0; avail <= Link::NumSlots; avail++) 30 | { 31 | int expo = 0; 32 | double unitCost = avail / (double) Link::NumSlots; 33 | 34 | unitCache[avail] = unitCost; 35 | for (int n = NMin; n <= NMax; n++) 36 | { 37 | cache(avail, expo++) = pow(unitCost, n); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Occupability.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace RMSA::ROUT; 7 | 8 | PSR::cOccupability::cOccupability(int NMin, int NMax, 9 | std::shared_ptr T) 10 | : Cost(NMin, NMax, T, Cost::occupability) 11 | { 12 | cache = arma::ones(Link::NumSlots + 1, NMax - NMin + 1); 13 | createCache(); 14 | } 15 | 16 | arma::rowvec PSR::cOccupability::getCost(std::weak_ptr link, 17 | std::shared_ptr) 18 | { 19 | return cache.row(link.lock()->get_Occupability()); 20 | } 21 | 22 | double PSR::cOccupability::getUnitCost(std::weak_ptr link, std::shared_ptr) 23 | { 24 | return unitCache[link.lock()->get_Occupability()]; 25 | } 26 | 27 | void PSR::cOccupability::createCache() 28 | { 29 | for (int occup = 0; occup <= Link::NumSlots; occup++) 30 | { 31 | int expo = 0; 32 | double unitCost = occup / (double) Link::NumSlots; 33 | 34 | unitCache[occup] = unitCost; 35 | for (int n = NMin; n <= NMax; n++) 36 | { 37 | cache(occup, expo++) = pow(unitCost, n); 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_OrigDestIndex.h: -------------------------------------------------------------------------------- 1 | #ifndef CORIGDESTINDEX_H 2 | #define CORIGDESTINDEX_H 3 | 4 | #include 5 | #include "Cost.h" 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | namespace PSR 12 | { 13 | 14 | /** 15 | * @brief The cOrigDestIndex class has, as cost, the index of this origin destination 16 | * pair. The pairs are put in a crescent list [0-1 0-2 ... 1-0 1-2 ... N-(N-1) ], 17 | * with N * (N-1) elements. Each origin destination pair will have, as cost, its 18 | * index on the list normalized by N * (N-1). 19 | */ 20 | class cOrigDestIndex : public Cost 21 | { 22 | public: 23 | /** 24 | * @brief cOrigDestIndex is the standard constructor for the cOrigDestIndex cost. 25 | * @param NMin is the minimum exponent to the cost. 26 | * @param NMax is the maximum exponent to the cost. 27 | * @param T is the topology. 28 | */ 29 | cOrigDestIndex(int NMin, int NMax, std::shared_ptr T); 30 | arma::rowvec getCost(std::weak_ptr, std::shared_ptr); 31 | double getUnitCost(std::weak_ptr, std::shared_ptr); 32 | 33 | private: 34 | void createCache(); 35 | std::map, arma::rowvec> cache; 36 | std::map, double> unitCache; 37 | }; 38 | } 39 | } 40 | } 41 | 42 | #endif // CORIGDESTINDEX_H 43 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MostUsed.h: -------------------------------------------------------------------------------- 1 | #ifndef MOSTUSED_H 2 | #define MOSTUSED_H 3 | 4 | #include 5 | #include 6 | 7 | class RoutingWavelengthAssignment; 8 | 9 | namespace RMSA 10 | { 11 | namespace RP 12 | { 13 | /** 14 | * @brief The MostUsed class is the standard constructor for the Most Used RP 15 | * algorithm. 16 | * 17 | * It runs an opaque simulation, and computes how many regenerators were used on 18 | * each node. Then, it allocates regenerators on the N that were most used, and 19 | * puts X regenerators on each one. 20 | */ 21 | class MostUsed : public NX_RegeneratorPlacement 22 | { 23 | public: 24 | MostUsed(std::shared_ptr T, 25 | std::shared_ptr RMSA, 26 | double NetworkLoad, 27 | long long unsigned NumCalls = 1E6, 28 | std::vector Bitrates = TransmissionBitrate::DefaultBitrates 29 | ); 30 | 31 | void placeRegenerators(unsigned N, unsigned X); 32 | void load(); 33 | 34 | private: 35 | std::shared_ptr RMSA; 36 | double NetworkLoad; 37 | long long unsigned NumCalls; 38 | std::vector Bitrates; 39 | }; 40 | } 41 | } 42 | 43 | #endif // MOSTUSED_H 44 | -------------------------------------------------------------------------------- /include/Devices/Splitter.h: -------------------------------------------------------------------------------- 1 | #ifndef SPLITTER_H 2 | #define SPLITTER_H 3 | 4 | #include 5 | 6 | class Node; 7 | 8 | namespace Devices 9 | { 10 | /** 11 | * @brief The Splitter class represents a splitter. Is only used with the 12 | * Broadcast-And-Select node architecture. 13 | */ 14 | class Splitter : public Device 15 | { 16 | public: 17 | /** 18 | * @brief Splitter is the standard constructor for a splitter. 19 | * @param NumPorts is the number of ports of the splitter. 20 | */ 21 | Splitter(Node *parent); 22 | 23 | Gain &get_Gain(); 24 | Power &get_Noise(); 25 | std::shared_ptr get_TransferFunction(double); 26 | double get_CapEx(); 27 | double get_OpEx(); 28 | 29 | std::shared_ptr clone(); 30 | 31 | /** 32 | * @brief set_NumPorts is used to reconfigure the number of ports of this 33 | * Splitter. Is called, for example, when a new link is added to the owner Node. 34 | * @param NumPorts is the new number of ports of this Splitter. 35 | */ 36 | void set_NumPorts(int NumPorts); 37 | 38 | private: 39 | Node *parent; 40 | unsigned int NumPorts; 41 | Gain SplitterLoss; 42 | Power NoisePower; 43 | /** 44 | * @brief deviceTF is the device's transfer function. 45 | */ 46 | std::shared_ptr deviceTF; 47 | }; 48 | } 49 | 50 | #endif // SPLITTER_H 51 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_FFE_Optimization.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_FFE_OPTIMIZATION_H 2 | #define SIMULATION_FFE_OPTIMIZATION_H 3 | 4 | #include "SimulationType.h" 5 | #include "RMSA.h" 6 | 7 | namespace RMSA 8 | { 9 | namespace SA 10 | { 11 | namespace FFE 12 | { 13 | class FFE_GA; 14 | } 15 | } 16 | } 17 | 18 | namespace Simulations 19 | { 20 | class Simulation_FFE_Optimization : public SimulationType 21 | { 22 | public: 23 | Simulation_FFE_Optimization(); 24 | 25 | void help(); 26 | void run(); 27 | void load(); 28 | void save(std::string); 29 | void load_file(std::string); 30 | void print(); 31 | 32 | bool hasLoaded; 33 | double NumCalls; 34 | double OptimizationLoad; 35 | 36 | std::string CoefficientsFilename; 37 | std::string LogFilename; 38 | 39 | RMSA::ROUT::RoutingAlgorithm::RoutingAlgorithms Routing_Algorithm; 40 | RMSA::ROUT::RoutingCost::RoutingCosts Routing_Cost; 41 | RMSA::RP::RegeneratorPlacementAlgorithm::RegeneratorPlacementAlgorithms 42 | RegPlacement_Algorithm; 43 | RMSA::RA::RegeneratorAssignmentAlgorithm::RegeneratorAssignmentAlgorithms 44 | RegAssignment_Algorithm; 45 | 46 | void place_Regenerators(std::shared_ptr T); 47 | 48 | private: 49 | std::shared_ptr FFE_GA_Optimization; 50 | void printCoefficients(std::string); 51 | }; 52 | } 53 | 54 | #endif // SIMULATION_FFE_OPTIMIZATION_H 55 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_LinkLength.h: -------------------------------------------------------------------------------- 1 | #ifndef CLINKLENGTH_H 2 | #define CLINKLENGTH_H 3 | 4 | #include "Cost.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | namespace PSR 12 | { 13 | 14 | /** 15 | * @brief The cLinkLength class has, as cost, how big this link is compared to the 16 | * other links in the topology. The links are put in crescent order, from 0 to N, 17 | * and then the i-th link on the list will have i/N as cost. 18 | */ 19 | class cLinkLength : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cLinkLength is the standard constructor for the cLinkLength cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cLinkLength(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr); 30 | double getUnitCost(std::weak_ptr link, std::shared_ptr); 31 | 32 | private: 33 | void createCache(); 34 | std::map, arma::rowvec> cache; 35 | std::map, double> unitCache; 36 | 37 | struct Comparator 38 | { 39 | std::weak_ptr link; 40 | bool operator <(const Comparator &) const; 41 | }; 42 | }; 43 | 44 | } 45 | } 46 | } 47 | 48 | #endif // CLINKLENGTH_H 49 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_NormalizedContiguity.h: -------------------------------------------------------------------------------- 1 | #ifndef COST_NORMALIZEDCONTIGUITY_H 2 | #define COST_NORMALIZEDCONTIGUITY_H 3 | 4 | #include "Cost.h" 5 | #include "GeneralClasses/TransmissionBitrate.h" 6 | #include "GeneralClasses/ModulationScheme.h" 7 | #include 8 | 9 | namespace RMSA 10 | { 11 | namespace ROUT 12 | { 13 | namespace PSR 14 | { 15 | 16 | /** 17 | * @brief The cNormContiguity class has, as cost, the contiguity 18 | * measure of the link. It only works on transparent networks. If sr is the 19 | * number of possible allocations of the call C in the Link link, then this 20 | * cost is sr / SR. 21 | */ 22 | class cNormContiguity : public Cost 23 | { 24 | public: 25 | /** 26 | * @brief cNormContiguity is the standard constructor for the cNormContiguity cost. 27 | * @param NMin is the minimum exponent to the cost. 28 | * @param NMax is the maximum exponent to the cost. 29 | * @param T is the topology. 30 | */ 31 | cNormContiguity(int NMin, int NMax, std::shared_ptr T); 32 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr C); 33 | double getUnitCost(std::weak_ptr link, std::shared_ptr C); 34 | 35 | private: 36 | void createCache(); 37 | arma::mat cache; 38 | std::map unitCache; 39 | }; 40 | 41 | } 42 | } 43 | } 44 | 45 | #endif // COST_NORMALIZEDCONTIGUITY_H 46 | 47 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/AdaptativeWeighingRouting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace RMSA::ROUT::PSR; 6 | 7 | AdaptativeWeighingRouting::AdaptativeWeighingRouting 8 | (std::shared_ptr T) : PowerSeriesRouting(T, RoutingCost::AWR) 9 | { 10 | Variant = Variant_AWR; 11 | } 12 | 13 | AdaptativeWeighingRouting::AdaptativeWeighingRouting(std::shared_ptr 14 | T, std::vector> Costs) : 15 | PowerSeriesRouting(T, Costs, RoutingCost::AWR) 16 | { 17 | Variant = Variant_AWR; 18 | } 19 | 20 | double AdaptativeWeighingRouting::get_Cost( 21 | std::weak_ptr link, std::shared_ptr C) 22 | { 23 | if (!link.lock()->is_LinkActive()) 24 | { 25 | return std::numeric_limits::max(); 26 | } 27 | 28 | double Cost = 0; 29 | 30 | //Spherical coordinates for a n-sphere that represents the possible values that the AWR can take. 31 | double Sines = 1; 32 | 33 | for (size_t n = 0; n < Costs.size(); ++n) 34 | { 35 | Cost += Costs[n]->getCost(1, link, C) * std::cos(coefficients.at(n)) * Sines; 36 | Sines *= std::sin(coefficients.at(n)); 37 | } 38 | 39 | return Cost; 40 | } 41 | -------------------------------------------------------------------------------- /data/topologies/NSFNet: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | node = 5 transparent ss 0 9 | node = 6 transparent ss 0 10 | node = 7 transparent ss 0 11 | node = 8 transparent ss 0 12 | node = 9 transparent ss 0 13 | node = 10 transparent ss 0 14 | node = 11 transparent ss 0 15 | node = 12 transparent ss 0 16 | node = 13 transparent ss 0 17 | node = 14 transparent ss 0 18 | 19 | [links] 20 | 21 | # -> = ORIGIN DESTINATION LENGTH 22 | -> = 1 2 1136 23 | -> = 1 3 1702 24 | -> = 1 8 2838 25 | -> = 2 1 1136 26 | -> = 2 3 683 27 | -> = 2 4 959 28 | -> = 3 1 1702 29 | -> = 3 2 683 30 | -> = 3 6 2049 31 | -> = 4 2 959 32 | -> = 4 5 573 33 | -> = 4 11 2349 34 | -> = 5 4 573 35 | -> = 5 6 1450 36 | -> = 5 7 732 37 | -> = 6 3 2049 38 | -> = 6 5 1450 39 | -> = 6 10 1128 40 | -> = 6 14 1976 41 | -> = 7 5 732 42 | -> = 7 8 718 43 | -> = 8 1 2838 44 | -> = 8 7 718 45 | -> = 8 9 706 46 | -> = 9 8 706 47 | -> = 9 10 839 48 | -> = 9 12 366 49 | -> = 9 13 451 50 | -> = 10 6 1128 51 | -> = 10 9 839 52 | -> = 11 4 2349 53 | -> = 11 12 596 54 | -> = 11 13 789 55 | -> = 12 9 366 56 | -> = 12 11 596 57 | -> = 12 14 385 58 | -> = 13 9 451 59 | -> = 13 11 789 60 | -> = 13 14 246 61 | -> = 14 6 1976 62 | -> = 14 12 385 63 | -> = 14 13 246 64 | -------------------------------------------------------------------------------- /src/Structure/Slot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | Slot::Slot(int numSlot) : numSlot(numSlot), isFree(true) 7 | { 8 | double centerFreq = PhysicalConstants::freq + 9 | BSlot * (numSlot - (Link::NumSlots / 2)); 10 | S = std::make_shared(centerFreq - BSlot / 2.0, 11 | centerFreq + BSlot / 2.0, 12 | (int) samplesPerSlot, true); 13 | } 14 | 15 | void Slot::freeSlot() 16 | { 17 | #ifdef RUN_ASSERTIONS 18 | if (isFree) 19 | { 20 | std::cerr << "Only occupied slots can be freed." << std::endl; 21 | abort(); 22 | } 23 | #endif 24 | isFree = true; 25 | S->specDensity.zeros(); 26 | } 27 | 28 | void Slot::useSlot() 29 | { 30 | #ifdef RUN_ASSERTIONS 31 | if (!isFree) 32 | { 33 | std::cerr << "Only occupied slots can be used." << std::endl; 34 | abort(); 35 | } 36 | #endif 37 | isFree = false; 38 | } 39 | 40 | Slot::Slot(const Slot &slot) 41 | { 42 | numSlot = slot.numSlot; 43 | isFree = slot.isFree; 44 | } 45 | 46 | Slot &Slot::operator =(const Slot &slot) 47 | { 48 | if (this != &slot) 49 | { 50 | numSlot = slot.numSlot; 51 | isFree = slot.isFree; 52 | } 53 | 54 | return *this; 55 | } 56 | -------------------------------------------------------------------------------- /src/Devices/Splitter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace Devices; 6 | using namespace TF; 7 | 8 | Splitter::Splitter(Node *parent) : Device(Device::SplitterDevice), 9 | parent(parent), 10 | NumPorts(parent->Neighbours.size()), 11 | SplitterLoss(1.0 / (NumPorts + 1), Gain::Linear), 12 | NoisePower(0, Power::Watt) 13 | { 14 | deviceTF = std::make_shared(get_Gain()); 15 | } 16 | 17 | Gain &Splitter::get_Gain() 18 | { 19 | if (NumPorts != parent->Neighbours.size()) 20 | { 21 | set_NumPorts(parent->Neighbours.size()); 22 | } 23 | return SplitterLoss; 24 | } 25 | 26 | Power &Splitter::get_Noise() 27 | { 28 | return NoisePower; 29 | } 30 | 31 | void Splitter::set_NumPorts(int NumPorts) 32 | { 33 | this->NumPorts = NumPorts; 34 | SplitterLoss = Gain(1.0 / (NumPorts + 1), Gain::Linear); 35 | deviceTF = std::make_shared(get_Gain()); 36 | } 37 | 38 | std::shared_ptr Splitter::clone() 39 | { 40 | return std::shared_ptr(new Splitter(parent)); 41 | } 42 | 43 | double Splitter::get_CapEx() 44 | { 45 | return 0.05; 46 | } 47 | 48 | double Splitter::get_OpEx() 49 | { 50 | return 0.2; 51 | } 52 | 53 | std::shared_ptr Splitter::get_TransferFunction(double) 54 | { 55 | return deviceTF; 56 | } 57 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/NX_MostSimultaneouslyUsed.h: -------------------------------------------------------------------------------- 1 | #ifndef NX_MOSTSIMULTANEOUSLYUSED_H 2 | #define NX_MOSTSIMULTANEOUSLYUSED_H 3 | 4 | #include "NX_RegeneratorPlacement.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | class RoutingWavelengthAssignment; 10 | 11 | namespace RP 12 | { 13 | /** 14 | * @brief The NX_MostSimultaneouslyUsed class is a variant of the MostSimultaneouslyUsed 15 | * RP algorithm that is NX. 16 | */ 17 | class NX_MostSimultaneouslyUsed : public NX_RegeneratorPlacement 18 | { 19 | public: 20 | /** 21 | * @brief NX_MostSimultaneouslyUsed is the standard constructor for the 22 | * NX_MostSimultaneouslyUsed RP algorithm. 23 | */ 24 | NX_MostSimultaneouslyUsed(std::shared_ptr T, 25 | std::shared_ptr RMSA, 26 | double NetworkLoad, 27 | long long unsigned NumCalls, 28 | std::vector Bitrates = 29 | TransmissionBitrate::DefaultBitrates); 30 | 31 | void placeRegenerators(unsigned N, unsigned X); 32 | void load(); 33 | 34 | private: 35 | std::shared_ptr RMSA; 36 | double NetworkLoad; 37 | long long unsigned NumCalls; 38 | std::vector Bitrates; 39 | 40 | }; 41 | } 42 | } 43 | 44 | #endif // NX_MOSTSIMULTANEOUSLYUSED_H 45 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_ModulationScheme.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | PSR::cModulationScheme::cModulationScheme( 7 | int NMin, int NMax, std::shared_ptr T) : 8 | Cost(NMin, NMax, T, Cost::scheme) 9 | { 10 | createCache(); 11 | } 12 | 13 | arma::rowvec PSR::cModulationScheme::getCost(std::weak_ptr, 14 | std::shared_ptr C) 15 | { 16 | return cache[C->Scheme]; 17 | } 18 | 19 | double PSR::cModulationScheme::getUnitCost(std::weak_ptr, std::shared_ptr C) 20 | { 21 | return unitCache[C->Scheme]; 22 | } 23 | 24 | void PSR::cModulationScheme::createCache() 25 | { 26 | double maxScheme = -1; 27 | 28 | for (auto &scheme : ModulationScheme::DefaultSchemes) 29 | { 30 | if (maxScheme < scheme.get_M()) 31 | { 32 | maxScheme = scheme.get_M(); 33 | } 34 | } 35 | 36 | for (auto &scheme : ModulationScheme::DefaultSchemes) 37 | { 38 | cache.emplace(scheme, arma::rowvec(NMax - NMin + 1)); 39 | 40 | int expo = 0; 41 | double unitCost = scheme.get_M() / maxScheme; 42 | 43 | unitCache[scheme] = unitCost; 44 | for (int n = NMin; n <= NMax; n++) 45 | { 46 | cache.at(scheme)(expo++) = pow(unitCost, n); 47 | } 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /tests/GeneralPurposeAlgorithms/IntegrationMethods/TrapezoidalRuleTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/GeneralPurposeAlgorithms/IntegrationMethods/TrapezoidalRule.h" 4 | #include 5 | #include 6 | 7 | TEST(IntegrationMethodTest, TrapezoidalRule) 8 | { 9 | NumericMethods::TrapezoidalRule TR; 10 | 11 | EXPECT_EQ(TR.calculate({0, 0, 0}, 100), 0) << "The integral of zero should be zero."; 12 | EXPECT_EQ(TR.calculate({1, 2, 3, 4}, 0), 0) << "The integral of a interval with zero length should be zero."; 13 | 14 | EXPECT_GT(TR.calculate({1, 2, 3}, 3.7), 0) << "The integral of a strictly positive function over a positive range should be positive."; 15 | EXPECT_LT(TR.calculate({ -1, -2, -3}, 3.7), 0) << "The integral of a strictly negative function over a positive range should be negative."; 16 | EXPECT_LT(TR.calculate({1, 2, 3}, -3.7), 0) << "The integral of a strictly positive function over a negative range should be negative."; 17 | EXPECT_GT(TR.calculate({ -1, -2, -3}, -3.7), 0) << "The integral of a strictly negative function over a negative range should be positive."; 18 | 19 | EXPECT_EQ(TR.calculate({1, 6, 3, 7}, 4), TR.calculate({ -1, -6, -3, -7}, -4)) << "The integral of -f(x) over -dx should be equal to the integral of f(x) over dx."; 20 | EXPECT_EQ(TR.calculate({1, 6, 3, 7}, 4), -TR.calculate({ -1, -6, -3, -7}, 4)) << "The integral of -f(x) over -dx should be minus the integral of f(x) over dx."; 21 | } 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/NSGA-II/NSGA2_Parameter.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_PARAMETER_H 2 | #define NSGA2_PARAMETER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace NSGA_II 8 | { 9 | /** 10 | * @brief The NSGA2_Parameter class represents a Parameter to a NSGA2_Individual. 11 | */ 12 | class NSGA2_Parameter 13 | { 14 | friend class NSGA2; 15 | 16 | public: 17 | /** 18 | * @brief NSGA2_Parameter is the default constructor. 19 | * @param gene is the Individual's genes. 20 | */ 21 | NSGA2_Parameter(std::vector gene); 22 | /** 23 | * @brief evaluate evaluates this Parameter. 24 | * @return the result of the evaluation. 25 | */ 26 | virtual double evaluate() = 0; 27 | /** 28 | * @brief get_ParamName returns the name of this Parameter. 29 | * @return the name of this Parameter. 30 | */ 31 | virtual std::string get_ParamName() = 0; 32 | /** 33 | * @brief operator == compairs two Parameters for equality. 34 | * @param other is the other Parameter. 35 | * @return true iff the value is equal. 36 | */ 37 | bool operator == (const NSGA2_Parameter &other) const; 38 | /** 39 | * @brief setValue sets the value of this parameter. 40 | * @param value is the new value of this parameter. 41 | */ 42 | void setValue(double value); 43 | 44 | protected: 45 | bool isEvaluated; 46 | double value; 47 | std::vector gene; 48 | }; 49 | } 50 | 51 | #endif // NSGA2_PARAMETER_H 52 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Bitrate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Calls.h" 4 | 5 | using namespace RMSA::ROUT; 6 | 7 | PSR::cBitrate::cBitrate(int NMin, int NMax, std::shared_ptr T) : 8 | Cost(NMin, NMax, T, Cost::bitrate) 9 | { 10 | createCache(); 11 | } 12 | 13 | arma::rowvec PSR::cBitrate::getCost(std::weak_ptr, 14 | std::shared_ptr C) 15 | { 16 | return cache[C->Bitrate]; 17 | } 18 | 19 | double PSR::cBitrate::getUnitCost(std::weak_ptr, std::shared_ptr C) 20 | { 21 | return unitCache[C->Bitrate]; 22 | } 23 | 24 | void PSR::cBitrate::createCache() 25 | { 26 | double maxBitrate = -1; 27 | 28 | for (auto &bitrate : TransmissionBitrate::DefaultBitrates) 29 | { 30 | if (maxBitrate < bitrate.get_Bitrate()) 31 | { 32 | maxBitrate = bitrate.get_Bitrate(); 33 | } 34 | } 35 | 36 | for (auto &bitrate : TransmissionBitrate::DefaultBitrates) 37 | { 38 | cache.emplace(bitrate, arma::rowvec(NMax - NMin + 1)); 39 | 40 | int expo = 0; 41 | double unitCost = bitrate.get_Bitrate() / maxBitrate; 42 | 43 | unitCache[bitrate] = unitCost; 44 | for (int n = NMin; n <= NMax; n++) 45 | { 46 | cache.at(bitrate)(expo++) = pow(unitCost, n); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/SignalQualityPrediction/SignalQualityPrediction_Variants.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNALQUALITYPREDICTION_VARIANTS_H 2 | #define SIGNALQUALITYPREDICTION_VARIANTS_H 3 | 4 | #include "SignalQualityPrediction.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace RP 10 | { 11 | namespace SQP 12 | { 13 | class SignalQualityPrediction_Variants : public SignalQualityPrediction 14 | { 15 | public: 16 | #define SQPVARIANTS \ 17 | X(mSCH, "Minimum Scheme") \ 18 | X(MSCH, "Maximum Scheme") 19 | 20 | #define X(a,b) a, 21 | enum SQP_Variants 22 | { 23 | SQPVARIANTS 24 | }; 25 | #undef X 26 | 27 | SignalQualityPrediction_Variants(std::shared_ptr T, 28 | std::shared_ptr RWA, 29 | double NetworkLoad, 30 | long long unsigned NumCalls, 31 | std::vector Bitrates = 32 | TransmissionBitrate::DefaultBitrates); 33 | 34 | void load(); 35 | 36 | private: 37 | static SQP_Variants Variant; 38 | static bool chooseVariant; 39 | 40 | typedef boost::bimap SQPVariantNameBimap; 41 | static SQPVariantNameBimap SQPVariantNames; 42 | 43 | void chooseSQPVariant(); 44 | 45 | void evaluateLNMax(); 46 | }; 47 | } 48 | } 49 | } 50 | 51 | #endif // SIGNALQUALITYPREDICTION_VARIANTS_H 52 | -------------------------------------------------------------------------------- /tests/Calls/EventTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "Calls/Event.h" 4 | #include 5 | 6 | TEST(EventTest, Constructor) 7 | { 8 | Event evt1(0.1, Event::CallRequisition, nullptr); 9 | EXPECT_EQ(evt1.t, 0.1) << "Constructor not working as it should."; 10 | EXPECT_EQ(evt1.Type, Event::CallRequisition) << "Constructor not working as it should."; 11 | EXPECT_EQ(evt1.Parent, nullptr) << "Constructor not working as it should."; 12 | 13 | Event evt2(0.2, Event::CallEnding, nullptr); 14 | EXPECT_EQ(evt2.t, 0.2) << "Constructor not working as it should."; 15 | EXPECT_EQ(evt2.Type, Event::CallEnding) << "Constructor not working as it should."; 16 | EXPECT_EQ(evt2.Parent, nullptr) << "Constructor not working as it should."; 17 | } 18 | 19 | TEST(EventTest, Comparison) 20 | { 21 | Event evt1(0.1, Event::CallRequisition, nullptr); 22 | Event evt2(0.2, Event::CallRequisition, nullptr); 23 | Event evt3(0.3, Event::CallEnding, nullptr); 24 | 25 | EXPECT_LT(evt1, evt2) << "Events should be ordered by their occurral times."; 26 | EXPECT_LT(evt1, evt3) << "Events should be ordered by their occurral times."; 27 | EXPECT_LT(evt2, evt3) << "Events should be ordered by their occurral times."; 28 | EXPECT_GT(evt2, evt1) << "Events should be ordered by their occurral times."; 29 | EXPECT_GT(evt3, evt1) << "Events should be ordered by their occurral times."; 30 | EXPECT_GT(evt3, evt2) << "Events should be ordered by their occurral times."; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /include/Structure/Slot.h: -------------------------------------------------------------------------------- 1 | #ifndef SLOT_H 2 | #define SLOT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Link; 9 | 10 | /** 11 | * @brief The Slot class represents a frequency slot. 12 | */ 13 | class Slot 14 | { 15 | public: 16 | /** 17 | * @brief BSlot is the bandwidth of a single slot. 18 | */ 19 | constexpr static double BSlot = 12.5E9; 20 | 21 | /** 22 | * @brief Slot is the standard constructor of a slot. 23 | */ 24 | Slot(int); 25 | /** 26 | * @brief Slot is the copy constructor of a slot. 27 | */ 28 | Slot(const Slot &slot); 29 | /** 30 | * @brief operator = is the assignment operator. 31 | */ 32 | Slot& operator= (const Slot &slot); 33 | 34 | /** 35 | * @brief numSlot identifies the slot in the link. 36 | */ 37 | int numSlot; 38 | /** 39 | * @brief isFree is true, iff the slot is free. 40 | */ 41 | bool isFree; 42 | /** 43 | * @brief freeSlot frees this slot, if it isn't free. 44 | */ 45 | void freeSlot(); 46 | /** 47 | * @brief useSlot uses this slot, if it isn't used. 48 | */ 49 | void useSlot(); 50 | /** 51 | * @brief samplesPerSlot is the number of frequency samples per slot. 52 | */ 53 | static constexpr unsigned long samplesPerSlot = 50; 54 | /** 55 | * @brief S is the main signal spectral density. 56 | */ 57 | std::shared_ptr S; 58 | }; 59 | 60 | #endif // SLOT_H 61 | -------------------------------------------------------------------------------- /src/GeneralPurposeAlgorithms/GA/GA_Individual.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralPurposeAlgorithms/GA/GA_Individual.h" 2 | #include "include/GeneralClasses/RandomGenerator.h" 3 | #include 4 | 5 | using namespace GeneticAlgorithm; 6 | 7 | GA_Individual::GA_Individual() 8 | { 9 | isEvaluated = false; 10 | parameter = -1; 11 | } 12 | 13 | bool GA_Individual::operator ==(const GA_Individual &other) const 14 | { 15 | return (parameter == other.parameter); 16 | } 17 | 18 | bool GA_Individual::operator <(const GA_Individual &other) const 19 | { 20 | return (parameter < other.parameter); 21 | } 22 | 23 | GA_Individual& GA_Individual::mutate() 24 | { 25 | isEvaluated = false; 26 | return *this; 27 | } 28 | 29 | void GA_Individual::setGene(std::map> newGene) 30 | { 31 | Gene = newGene; 32 | isEvaluated = false; 33 | } 34 | 35 | std::map> GA_Individual::getGenes() const 36 | { 37 | return Gene; 38 | } 39 | 40 | std::string GA_Individual::print(bool pretty) 41 | { 42 | if (pretty) 43 | { 44 | std::cout << "Individual: " << parameter << std::endl; 45 | return ""; 46 | } 47 | else 48 | { 49 | std::string indiv = ""; 50 | 51 | for (auto &g : Gene) 52 | { 53 | for (auto &gSlot : g.second) 54 | { 55 | indiv += std::to_string(gSlot); 56 | indiv += " "; 57 | } 58 | } 59 | 60 | return indiv; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_HopDistance.h: -------------------------------------------------------------------------------- 1 | #ifndef CHOPDISTANCE_H 2 | #define CHOPDISTANCE_H 3 | 4 | #include "Cost.h" 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | namespace ROUT 10 | { 11 | namespace PSR 12 | { 13 | 14 | /** 15 | * @brief The cHopDistance class has, as cost, the distance between the call's 16 | * origin and destination nodes, measured in terms of how many links there are 17 | * in the route between them found by the minimum hops algorithm. 18 | */ 19 | class cHopDistance : public Cost 20 | { 21 | public: 22 | /** 23 | * @brief cHopDistance is the standard constructor for the cHopDistance cost. 24 | * @param NMin is the minimum exponent to the cost. 25 | * @param NMax is the maximum exponent to the cost. 26 | * @param T is the topology. 27 | */ 28 | cHopDistance(int NMin, int NMax, std::shared_ptr T); 29 | arma::rowvec getCost(std::weak_ptr link, std::shared_ptr); 30 | double getUnitCost(std::weak_ptr, std::shared_ptr); 31 | 32 | private: 33 | void createCache(); 34 | std::map, arma::rowvec> cache; 35 | std::map, double> unitCache; 36 | 37 | struct Comparator 38 | { 39 | int OrigID; 40 | int DestID; 41 | double RouteLength; 42 | unsigned int NumHops; 43 | 44 | Comparator(int, int, double, unsigned int); 45 | bool operator <(const Comparator &) const; 46 | }; 47 | }; 48 | 49 | } 50 | } 51 | } 52 | 53 | #endif // CHOPDISTANCE_H 54 | -------------------------------------------------------------------------------- /data/topologies/PacificBell: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | node = 5 transparent ss 0 9 | node = 6 transparent ss 0 10 | node = 7 transparent ss 0 11 | node = 8 transparent ss 0 12 | node = 9 transparent ss 0 13 | node = 10 transparent ss 0 14 | node = 11 transparent ss 0 15 | node = 12 transparent ss 0 16 | node = 13 transparent ss 0 17 | node = 14 transparent ss 0 18 | node = 15 transparent ss 0 19 | node = 16 transparent ss 0 20 | node = 17 transparent ss 0 21 | 22 | [links] 23 | 24 | # -> = ORIGIN DESTINATION LENGTH 25 | -> = 1 3 650 26 | -> = 1 4 585 27 | -> = 1 5 650 28 | -> = 1 6 780 29 | -> = 1 7 975 30 | -> = 2 4 520 31 | -> = 2 5 585 32 | -> = 3 1 650 33 | -> = 3 8 390 34 | -> = 4 1 585 35 | -> = 4 2 520 36 | -> = 4 9 910 37 | -> = 4 10 650 38 | -> = 4 13 650 39 | -> = 4 16 650 40 | -> = 5 1 650 41 | -> = 5 2 585 42 | -> = 5 9 780 43 | -> = 5 14 585 44 | -> = 5 16 650 45 | -> = 6 1 780 46 | -> = 6 15 975 47 | -> = 7 1 975 48 | -> = 7 8 715 49 | -> = 7 10 650 50 | -> = 7 11 650 51 | -> = 8 3 390 52 | -> = 8 7 715 53 | -> = 9 4 910 54 | -> = 9 5 780 55 | -> = 10 4 650 56 | -> = 10 7 650 57 | -> = 11 7 650 58 | -> = 11 12 650 59 | -> = 12 11 650 60 | -> = 12 13 585 61 | -> = 13 4 650 62 | -> = 13 12 585 63 | -> = 14 5 585 64 | -> = 14 17 585 65 | -> = 15 6 975 66 | -> = 15 17 585 67 | -> = 16 4 650 68 | -> = 16 5 650 69 | -> = 17 14 585 70 | -> = 17 15 585 71 | -------------------------------------------------------------------------------- /src/GeneralClasses/TransmissionBitrate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::vector TransmissionBitrate::DefaultBitrates = 4 | { 5 | #define X(a) TransmissionBitrate(a), 6 | DEFAULT_TRANSMISSIONBITRATES 7 | #undef X 8 | #undef DEFAULT_TRANSMISSIONBITRATES 9 | }; 10 | 11 | TransmissionBitrate::TransmissionBitrate(double Bitrate) 12 | { 13 | this->Bitrate = Bitrate; 14 | } 15 | 16 | TransmissionBitrate::TransmissionBitrate(const TransmissionBitrate &other) 17 | { 18 | Bitrate = other.Bitrate; 19 | } 20 | 21 | double TransmissionBitrate::get_Bitrate() const 22 | { 23 | return Bitrate; 24 | } 25 | 26 | bool TransmissionBitrate::operator ==(const TransmissionBitrate &br) const 27 | { 28 | return Bitrate == br.get_Bitrate(); 29 | } 30 | 31 | bool TransmissionBitrate::operator !=(const TransmissionBitrate &br) const 32 | { 33 | return !(operator ==(br)); 34 | } 35 | 36 | bool TransmissionBitrate::operator <(const TransmissionBitrate &br) const 37 | { 38 | return (Bitrate < br.get_Bitrate()); 39 | } 40 | 41 | bool TransmissionBitrate::operator <=(const TransmissionBitrate &br) const 42 | { 43 | return ((operator ==(br)) || (operator <(br))); 44 | } 45 | 46 | bool TransmissionBitrate::operator >(const TransmissionBitrate &br) const 47 | { 48 | return (Bitrate > br.get_Bitrate()); 49 | } 50 | 51 | bool TransmissionBitrate::operator >=(const TransmissionBitrate &br) const 52 | { 53 | return ((operator ==(br)) || (operator >(br))); 54 | } 55 | 56 | std::ostream& operator <<(std::ostream &out, const TransmissionBitrate &br) 57 | { 58 | return out << (br.Bitrate / 1E9) << "Gbps"; 59 | } 60 | -------------------------------------------------------------------------------- /tests/GeneralClasses/ModulationSchemeTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/GeneralClasses/ModulationScheme.h" 4 | #include 5 | 6 | TEST(ModulationSchemeTest, Constructors) 7 | { 8 | Gain G(10); 9 | ModulationScheme M1(4, G); 10 | EXPECT_EQ(M1.get_SNR_Per_Bit(), G) << "SNR Per Bit not being correctly set."; 11 | 12 | ModulationScheme M2(M1); 13 | ModulationScheme M3 = M1; 14 | 15 | EXPECT_EQ(M1, M2) << "Copy constructor not working as it should."; 16 | EXPECT_EQ(M1.get_SNR_Per_Bit(), M2.get_SNR_Per_Bit()) << "Copy constructor not working as it should."; 17 | EXPECT_EQ(M1.get_M(), M2.get_M()) << "Copy constructor not working as it should."; 18 | 19 | EXPECT_EQ(M1, M3) << "Assignment operator not working as it should."; 20 | EXPECT_EQ(M1.get_SNR_Per_Bit(), M3.get_SNR_Per_Bit()) << "Assignment operator not working as it should."; 21 | EXPECT_EQ(M1.get_M(), M3.get_M()) << "Assignment operator not working as it should."; 22 | } 23 | 24 | TEST(ModulationSchemeTest, Operations) 25 | { 26 | ModulationScheme M1(4, Gain(15)); 27 | ModulationScheme M2(4, Gain(15)); 28 | ModulationScheme M3(16, Gain(20)); 29 | 30 | EXPECT_EQ(M1, M2) << M1 << " should be equal to " << M2 << "."; 31 | EXPECT_NE(M1, M3) << M1 << " should not be equal to " << M3 << "."; 32 | EXPECT_LT(M1, M3) << M1 << " should be less than to " << M3 << "."; 33 | EXPECT_LE(M1, M3) << M1 << " should be less than or equal to " << M3 << "."; 34 | EXPECT_GT(M3, M2) << M3 << " should be greater than to " << M2 << "."; 35 | EXPECT_GE(M3, M2) << M3 << " should be greater than or equal to " << M2 << "."; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /data/topologies/German: -------------------------------------------------------------------------------- 1 | [nodes] 2 | 3 | # node = ID TYPE ARCHITECTURE NUMREG 4 | node = 1 transparent ss 0 5 | node = 2 transparent ss 0 6 | node = 3 transparent ss 0 7 | node = 4 transparent ss 0 8 | node = 5 transparent ss 0 9 | node = 6 transparent ss 0 10 | node = 7 transparent ss 0 11 | node = 8 transparent ss 0 12 | node = 9 transparent ss 0 13 | node = 10 transparent ss 0 14 | node = 11 transparent ss 0 15 | node = 12 transparent ss 0 16 | node = 13 transparent ss 0 17 | node = 14 transparent ss 0 18 | node = 15 transparent ss 0 19 | node = 16 transparent ss 0 20 | node = 17 transparent ss 0 21 | 22 | [links] 23 | 24 | # -> = ORIGIN DESTINATION LENGTH 25 | -> = 1 2 36 26 | -> = 1 4 37 27 | -> = 2 1 36 28 | -> = 2 3 41 29 | -> = 3 2 41 30 | -> = 3 4 88 31 | -> = 3 9 182 32 | -> = 4 1 37 33 | -> = 4 3 88 34 | -> = 4 5 278 35 | -> = 4 8 208 36 | -> = 5 4 278 37 | -> = 5 6 144 38 | -> = 6 5 144 39 | -> = 6 7 144 40 | -> = 6 8 120 41 | -> = 7 6 144 42 | -> = 7 8 157 43 | -> = 7 10 306 44 | -> = 8 4 208 45 | -> = 8 6 120 46 | -> = 8 7 157 47 | -> = 8 9 316 48 | -> = 8 10 298 49 | -> = 8 11 258 50 | -> = 9 3 182 51 | -> = 9 8 316 52 | -> = 9 11 353 53 | -> = 9 12 224 54 | -> = 9 13 85 55 | -> = 10 7 306 56 | -> = 10 8 298 57 | -> = 10 11 174 58 | -> = 11 8 258 59 | -> = 11 9 353 60 | -> = 11 10 174 61 | -> = 11 12 275 62 | -> = 12 9 224 63 | -> = 12 11 275 64 | -> = 12 15 187 65 | -> = 12 17 179 66 | -> = 13 9 85 67 | -> = 13 14 64 68 | -> = 14 13 64 69 | -> = 14 15 74 70 | -> = 15 12 187 71 | -> = 15 14 74 72 | -> = 15 16 86 73 | -> = 16 15 86 74 | -> = 16 17 143 75 | -> = 17 12 179 76 | -> = 17 16 143 77 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_OrigDestIndex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::ROUT; 8 | 9 | PSR::cOrigDestIndex::cOrigDestIndex 10 | (int NMin, int NMax, std::shared_ptr T) : 11 | Cost(NMin, NMax, T, origdestindex) 12 | { 13 | createCache(); 14 | } 15 | 16 | arma::rowvec PSR::cOrigDestIndex::getCost 17 | (std::weak_ptr, std::shared_ptr C) 18 | { 19 | return cache.at({C->Origin.lock()->ID, C->Destination.lock()->ID}); 20 | } 21 | 22 | double PSR::cOrigDestIndex::getUnitCost(std::weak_ptr, std::shared_ptr C) 23 | { 24 | return unitCache.at({C->Origin.lock()->ID, C->Destination.lock()->ID}); 25 | } 26 | 27 | void PSR::cOrigDestIndex::createCache() 28 | { 29 | int Index = 1; 30 | int numPairs = T->Nodes.size() * (T->Nodes.size() - 1); 31 | 32 | for (auto &orig : T->Nodes) 33 | { 34 | for (auto &dest : T->Nodes) 35 | { 36 | if (orig == dest) 37 | { 38 | continue; 39 | } 40 | 41 | auto OrigDestPair = std::make_pair(orig->ID, dest->ID); 42 | cache.emplace(OrigDestPair, arma::ones(NMax - NMin + 1)); 43 | 44 | int expo = 0; 45 | double unitCost = (1.0 * Index) / numPairs; 46 | 47 | unitCache[OrigDestPair] = unitCost; 48 | for (int n = NMin; n <= NMax; n++) 49 | { 50 | cache.at(OrigDestPair)(expo++) = pow(unitCost, n); 51 | } 52 | Index++; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_Slots.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Calls/Call.h" 3 | 4 | using namespace RMSA::ROUT; 5 | 6 | PSR::cSlots::cSlots(int NMin, int NMax, std::shared_ptr T) : 7 | Cost(NMin, NMax, T, Cost::slots) 8 | { 9 | createCache(); 10 | } 11 | 12 | arma::rowvec PSR::cSlots::getCost(std::weak_ptr, std::shared_ptr C) 13 | { 14 | return cache.at(C->Scheme.get_NumSlots(C->Bitrate)); 15 | } 16 | 17 | double PSR::cSlots::getUnitCost(std::weak_ptr, std::shared_ptr C) 18 | { 19 | return unitCache[C->Scheme.get_NumSlots(C->Bitrate)]; 20 | } 21 | 22 | void PSR::cSlots::createCache() 23 | { 24 | unsigned int maxSlots = 1; 25 | for (auto scheme : ModulationScheme::DefaultSchemes) 26 | { 27 | for (auto bitrate : TransmissionBitrate::DefaultBitrates) 28 | { 29 | if (maxSlots < scheme.get_NumSlots(bitrate)) 30 | { 31 | maxSlots = scheme.get_NumSlots(bitrate); 32 | } 33 | } 34 | } 35 | 36 | for (auto scheme : ModulationScheme::DefaultSchemes) 37 | { 38 | for (auto bitrate : TransmissionBitrate::DefaultBitrates) 39 | { 40 | unsigned int numSlots = scheme.get_NumSlots(bitrate); 41 | cache.emplace(numSlots, arma::ones(NMax - NMin + 1)); 42 | 43 | int expo = 0; 44 | double unitCost = numSlots / maxSlots; 45 | 46 | unitCache[numSlots] = unitCost; 47 | for (int n = NMin; n <= NMax; n++) 48 | { 49 | cache.at(numSlots)(expo++) = pow(unitCost, n); 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::ROUT::PSR; 8 | 9 | Cost::CostNameBimap Cost::CostsNames = 10 | boost::assign::list_of 11 | #define X(a,b,c,d) (a,b) 12 | POSSIBLECOSTS 13 | #undef X 14 | ; 15 | 16 | Cost::CostNicknameBimap Cost::CostsNicknames = 17 | boost::assign::list_of 18 | #define X(a,b,c,d) (a,c) 19 | POSSIBLECOSTS 20 | #undef X 21 | ; 22 | 23 | Cost::Cost(int NMin, int NMax, std::shared_ptr T, 24 | PossibleCosts Type) : Type(Type), NMin(NMin), NMax(NMax), T(T) 25 | { 26 | 27 | } 28 | 29 | std::shared_ptr Cost::createCost(PossibleCosts cost, int NMin, int NMax, 30 | std::shared_ptr T) 31 | { 32 | std::shared_ptr Cost; 33 | 34 | switch (cost) 35 | { 36 | #define X(a,b,c,d) case a: Cost = std::make_shared(NMin, NMax, T); break; 37 | POSSIBLECOSTS 38 | #undef X 39 | } 40 | 41 | return Cost; 42 | } 43 | 44 | int Cost::get_NMin() 45 | { 46 | return NMin; 47 | } 48 | 49 | int Cost::get_NMax() 50 | { 51 | return NMax; 52 | } 53 | 54 | int Cost::get_N() 55 | { 56 | return NMax - NMin + 1; 57 | } 58 | 59 | double Cost::getCost(int N, std::weak_ptr link, std::shared_ptr C) 60 | { 61 | #ifdef RUN_ASSERTIONS 62 | if (N > NMax || N < NMin) 63 | { 64 | std::cerr << "Invalid N Requested." << std::endl; 65 | abort(); 66 | } 67 | #endif 68 | return getCost(link, C)(N - NMin); 69 | } 70 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/TensorialPowerSeriesRouting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace RMSA::ROUT::PSR; 6 | 7 | TensorialPowerSeriesRouting::TensorialPowerSeriesRouting 8 | (std::shared_ptr T) : PowerSeriesRouting(T, RoutingCost::tenPSR) 9 | { 10 | Variant = Variant_TensorialPSR; 11 | } 12 | 13 | TensorialPowerSeriesRouting::TensorialPowerSeriesRouting 14 | (std::shared_ptr T, std::vector> Costs) : 15 | PowerSeriesRouting(T, Costs, RoutingCost::tenPSR) 16 | { 17 | Variant = Variant_TensorialPSR; 18 | } 19 | 20 | double TensorialPowerSeriesRouting::get_Cost 21 | (std::weak_ptr link, std::shared_ptr C) 22 | { 23 | if (!link.lock()->is_LinkActive()) 24 | { 25 | return std::numeric_limits::max(); 26 | } 27 | 28 | arma::mat cost_matrix = arma::ones(1); 29 | 30 | for (auto &cost : Costs) 31 | { 32 | cost_matrix = arma::kron(cost_matrix, cost->getCost(link, C)); 33 | } 34 | 35 | if (!firstTimeRun) 36 | { 37 | calculate_CoefsMatrix(); 38 | coefs_matrix.copy_size(cost_matrix); 39 | firstTimeRun = true; 40 | } 41 | 42 | return arma::accu(coefs_matrix % cost_matrix); 43 | } 44 | 45 | void TensorialPowerSeriesRouting::calculate_CoefsMatrix() 46 | { 47 | coefs_matrix = arma::ones(1); 48 | for (size_t cost = 0; cost < Costs.size(); ++cost) 49 | { 50 | auto costCoefs = coefficients.cols(cost * get_N(), (cost + 1) * get_N() - 1); 51 | coefs_matrix = arma::kron(coefs_matrix, costCoefs); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/GA/GA_Generation.h: -------------------------------------------------------------------------------- 1 | #ifndef GA_GENERATION_H 2 | #define GA_GENERATION_H 3 | 4 | #include "GA.h" 5 | 6 | namespace GeneticAlgorithm 7 | { 8 | 9 | class GA_Individual; 10 | 11 | /** 12 | * @brief The GA_Generation class represents a generation to the Genetic Algorithm. 13 | */ 14 | class GA_Generation 15 | { 16 | friend class GA; 17 | 18 | public: 19 | /** 20 | * @brief GA_Generation is the standard constructor. 21 | */ 22 | GA_Generation(); 23 | 24 | /** 25 | * @brief eval evaluates the parameters of each Generation's Individuals. 26 | */ 27 | void eval(); 28 | /** 29 | * @brief print prints the fitter individual. 30 | */ 31 | void print(std::string filename = "NO_FILE_GIVEN"); 32 | 33 | /** 34 | * @brief operator += clones the Individual i and adds it to this Generation. 35 | * @param i is the Individual to be added. 36 | */ 37 | void operator +=(std::shared_ptr i); 38 | /** 39 | * @brief operator += clones each individual in Generation g and adds it to 40 | * this Generation. 41 | * @param g is the Generation to be added. 42 | */ 43 | void operator += (std::shared_ptr g); 44 | /** 45 | * @brief people is a set containing the individuals of this generation. 46 | */ 47 | std::vector> people; 48 | /** 49 | * @brief getBestIndividual returns the best individual of this generation. 50 | * @return the best individual of this generation. 51 | */ 52 | std::shared_ptr getBestIndividual() const; 53 | 54 | protected: 55 | bool isEvaluated; 56 | 57 | virtual void breed(unsigned int a, unsigned int b, std::shared_ptr dest) = 0; 58 | }; 59 | } 60 | 61 | #endif // GA_GENERATION_H 62 | -------------------------------------------------------------------------------- /include/Devices/Amplifiers/Amplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef AMPLIFIER_H 2 | #define AMPLIFIER_H 3 | 4 | #include 5 | 6 | namespace Devices 7 | { 8 | /** 9 | * @brief The Amplifier class represents an amplifier, that amplifies a signal 10 | * and generates noise. 11 | */ 12 | class Amplifier : public Device 13 | { 14 | public: 15 | /** 16 | * @brief The AmplifierType enum is used to identify the type of amplifier. 17 | */ 18 | enum AmplifierType 19 | { 20 | InLineAmplifierType, /*!< In-Line Amplifier */ 21 | BoosterAmplifierType, /*!< Booster Amplifier */ 22 | PreAmplifierType /*!< Pre-Amplifier */ 23 | }; 24 | 25 | /** 26 | * @brief Amplifier is the standard constructor for a Amplifier. 27 | * @param G is the Gain of the amplifier. 28 | */ 29 | Amplifier(Gain G); 30 | 31 | Power &get_Noise(); 32 | std::shared_ptr get_TransferFunction(double); 33 | double get_CapEx(); 34 | double get_OpEx(); 35 | 36 | /** 37 | * @brief AmplifierGain is the gain of this amplifier. 38 | */ 39 | Gain AmplifierGain; 40 | /** 41 | * @brief NoisePower is the power of the ASE noise generated by the amplifier. 42 | */ 43 | Power NoisePower; 44 | 45 | protected: 46 | /** 47 | * @brief set_Gain is used to set a new gain of this Amplifier. 48 | * @param G is the new gain of this Amplifier. 49 | */ 50 | void set_Gain(Gain G); 51 | 52 | private: 53 | /** 54 | * @brief calculate_NoisePower calculates the ASE Noise power 55 | * generated by the amplifier. 56 | */ 57 | virtual void calculate_NoisePower() = 0; 58 | /** 59 | * @brief deviceTF is the device's transfer function. 60 | */ 61 | std::shared_ptr deviceTF; 62 | }; 63 | } 64 | 65 | #endif // AMPLIFIER_H 66 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/PSRVariants/MatricialPowerSeriesRouting.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace RMSA::ROUT::PSR; 6 | 7 | MatricialPowerSeriesRouting::MatricialPowerSeriesRouting 8 | (std::shared_ptr T) : PowerSeriesRouting(T, RoutingCost::matPSR) 9 | { 10 | Variant = Variant_MatricialPSR; 11 | } 12 | 13 | MatricialPowerSeriesRouting::MatricialPowerSeriesRouting 14 | (std::shared_ptr T, std::vector> Costs) : 15 | PowerSeriesRouting(T, Costs, RoutingCost::matPSR) 16 | { 17 | Variant = Variant_MatricialPSR; 18 | } 19 | 20 | double MatricialPowerSeriesRouting::get_Cost 21 | (std::weak_ptr link, std::shared_ptr C) 22 | { 23 | if (!link.lock()->is_LinkActive()) 24 | { 25 | return std::numeric_limits::max(); 26 | } 27 | 28 | std::vector costs; 29 | for (auto &cost : Costs) 30 | { 31 | costs.push_back(cost->getUnitCost(link, C)); 32 | } 33 | 34 | if (cache.count(costs)) 35 | { 36 | return cache[costs]; 37 | } 38 | else 39 | { 40 | arma::mat cost_matrix = arma::ones(1); 41 | 42 | for (auto &cost : Costs) 43 | { 44 | cost_matrix = arma::kron(cost_matrix, cost->getCost(link, C)); 45 | } 46 | 47 | if (!firstTimeRun) 48 | { 49 | coefficients.copy_size(cost_matrix); 50 | firstTimeRun = true; 51 | } 52 | 53 | double totalCost = arma::accu(coefficients % cost_matrix); 54 | cache[costs] = totalCost; 55 | 56 | return totalCost; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Generation.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Generation.h" 2 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_Individual.h" 3 | #include "include/RMSA/SpectrumAssignmentAlgorithms/FFE/FFE_GA.h" 4 | #include "include/RMSA/SpectrumAssignmentAlgorithms/SpectrumAssignmentAlgorithm.h" 5 | #include "include/Structure/Link.h" 6 | #include "include/GeneralClasses/RandomGenerator.h" 7 | 8 | using namespace RMSA::SA::FFE; 9 | using namespace GeneticAlgorithm; 10 | 11 | FFE_Generation::FFE_Generation(FFE_GA *GA) : GA_Generation(), GA(GA) 12 | { 13 | 14 | } 15 | 16 | void FFE_Generation::breed(unsigned int a, unsigned int b, 17 | std::shared_ptr dest) 18 | { 19 | if (a == b) 20 | { 21 | return; 22 | } 23 | 24 | auto iterator_a = people.begin(); 25 | auto iterator_b = people.begin(); 26 | std::advance(iterator_a, a); 27 | std::advance(iterator_b, b); 28 | 29 | std::map> GeneA = (*iterator_a)->getGenes(), 30 | GeneB = (*iterator_b)->getGenes(); 31 | std::uniform_int_distribution dist(1, GeneA.size() - 1); 32 | int crossOverPoint = dist(random_generator); 33 | 34 | for (size_t i = crossOverPoint; i < GeneA.size(); ++i) 35 | { 36 | auto nSlot = SpectrumAssignmentAlgorithm::possibleRequiredSlots.begin(); 37 | std::advance(nSlot, i); 38 | std::swap(GeneA[*nSlot], GeneB[*nSlot]); //swaps genes of the individuals 39 | } 40 | 41 | auto newIndivA = (*iterator_a)->clone(), newIndivB = (*iterator_b)->clone(); 42 | newIndivA->setGene(GeneA); 43 | newIndivB->setGene(GeneB); 44 | (*dest) += newIndivA; 45 | (*dest) += newIndivB; 46 | 47 | people.erase(iterator_a); 48 | people.erase(iterator_b); 49 | } 50 | -------------------------------------------------------------------------------- /tests/GeneralClasses/SpectralDensityTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include 4 | #include 5 | 6 | TEST(SpectralDensityTest, Constructors) 7 | { 8 | double centerFreq = 193.4E12; 9 | double freqRange = 25E9; 10 | unsigned int numSamples = 100; 11 | 12 | SpectralDensity cleanSpecDens(centerFreq - freqRange, centerFreq + freqRange, numSamples, true); 13 | for(auto& val : cleanSpecDens.specDensity) 14 | { 15 | EXPECT_EQ(val, 0) << "Clean spectral density constructor not working."; 16 | } 17 | 18 | SpectralDensity specDens(centerFreq - freqRange, centerFreq + freqRange, numSamples, false); 19 | EXPECT_EQ(specDens.densityScaling, Gain(0, 20 | Gain::dB)) << "The proper density scaling is not being initialized."; 21 | EXPECT_EQ(specDens.freqMin, centerFreq - freqRange) << 22 | "The proper minimum frequency is not being initialized."; 23 | EXPECT_EQ(specDens.freqMax, centerFreq + freqRange) << 24 | "The proper maximum frequency is not being initialized."; 25 | EXPECT_EQ(specDens.stepFrequency, 26 | freqRange * 2 / (double) numSamples) << "The proper step frequency is not being initialized."; 27 | EXPECT_EQ(specDens.specDensity.n_cols, 28 | numSamples) << "The proper number of samples is not being initialized."; 29 | EXPECT_GT((specDens.specDensity)(numSamples / 2), (specDens.specDensity)(0)) << 30 | "Gaussian function exhibiting irregular behavior."; 31 | EXPECT_GT((specDens.specDensity)(numSamples / 2), (specDens.specDensity)(numSamples - 1)) << 32 | "Gaussian function exhibiting irregular behavior."; 33 | 34 | SpectralDensity specDens2(specDens); 35 | EXPECT_EQ(specDens, specDens2) << "Copy constructor not working as expected."; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/NX_RegeneratorPlacement.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace RMSA::RP; 5 | 6 | unsigned NX_RegeneratorPlacement::NX_N; 7 | unsigned NX_RegeneratorPlacement::NX_X; 8 | 9 | NX_RegeneratorPlacement::NX_RegeneratorPlacement(std::shared_ptr T) : 10 | RegeneratorPlacementAlgorithm(T) 11 | { 12 | isNXAlgorithm = true; 13 | } 14 | 15 | void NX_RegeneratorPlacement::load() 16 | { 17 | std::cout << std::endl << "-> Define the number of translucent nodes." 18 | << std::endl; 19 | 20 | do 21 | { 22 | unsigned N; 23 | std::cin >> N; 24 | 25 | if (std::cin.fail() || N < 1 || N > T->Nodes.size()) 26 | { 27 | std::cin.clear(); 28 | std::cin.ignore(); 29 | 30 | std::cerr << "Invalid number of translucent nodes." << std::endl; 31 | std::cout << std::endl << "-> Define the number of translucent nodes." 32 | << std::endl; 33 | } 34 | else 35 | { 36 | NX_N = N; 37 | break; 38 | } 39 | } 40 | while (1); 41 | 42 | std::cout << std::endl << "-> Define the number of regenerators per node." 43 | << std::endl; 44 | 45 | do 46 | { 47 | unsigned X; 48 | std::cin >> X; 49 | 50 | if (std::cin.fail() || X < 1) 51 | { 52 | std::cin.clear(); 53 | std::cin.ignore(); 54 | 55 | std::cerr << "Invalid number of regenerators per node." << std::endl; 56 | std::cout << std::endl << "-> Define the number of regenerators per node." 57 | << std::endl; 58 | } 59 | else 60 | { 61 | NX_X = X; 62 | break; 63 | } 64 | } 65 | while (1); 66 | } 67 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/SignalQualityPrediction/SignalQualityPrediction.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNALQUALITYPREDICTION_H 2 | #define SIGNALQUALITYPREDICTION_H 3 | 4 | #include "../NX_RegeneratorPlacement.h" 5 | #include 6 | #include 7 | #include 8 | 9 | namespace RMSA 10 | { 11 | namespace RP 12 | { 13 | //!Contains the operations related to the Signal Quality Prediction RP algorithm. 14 | namespace SQP 15 | { 16 | class SignalQualityPrediction : public NX_RegeneratorPlacement 17 | { 18 | public: 19 | #define SQPTypes \ 20 | X(HopsNumber, "Hops Number") \ 21 | X(Distance, "Distance") 22 | 23 | #define X(a,b) a, 24 | enum SQP_Type 25 | { 26 | SQPTypes 27 | }; 28 | #undef X 29 | 30 | SignalQualityPrediction(std::shared_ptr T, 31 | std::shared_ptr RMSA, 32 | double NetworkLoad, 33 | long long unsigned NumCalls, 34 | std::vector Bitrates = 35 | TransmissionBitrate::DefaultBitrates); 36 | 37 | void placeRegenerators(unsigned N = NX_N, unsigned X = NX_X); 38 | void load(); 39 | void chooseSQPType(); 40 | 41 | double get_LNMax(TransmissionBitrate, ModulationScheme); 42 | 43 | static SQP_Type Type; 44 | 45 | protected: 46 | typedef boost::bimap SQPTypeNameBimap; 47 | static SQPTypeNameBimap SQPTypeNames; 48 | 49 | static bool chosenType; 50 | 51 | std::shared_ptr RMSA; 52 | double NetworkLoad; 53 | long long unsigned NumCalls; 54 | std::vector Bitrates; 55 | 56 | std::map, unsigned long> LNMax; 57 | 58 | void evaluateLNMax(); 59 | }; 60 | } 61 | } 62 | } 63 | 64 | #endif // SIGNALQUALITYPREDICTION_H 65 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_NetworkLoad.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_NETWORKLOAD_H 2 | #define SIMULATION_NETWORKLOAD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "RMSA.h" 9 | 10 | namespace Simulations 11 | { 12 | 13 | /** 14 | * @brief The Simulation_NetworkLoad class is the simulation that varies the 15 | * network load and analyses the effect on the call blocking probability. 16 | * 17 | * This simulation varies the network load, and analyzes the network performance 18 | * in terms of predefined metrics, such as call blocking probability, 19 | * or slot blocking probability. 20 | */ 21 | class Simulation_NetworkLoad : public SimulationType 22 | { 23 | public: 24 | /** 25 | * @brief Simulation_NetworkLoad is the default constructor. 26 | */ 27 | Simulation_NetworkLoad(); 28 | 29 | void help(); 30 | void run(); 31 | void load(); 32 | void save(std::string); 33 | void load_file(std::string); 34 | void print(); 35 | 36 | private: 37 | std::vector> simulations; 38 | bool hasSimulated; 39 | bool hasLoaded; 40 | bool runLoadNX; 41 | 42 | double NumCalls; 43 | double NetworkLoadMin, NetworkLoadMax, NetworkLoadStep; 44 | 45 | std::string FileName; 46 | 47 | RMSA::ROUT::RoutingAlgorithm::RoutingAlgorithms Routing_Algorithm; 48 | RMSA::ROUT::RoutingCost::RoutingCosts Routing_Cost; 49 | RMSA::SA::SpectrumAssignmentAlgorithm::SpectrumAssignmentAlgorithms 50 | WavAssign_Algorithm; 51 | RMSA::RP::RegeneratorPlacementAlgorithm::RegeneratorPlacementAlgorithms 52 | RegPlacement_Algorithm; 53 | RMSA::RA::RegeneratorAssignmentAlgorithm::RegeneratorAssignmentAlgorithms 54 | RegAssignment_Algorithm; 55 | 56 | void create_Simulations(); 57 | void place_Regenerators(std::shared_ptr T); 58 | }; 59 | 60 | } 61 | #endif // SIMULATION_NETWORKLOAD_H 62 | -------------------------------------------------------------------------------- /include/GeneralClasses/TransmissionBitrate.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSMISSIONBITRATE_H 2 | #define TRANSMISSIONBITRATE_H 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * @brief The TransmissionBitrate class represents a transmission bitrate. 9 | */ 10 | class TransmissionBitrate 11 | { 12 | public: 13 | /** 14 | * In DEFAULT_TRANSMISSIONBITRATES there are the default transmission bitrates 15 | * used through the simulator. To add a new bitrate, add to the list X(BR), where 16 | * BR is measured in bits-per-second. 17 | **/ 18 | #define DEFAULT_TRANSMISSIONBITRATES \ 19 | X(10E9) \ 20 | X(40E9) \ 21 | X(100E9) \ 22 | X(160E9) \ 23 | X(400E9) 24 | 25 | /** 26 | * @brief TransmissionBitrate is the standard constructor for a TransmissionBitrate. 27 | * @param Bitrate is the bitrate, in bits per second. 28 | */ 29 | TransmissionBitrate(double Bitrate); 30 | /** 31 | * @brief TransmissionBitrate is the copy constructor. 32 | */ 33 | TransmissionBitrate(const TransmissionBitrate &); 34 | /** 35 | * @brief get_Bitrate returns the value of the bitrate, in bits per second. 36 | * @return the value of the bitrate, in bits per second. 37 | */ 38 | double get_Bitrate() const; 39 | 40 | bool operator ==(const TransmissionBitrate &) const; 41 | bool operator !=(const TransmissionBitrate &) const; 42 | bool operator <(const TransmissionBitrate &) const; 43 | bool operator <=(const TransmissionBitrate &) const; 44 | bool operator >(const TransmissionBitrate &) const; 45 | bool operator >=(const TransmissionBitrate &) const; 46 | 47 | /** 48 | * @brief DefaultBitrates is a vector containing the default bitrates considered 49 | * through the simulator. 50 | */ 51 | static std::vector DefaultBitrates; 52 | 53 | friend std::ostream& operator <<(std::ostream &out, const TransmissionBitrate &br); 54 | private: 55 | double Bitrate; 56 | }; 57 | 58 | #endif // TRANSMISSIONBITRATE_H 59 | 60 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_TransparencyAnalysis.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_TRANSPARENCYANALYSIS_H 2 | #define SIMULATION_TRANSPARENCYANALYSIS_H 3 | 4 | #include "SimulationType.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class Node; 11 | 12 | namespace Simulations 13 | { 14 | 15 | /** 16 | * @brief The Simulation_TransparencyAnalysis class represents a transparency 17 | * analysis simulation. 18 | * 19 | * This simulation varies the average distance between inline amplifiers and the 20 | * input OSNR, and checks whether it's still possible to establish a connection 21 | * in the route with longest length found by the Shortest Path routing algorithm, 22 | * using the greatest possible bitrate and any modulation scheme. If it's possible 23 | * to establish such connection, then the network is said to be "transparent". 24 | */ 25 | class Simulation_TransparencyAnalysis : public SimulationType 26 | { 27 | public: 28 | /** 29 | * @brief Simulation_TransparencyAnalysis is the standard constructor. 30 | */ 31 | Simulation_TransparencyAnalysis(); 32 | 33 | void help(); 34 | void run(); 35 | void load(); 36 | void save(std::string); 37 | void load_file(std::string); 38 | void print(); 39 | 40 | private: 41 | typedef std::pair InLineDistance_OSNR_Point; 42 | 43 | bool hasLoaded; 44 | bool hasRun; 45 | 46 | double minOSNR, maxOSNR, stepOSNR; 47 | double minAvgLinkSpan, maxAvgLinkSpan, stepAvgLinkSpan; 48 | std::string FileName; 49 | 50 | std::shared_ptr Orig_Origin, Orig_Destination; 51 | void find_OriginDestination(); 52 | 53 | std::vector TransparentPoints; 54 | std::vector OpaquePoints; 55 | 56 | std::shared_ptr minModulationScheme; 57 | std::shared_ptr maxBitrate; 58 | }; 59 | 60 | } 61 | #endif // SIMULATION_TRANSPARENCYANALYSIS_H 62 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/RoutingCost.h: -------------------------------------------------------------------------------- 1 | #ifndef ROUTINGCOST_H 2 | #define ROUTINGCOST_H 3 | 4 | #include 5 | #include 6 | 7 | class Link; 8 | class Topology; 9 | class Call; 10 | 11 | namespace RMSA 12 | { 13 | namespace ROUT 14 | { 15 | class RoutingCost 16 | { 17 | #define ROUTING_COSTS \ 18 | X(AWR, "Adaptative Weighing Routing", "AWR", PSR::AdaptativeWeighingRouting) \ 19 | X(LORa, "Length and Occupation Routing - Availability", "LORa", LengthOccupationRoutingAvailability) \ 20 | X(LORc, "Length and Occupation Routing - Contiguity", "LORc", LengthOccupationRoutingContiguity) \ 21 | X(localPSR, "Local Power Series Routing", "localPSR", PSR::LocalPowerSeriesRouting) \ 22 | X(matPSR, "Matricial Power Series Routing", "matPSR", PSR::MatricialPowerSeriesRouting) \ 23 | X(tenPSR, "Tensorial Power Series Routing", "tenPSR", PSR::TensorialPowerSeriesRouting) \ 24 | X(MH, "Minimum Hops", "MH", MinimumHops) \ 25 | X(SP, "Shortest Path", "SP", ShortestPath) //Enum value, Name, Nickname, Class name. 26 | 27 | public: 28 | #define X(a,b,c,d) a, 29 | enum RoutingCosts 30 | { 31 | ROUTING_COSTS 32 | }; 33 | #undef X 34 | 35 | RoutingCost(std::shared_ptr T, RoutingCosts RoutCost); 36 | virtual double get_Cost(std::weak_ptr link, std::shared_ptr C) = 0; 37 | 38 | virtual void load() = 0; 39 | virtual void save(std::string) = 0; 40 | virtual void print() = 0; 41 | 42 | typedef boost::bimap RoutAlgNameBimap; 43 | static RoutAlgNameBimap RoutingCostsNames; 44 | typedef boost::bimap RoutAlgNicknameBimap; 45 | static RoutAlgNicknameBimap RoutingCostsNicknames; 46 | 47 | static RoutingCosts define_RoutingCost(); 48 | static std::shared_ptr create_RoutingCost(RoutingCosts, 49 | std::shared_ptr, bool runLoad = true); 50 | 51 | RoutingCosts RoutCost; 52 | 53 | protected: 54 | std::shared_ptr T; 55 | }; 56 | } 57 | } 58 | 59 | #endif // ROUTINGCOST_H 60 | -------------------------------------------------------------------------------- /tests/crosstalkTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/Structure.h" 4 | #include "include/RMSA/TransparentSegment.h" 5 | #include 6 | 7 | extern bool considerFilterImperfection; 8 | 9 | TEST(CrosstalkTest, Epsilon) 10 | { 11 | bool backup_Filter = considerFilterImperfection; 12 | considerFilterImperfection = true; 13 | 14 | std::shared_ptr T = std::make_shared(); 15 | std::shared_ptr N1 = T->add_Node(1).lock(); 16 | std::shared_ptr N2 = T->add_Node(2).lock(); 17 | std::shared_ptr N3 = T->add_Node(3).lock(); 18 | std::shared_ptr N4 = T->add_Node(4).lock(); 19 | std::shared_ptr L14 = T->add_Link(N1, N4, 1000).lock(); 20 | std::shared_ptr L24 = T->add_Link(N2, N4, 1000).lock(); 21 | std::shared_ptr L34 = T->add_Link(N3, N4, 1000).lock(); 22 | 23 | mapSlots sl14, sl24, sl34; 24 | sl14[L14] = {L14->Slots[0], L14->Slots[1], L14->Slots[2], L14->Slots[3]}; 25 | sl24[L24] = {L24->Slots[1], L24->Slots[2]}; 26 | sl34[L34] = {L34->Slots[2], L34->Slots[3]}; 27 | 28 | RMSA::TransparentSegment Seg14({L14}, ModulationScheme(4, Gain(6.8)), 0); 29 | RMSA::TransparentSegment Seg24({L24}, ModulationScheme(4, Gain(6.8)), 0); 30 | RMSA::TransparentSegment Seg34({L34}, ModulationScheme(4, Gain(6.8)), 0); 31 | 32 | Signal S14(sl14); 33 | Signal S24(sl24); 34 | Signal S34(sl34); 35 | 36 | S24 = Seg24.bypass(S24); 37 | S34 = Seg34.bypass(S34); 38 | L24->linkSpecDens->updateLink(Seg24.opticalPathSpecDensity.front(), sl24.begin()->second); 39 | L34->linkSpecDens->updateLink(Seg34.opticalPathSpecDensity.front(), sl34.begin()->second); 40 | 41 | for (auto &slot : sl24.begin()->second) 42 | { 43 | slot.lock()->useSlot(); 44 | } 45 | for (auto &slot : sl34.begin()->second) 46 | { 47 | slot.lock()->useSlot(); 48 | } 49 | 50 | S14 = Seg14.bypass(S14); 51 | std::cout << S14.get_WeightedCrosstalk() << std::endl; 52 | 53 | considerFilterImperfection = backup_Filter; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_PowerRatioThreshold.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_POWERRATIOTHRESHOLD_H 2 | #define SIMULATION_POWERRATIOTHRESHOLD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "RMSA.h" 9 | #include 10 | 11 | namespace Simulations 12 | { 13 | 14 | /** 15 | * @brief The Simulation_PowerRatioThreshold class is the simulation 16 | * that varies the power ratio threshold and analyzes the effect on 17 | * the call blocking probability. 18 | * 19 | * This simulation varies the power ratio threshold for the filter 20 | * imperfection physical impairment, and analyzes the network 21 | * performance in terms of call blocking probability. 22 | */ 23 | class Simulation_PowerRatioThreshold : public SimulationType 24 | { 25 | public: 26 | /** 27 | * @brief Simulation_PowerRatioThreshold is the default constructor. 28 | */ 29 | Simulation_PowerRatioThreshold(); 30 | 31 | void help(); 32 | void run(); 33 | void load(); 34 | void save(std::string); 35 | void load_file(std::string); 36 | void print(); 37 | 38 | std::vector> simulations; 39 | 40 | bool hasLoaded; 41 | bool runLoadNX; 42 | double NumCalls; 43 | double NetworkLoad; 44 | double PowerRatioThresholdMin, PowerRatioThresholdMax, PowerRatioThresholdStep; 45 | 46 | std::string FileName; 47 | 48 | RMSA::ROUT::RoutingAlgorithm::RoutingAlgorithms Routing_Algorithm; 49 | RMSA::ROUT::RoutingCost::RoutingCosts Routing_Cost; 50 | RMSA::SA::SpectrumAssignmentAlgorithm::SpectrumAssignmentAlgorithms 51 | WavAssign_Algorithm; 52 | RMSA::RP::RegeneratorPlacementAlgorithm::RegeneratorPlacementAlgorithms 53 | RegPlacement_Algorithm; 54 | RMSA::RA::RegeneratorAssignmentAlgorithm::RegeneratorAssignmentAlgorithms 55 | RegAssignment_Algorithm; 56 | 57 | void create_Simulations(); 58 | void place_Regenerators(std::shared_ptr T); 59 | }; 60 | 61 | } 62 | #endif // SIMULATION_POWERRATIOTHRESHOLD_H 63 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_StatisticalTrend.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_BOXPLOT_H 2 | #define SIMULATION_BOXPLOT_H 3 | 4 | #include "SimulationType.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | using namespace RMSA; 12 | 13 | namespace Simulations 14 | { 15 | 16 | class NetworkSimulation; 17 | 18 | /** 19 | * @brief The Simulation_StatisticalTrend class represents a statistical trend 20 | * analysis. 21 | * 22 | * This simulation repeats a fixed-parameter network simulation, in order to 23 | * evaluate any statistical trends on the results. 24 | */ 25 | class Simulation_StatisticalTrend : public SimulationType 26 | { 27 | public: 28 | /** 29 | * @brief Simulation_StatisticalTrend is the default constructor. 30 | */ 31 | Simulation_StatisticalTrend(); 32 | 33 | void run(); 34 | void load(); 35 | void print(); 36 | void save(std::string); 37 | void load_file(std::string); 38 | void help(); 39 | 40 | private: 41 | std::vector> simulations; 42 | 43 | double NumCalls; 44 | double NetworkLoad; 45 | int NumRepetitions; 46 | 47 | std::string FileName; 48 | 49 | ROUT::RoutingAlgorithm::RoutingAlgorithms Routing_Algorithm; 50 | ROUT::RoutingCost::RoutingCosts Routing_Cost; 51 | SA::SpectrumAssignmentAlgorithm::SpectrumAssignmentAlgorithms 52 | WavAssign_Algorithm; 53 | RP::RegeneratorPlacementAlgorithm::RegeneratorPlacementAlgorithms 54 | RegPlacement_Algorithm; 55 | RA::RegeneratorAssignmentAlgorithm::RegeneratorAssignmentAlgorithms 56 | RegAssignment_Algorithm; 57 | 58 | void create_Simulations(); 59 | void place_Regenerators(std::shared_ptr); 60 | 61 | bool hasLoaded; 62 | bool runLoadNX; 63 | }; 64 | 65 | } 66 | #endif // SIMULATION_BOXPLOT_H 67 | -------------------------------------------------------------------------------- /include/RMSA/RegeneratorPlacementAlgorithms/MostSimultaneouslyUsed.h: -------------------------------------------------------------------------------- 1 | #ifndef MOSTSIMULTANEOUSLYUSED_H 2 | #define MOSTSIMULTANEOUSLYUSED_H 3 | 4 | #include 5 | #include 6 | 7 | namespace RMSA 8 | { 9 | class RoutingWavelengthAssignment; 10 | 11 | namespace RP 12 | { 13 | /** 14 | * @brief The MostSimultaneouslyUsed class represents the Most Simultaneously Used 15 | * RP algorithm. 16 | * 17 | * It runs an opaque simulation and computes the maximum amount of regenerators that 18 | * were simultaneously used on each node. Then it divides the regenerators proportionally 19 | * to this number. 20 | */ 21 | class MostSimultaneouslyUsed : public RegeneratorPlacementAlgorithm 22 | { 23 | public: 24 | /** 25 | * @brief MostSimultaneouslyUsed is the standard constructor. 26 | */ 27 | MostSimultaneouslyUsed(std::shared_ptr T, 28 | std::shared_ptr RMSA, 29 | double NetworkLoad, 30 | long long unsigned NumCalls = 1E6, 31 | std::vector Bitrates = TransmissionBitrate::DefaultBitrates 32 | ); 33 | /** 34 | * @brief placeRegenerators runs an opaque simulation and inserts NReg regenerators 35 | * distributed over the entire topology. 36 | * 37 | * Please note that MSU is not a NX Reg. Placement Algorithm. It's only parameter is 38 | * the number of regenerators, NumTotalReg, and not the N-X pair. 39 | * 40 | * @param NumTotalReg is the number of regenerators that will be distributed over the 41 | * topology. 42 | */ 43 | void placeRegenerators(unsigned NumTotalReg = MSU_NumTotalReg, unsigned = 0); 44 | void load(); 45 | 46 | private: 47 | std::shared_ptr RMSA; 48 | double NetworkLoad; 49 | long long unsigned NumCalls; 50 | std::vector Bitrates; 51 | static unsigned MSU_NumTotalReg; 52 | 53 | }; 54 | } 55 | } 56 | 57 | #endif // MOSTSIMULTANEOUSLYUSED_H 58 | -------------------------------------------------------------------------------- /include/Devices/SSS.h: -------------------------------------------------------------------------------- 1 | #ifndef SSS_H 2 | #define SSS_H 3 | 4 | #include 5 | #include 6 | 7 | class Node; 8 | class Link; 9 | class SpectralDensity; 10 | 11 | namespace Devices 12 | { 13 | /** 14 | * @brief The SSS class represents a spectrum selective switch. 15 | */ 16 | class SSS : public Device 17 | { 18 | public: 19 | /** 20 | * @brief SSSLoss is the loss of a SSS. Is considered constant for all 21 | * the SSS devices. 22 | */ 23 | static Gain SSSLoss; 24 | /** 25 | * @brief SSS is the standard constructor of a SSS. 26 | */ 27 | SSS(Node *parent); 28 | 29 | Gain &get_Gain(); 30 | Power &get_Noise(); 31 | std::shared_ptr get_TransferFunction(double centerFreq); 32 | double get_CapEx(); 33 | double get_OpEx(); 34 | 35 | /** 36 | * @brief get_BlockTransferFunction returns the transfer function that represents the device's blocking frequency response. 37 | * @param centerFreq is the central frequency of this transfer function. 38 | * @return the transfer function that represents the device's frequency response. 39 | */ 40 | std::shared_ptr get_BlockTransferFunction(double centerFreq); 41 | 42 | std::shared_ptr clone(); 43 | /** 44 | * @brief filterOrder is the order of the optical filter in this device. 45 | */ 46 | unsigned int filterOrder; 47 | 48 | private: 49 | Power NoisePower; 50 | Node *parent; 51 | /** 52 | * @brief deviceTF is the device's transfer function. 53 | */ 54 | std::shared_ptr deviceTF; 55 | /** 56 | * @brief bypassFunctionsCache is a map of the transfer functions of this 57 | * SSS device, given a certain central frequency and bandwidth. 58 | */ 59 | std::map> bypassFunctionsCache; 60 | /** 61 | * @brief blockingFunctionsCache is a map of the blocking transfer functions 62 | * of this SSS device, given a certain central frequency and bandwidth. 63 | */ 64 | std::map> blockingFunctionsCache; 65 | }; 66 | } 67 | 68 | #endif // SSS_H 69 | -------------------------------------------------------------------------------- /src/GeneralPurposeAlgorithms/GA/GA_Generation.cpp: -------------------------------------------------------------------------------- 1 | #include "include/GeneralPurposeAlgorithms/GA/GA_Generation.h" 2 | #include "include/GeneralPurposeAlgorithms/GA/GA_Individual.h" 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace GeneticAlgorithm; 8 | 9 | GA_Generation::GA_Generation() 10 | { 11 | isEvaluated = false; 12 | } 13 | 14 | void GA_Generation::eval() 15 | { 16 | if (isEvaluated) 17 | { 18 | return; 19 | } 20 | 21 | #pragma omp parallel for ordered schedule(dynamic) 22 | for (size_t i = 0; i < people.size(); i++) 23 | { 24 | auto person = people.begin(); 25 | std::advance(person, i); 26 | (*person)->eval(); 27 | } 28 | std::sort(people.begin(), people.end(), 29 | [](const std::shared_ptr &l, 30 | const std::shared_ptr &r) 31 | { 32 | return *l < *r; 33 | }); 34 | 35 | isEvaluated = true; 36 | } 37 | 38 | void GA_Generation::operator +=(std::shared_ptr i) 39 | { 40 | isEvaluated = false; 41 | people.push_back(i->clone()); 42 | } 43 | 44 | void GA_Generation::operator +=(std::shared_ptr g) 45 | { 46 | for (auto &indiv : g->people) 47 | { 48 | this->operator +=(indiv); 49 | } 50 | } 51 | 52 | void GA_Generation::print(std::string filename) 53 | { 54 | if (filename == "NO_FILE_GIVEN") 55 | { 56 | getBestIndividual()->print(); 57 | } 58 | else 59 | { 60 | std::ofstream OutFile(filename.c_str()); 61 | OutFile << getBestIndividual()->print(false) << std::endl; 62 | OutFile.close(); 63 | } 64 | } 65 | 66 | std::shared_ptr GA_Generation::getBestIndividual() const 67 | { 68 | std::shared_ptr best = people.front(); 69 | for (auto &indiv : people) 70 | { 71 | if (indiv->getParameter() == -1) 72 | { 73 | indiv->eval(); 74 | } 75 | 76 | if (indiv->getParameter() < best->getParameter()) 77 | { 78 | best = indiv; 79 | } 80 | } 81 | return best; 82 | } 83 | -------------------------------------------------------------------------------- /src/RMSA/RegeneratorPlacementAlgorithms/DistanceAdaptative.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace RMSA::RP; 7 | 8 | int DistanceAdaptative::DA_NumTotalRegenerators; 9 | 10 | DistanceAdaptative::DistanceAdaptative(std::shared_ptr T) : 11 | RegeneratorPlacementAlgorithm(T) 12 | { 13 | 14 | } 15 | 16 | void DistanceAdaptative::load() 17 | { 18 | std::cout << std::endl << "-> Define the total number of regenerators." 19 | << std::endl; 20 | 21 | do 22 | { 23 | int NumTotalReg; 24 | std::cin >> NumTotalReg; 25 | 26 | if (std::cin.fail() || NumTotalReg < 1) 27 | { 28 | std::cin.clear(); 29 | std::cin.ignore(); 30 | 31 | std::cerr << "Invalid number." << std::endl; 32 | std::cout << std::endl << "-> Define the total number of regenerators." 33 | << std::endl; 34 | } 35 | else 36 | { 37 | DA_NumTotalRegenerators = NumTotalReg; 38 | break; 39 | } 40 | 41 | } 42 | while (1); 43 | } 44 | 45 | void DistanceAdaptative::placeRegenerators(unsigned NumTotalReg, unsigned) 46 | { 47 | if (NumTotalReg == 0) 48 | { 49 | NumTotalReg = DA_NumTotalRegenerators; 50 | } 51 | 52 | double TotalLinkLength = 0; 53 | for (auto &link : T->Links) 54 | { 55 | TotalLinkLength += link.second->Length; 56 | } 57 | 58 | for (auto &node : T->Nodes) 59 | { 60 | double NodeLinksLength = 0; 61 | for (auto &link : node->Links) 62 | { 63 | NodeLinksLength += link->Length; 64 | } 65 | 66 | int NumReg = std::floor(NumTotalReg * (NodeLinksLength / TotalLinkLength)); 67 | if (NumReg == 0) 68 | { 69 | node->set_NodeType(Node::TransparentNode); 70 | node->set_NumRegenerators(0); 71 | } 72 | else 73 | { 74 | node->set_NodeType(Node::TranslucentNode); 75 | node->set_NumRegenerators(NumReg); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /include/RMSA/RoutingAlgorithms/RoutingAlgorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef ROUTINGALGORITHM_H 2 | #define ROUTINGALGORITHM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include "RoutingCost.h" 8 | 9 | class Topology; 10 | class Call; 11 | class Link; 12 | 13 | namespace RMSA 14 | { 15 | //! Contains the routing algorithms 16 | namespace ROUT 17 | { 18 | class RoutingCost; 19 | 20 | /** 21 | * @brief The RoutingAlgorithm class searches for a route, given a Call. 22 | */ 23 | class RoutingAlgorithm 24 | { 25 | public: 26 | #define ROUTING_ALGORITHM \ 27 | X(bellmanford, "Bellman-Ford Shortest Path Algorithm", "bellmanford", BellmanFord_RoutingAlgorithm) \ 28 | X(dijkstra, "Dijkstra Shortest Path Algorithm", "dijkstra", Dijkstra_RoutingAlgorithm) \ 29 | X(yen, "Yen K-Shortest Path Algorithm", "yen", Yen_RoutingAlgorithm) 30 | 31 | #define X(a,b,c,d) a, 32 | enum RoutingAlgorithms 33 | { 34 | ROUTING_ALGORITHM 35 | }; 36 | #undef X 37 | 38 | typedef boost::bimap RoutTypeNameBimap; 39 | static RoutTypeNameBimap RoutingAlgorithmNames; 40 | typedef boost::bimap RoutTypeNicknameBimap; 41 | static RoutTypeNicknameBimap RoutingAlgorithmNicknames; 42 | 43 | RoutingAlgorithms RoutAlg; 44 | std::shared_ptr RCost; 45 | 46 | RoutingAlgorithm(std::shared_ptr T, RoutingAlgorithms RoutAlg, 47 | RoutingCost::RoutingCosts RoutCost, bool runLoad = true); 48 | 49 | static RoutingAlgorithms define_RoutingAlgorithm(); 50 | static std::shared_ptr create_RoutingAlgorithm( 51 | RoutingAlgorithms, RoutingCost::RoutingCosts, std::shared_ptr, 52 | bool runLoad = true); 53 | virtual void load() = 0; 54 | virtual void save(std::string) = 0; 55 | virtual void print() = 0; 56 | 57 | virtual std::vector>> 58 | route(std::shared_ptr C) = 0; 59 | 60 | std::shared_ptr T; 61 | 62 | RoutingCost::RoutingCosts Cost; 63 | RoutingAlgorithms Alg; 64 | 65 | protected: 66 | double get_RoutingCost(std::vector>, std::shared_ptr); 67 | }; 68 | } 69 | } 70 | 71 | #endif // ROUTINGALGORITHM_H 72 | -------------------------------------------------------------------------------- /include/SimulationTypes/Simulation_RegeneratorNumber.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_REGENERATORNUMBER_H 2 | #define SIMULATION_REGENERATORNUMBER_H 3 | 4 | #include "SimulationType.h" 5 | #include 6 | #include 7 | #include 8 | #include "RMSA.h" 9 | 10 | namespace Simulations 11 | { 12 | 13 | /** 14 | * @brief The Simulation_RegeneratorNumber class represents a simulation that 15 | * varies the number of regenerators. 16 | * 17 | * This simulation inserts regenerators in the nodes of the topology, and 18 | * analyses the call requisition blocking probability. If the RP Algorithm is NX, 19 | * then the same number of regenerators will be inserted in each node. Otherwise, 20 | * the product N . X of regenerators is distributed over the topology. 21 | */ 22 | class Simulation_RegeneratorNumber : public SimulationType 23 | { 24 | public: 25 | /** 26 | * @brief Simulation_RegeneratorNumber is the default constructor. 27 | */ 28 | Simulation_RegeneratorNumber(); 29 | 30 | void help(); 31 | void run(); 32 | void load(); 33 | void save(std::string); 34 | void load_file(std::string); 35 | void print(); 36 | 37 | private: 38 | bool hasLoaded; 39 | 40 | double OptimizationLoad; 41 | long double NumCalls; 42 | 43 | std::string FileName; 44 | 45 | unsigned long minRegNumber; 46 | unsigned long maxRegNumber; 47 | unsigned long stepRegNumber; 48 | unsigned int numTranslucentNodes; 49 | 50 | RMSA::ROUT::RoutingAlgorithm::RoutingAlgorithms Routing_Algorithm; 51 | RMSA::ROUT::RoutingCost::RoutingCosts Routing_Cost; 52 | RMSA::SA::SpectrumAssignmentAlgorithm::SpectrumAssignmentAlgorithms 53 | WavAssign_Algorithm; 54 | RMSA::RP::RegeneratorPlacementAlgorithm::RegeneratorPlacementAlgorithms 55 | RegPlacement_Algorithm; 56 | RMSA::RA::RegeneratorAssignmentAlgorithm::RegeneratorAssignmentAlgorithms 57 | RegAssignment_Algorithm; 58 | 59 | void createSimulations(); 60 | void placeRegenerators(std::shared_ptr); 61 | void refreshRegenerators(std::shared_ptr, unsigned long numReg); 62 | std::vector> simulations; 63 | }; 64 | 65 | } 66 | 67 | #endif // SIMULATION_REGENERATORNUMBER_H 68 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/PSO/PSO_Particle.h: -------------------------------------------------------------------------------- 1 | #ifndef PSO_PARTICLE_H 2 | #define PSO_PARTICLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace PSO 11 | { 12 | /** 13 | * @brief The PSO_Particle class represents a particle to the PSO Optimization. 14 | * @tparam PositionType represents the same that the homonym class represents on 15 | * the ParticleSwarmOptimization. 16 | */ 17 | template 18 | class PSO_Particle 19 | { 20 | public: 21 | /** 22 | * @brief PSO_Particle is the standard constructor for a particle on the PSO 23 | * optimization. 24 | * @param N is the number of dimensions on this particle's position. 25 | * @param XMin is the minimum possible position, on each dimension. 26 | * @param XMax is the maximum possible position, on each dimension. 27 | */ 28 | PSO_Particle(unsigned int N, PositionType XMin, PositionType XMax); 29 | 30 | std::vector X; //Position 31 | std::vector V; //Velocity 32 | std::vector P; //Best position so far 33 | 34 | /** 35 | * @brief currentFit is the current fit of this particle. 36 | */ 37 | PositionType currentFit; 38 | /** 39 | * @brief bestFit is the best fit ever found by this particle. 40 | */ 41 | PositionType bestFit; 42 | /** 43 | * @brief Neighbour are pointers to this particle neighbours. 44 | */ 45 | std::weak_ptr Neighbour[2]; 46 | 47 | private: 48 | unsigned int N; 49 | void initialize(PositionType XMin, PositionType XMax); 50 | 51 | }; 52 | 53 | template 54 | PSO_Particle::PSO_Particle( 55 | unsigned int N, PositionType XMin, PositionType XMax) : N(N) 56 | { 57 | X.resize(N, 0); 58 | V.resize(N, 0); 59 | P.resize(N, 0); 60 | initialize(XMin, XMax); 61 | } 62 | 63 | template 64 | void PSO_Particle::initialize(PositionType, PositionType XMax) 65 | { 66 | 67 | std::uniform_real_distribution distribution(0, XMax); 68 | for (auto &x : X) 69 | { 70 | x = distribution(random_generator); 71 | } 72 | } 73 | } 74 | 75 | #endif // PSO_PARTICLE_H 76 | -------------------------------------------------------------------------------- /tests/Devices/SplitterTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/Devices/Splitter.h" 4 | #include "include/Structure/Node.h" 5 | #include "include/Structure/Link.h" 6 | #include 7 | 8 | TEST(DevicesTest, SplitterTest) 9 | { 10 | std::shared_ptr NodeAux1 = std::make_shared(1); 11 | std::shared_ptr NodeAux2 = std::make_shared(2); 12 | std::shared_ptr NodeAux3 = std::make_shared(3); 13 | std::shared_ptr link12 = std::make_shared(NodeAux1, NodeAux2, 1000); 14 | std::shared_ptr link13 = std::make_shared(NodeAux1, NodeAux3, 1000); 15 | std::shared_ptr link21 = std::make_shared(NodeAux2, NodeAux1, 1000); 16 | 17 | Devices::Splitter Splitter1(NodeAux1.get()); 18 | EXPECT_EQ(Splitter1.get_TransferFunction(1000)->get_TransmittanceAt(123), Splitter1.get_Gain()) << "Transfer function gain not being correctly set."; 19 | ASSERT_EQ(Splitter1.get_Gain(), Gain(0)) << "A splitter does not insert loss when the node does not have any neighbours."; 20 | 21 | NodeAux2->insert_Link(NodeAux1, link21); 22 | EXPECT_EQ(Splitter1.get_Gain(), Gain(0)) << "An incoming link should not affect the loss of a splitter."; 23 | NodeAux1->insert_Link(NodeAux2, link12); 24 | EXPECT_NE(Splitter1.get_Gain(), Gain(0)) << "An outcoming link should affect the loss of a splitter."; 25 | 26 | std::shared_ptr Splitter3 = Splitter1.clone(); 27 | ASSERT_EQ(Splitter1.get_Gain(), Splitter3->get_Gain()) << "Splitter cloning not working correctly: gain unequal."; 28 | EXPECT_EQ(Splitter1.get_Noise(), Splitter3->get_Noise()) << "Splitter cloning not working correctly: noise unequal."; 29 | EXPECT_EQ(Splitter1.get_CapEx(), Splitter3->get_CapEx()) << "Splitter cloning not working correctly: CapEx unequal."; 30 | EXPECT_EQ(Splitter1.get_OpEx(), Splitter3->get_OpEx()) << "Splitter cloning not working correctly: OpEx unequal."; 31 | 32 | Gain origGain = Splitter1.get_Gain(); 33 | NodeAux1->insert_Link(NodeAux3, link13); 34 | EXPECT_EQ(Splitter1.get_Gain(), Splitter3->get_Gain()) << "Splitter cloning not working correctly: gain unequal."; 35 | EXPECT_NE(Splitter1.get_Gain(), origGain) << "Splitter gain should sense the number of outcoming links of the parent node."; 36 | } 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/Calls/Event.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENT_H 2 | #define EVENT_H 3 | 4 | #include 5 | 6 | class Call; 7 | 8 | namespace RMSA 9 | { 10 | class Route; 11 | } 12 | 13 | /** 14 | * @brief The Event class represents an event that happened in the network. Is 15 | * either a call requisition or a call ending. 16 | */ 17 | class Event 18 | { 19 | public: 20 | /** 21 | * @brief The Event_Type enum is used to specify the type of event. 22 | * 23 | * Each call generates two events, a CallRequisition on its start and a 24 | * CallEnding on its ending. 25 | */ 26 | enum Event_Type 27 | { 28 | CallRequisition, /*!< Event on the starting call. */ 29 | CallEnding /*!< Event on the ending call. */ 30 | }; 31 | 32 | /** 33 | * @brief Event is the constructor of a Event. 34 | * @param t is the instant of ocurral of the Event. 35 | * @param Type is the type of Event. 36 | * @param Parent if a pointer to the owner Call of this Event. 37 | */ 38 | Event(double t, Event_Type Type, std::shared_ptr Parent); 39 | 40 | /** 41 | * @brief operator > is used to compare the ocurral instants of two events. 42 | * @return true iff this event ocurrs after the Event passed as argument. 43 | */ 44 | bool operator>(const Event &) const; 45 | /** 46 | * @brief operator < is used to compare the ocurral instants of two events. 47 | * @return true iff this event ocurrs before the Event passed as argument. 48 | */ 49 | bool operator<(const Event &) const; 50 | /** 51 | * @brief operator == compares two events for equality. 52 | * @return true iff the events have the same occural time. 53 | */ 54 | bool operator==(const Event &) const; 55 | 56 | /** 57 | * @brief t is the ocurring time of the event. 58 | */ 59 | double t; 60 | /** 61 | * @brief Type is the type of Event. 62 | */ 63 | Event_Type Type; 64 | /** 65 | * @brief Parent is a pointer to the Call that owns this Event. 66 | */ 67 | std::shared_ptr Parent; 68 | /** 69 | * @brief route is a pointer to the Route used to stablish the Parent Call. 70 | * If did not succeeded to stablish, then this is a pointer to nullptr. 71 | */ 72 | std::shared_ptr route; 73 | }; 74 | 75 | #endif // EVENT_H 76 | -------------------------------------------------------------------------------- /src/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_LinkLength.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/RoutingAlgorithms/Costs/PowerSeriesRouting/Costs/Cost_LinkLength.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::ROUT; 8 | 9 | PSR::cLinkLength::cLinkLength(int NMin, int NMax, std::shared_ptr T) : 10 | Cost(NMin, NMax, T, Cost::linklength) 11 | { 12 | createCache(); 13 | } 14 | 15 | arma::rowvec PSR::cLinkLength::getCost 16 | (std::weak_ptr link, std::shared_ptr) 17 | { 18 | return cache.at(link.lock()); 19 | } 20 | 21 | double PSR::cLinkLength::getUnitCost(std::weak_ptr link, std::shared_ptr) 22 | { 23 | return unitCache.at(link.lock()); 24 | } 25 | 26 | bool PSR::cLinkLength::Comparator::operator <(const Comparator &other) const 27 | { 28 | auto locklink = link.lock(); 29 | auto otherlocklink = other.link.lock(); 30 | 31 | if (locklink->Length < otherlocklink->Length) 32 | { 33 | return true; 34 | } 35 | else if (locklink->Length == otherlocklink->Length) 36 | { 37 | if (locklink->Origin.lock()->ID < otherlocklink->Origin.lock()->ID) 38 | { 39 | return true; 40 | } 41 | else if ((locklink->Origin.lock()->ID == otherlocklink->Origin.lock()->ID) && 42 | (locklink->Destination.lock()->ID < otherlocklink->Destination.lock()->ID)) 43 | { 44 | return true; 45 | } 46 | } 47 | 48 | return false; 49 | } 50 | 51 | void PSR::cLinkLength::createCache() 52 | { 53 | std::set LinkComparator; 54 | for (auto &link : T->Links) 55 | { 56 | LinkComparator.emplace(Comparator{link.second}); 57 | } 58 | 59 | int Index = 1; 60 | for (auto &linkcomp : LinkComparator) 61 | { 62 | cache.emplace(linkcomp.link.lock(), arma::ones(NMax - NMin + 1)); 63 | 64 | int expo = 0; 65 | double unitCost = (1.0 * Index) / LinkComparator.size(); 66 | 67 | unitCache[linkcomp.link.lock()] = unitCost; 68 | for (int n = NMin; n <= NMax; n++) 69 | { 70 | cache.at(linkcomp.link.lock())(expo++) = pow(unitCost, n); 71 | } 72 | Index++; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/RMSA/SpectrumAssignmentAlgorithms/FirstFit.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace RMSA::SA; 7 | 8 | FirstFit::FirstFit(std::shared_ptr T) : 9 | SpectrumAssignmentAlgorithm(T, SpectrumAssignmentAlgorithms::FF) 10 | { 11 | 12 | } 13 | 14 | mapSlots FirstFit::assignSlots(std::shared_ptr C, TransparentSegment Seg) 15 | { 16 | 17 | int RequiredSlots = Seg.ModScheme.get_NumSlots(C->Bitrate); 18 | std::map, std::vector>, 19 | std::owner_less>> Slots; 20 | Slots.clear(); 21 | 22 | bool SlotsAvailability[Link::NumSlots]; 23 | 24 | for (int i = 0; i < Link::NumSlots; i++) 25 | { 26 | SlotsAvailability[i] = true; 27 | } 28 | 29 | for (auto &link : Seg.Links) 30 | { 31 | auto locklink = link.lock(); 32 | 33 | for (auto &slot : locklink->Slots) 34 | { 35 | SlotsAvailability[slot->numSlot] &= slot->isFree; 36 | } 37 | } 38 | 39 | int CurrentFreeSlots = 0; 40 | int si = -1, sf = 0; 41 | 42 | for (sf = 0; sf < Link::NumSlots; sf++) 43 | { 44 | if (SlotsAvailability[sf]) 45 | { 46 | CurrentFreeSlots++; 47 | } 48 | else 49 | { 50 | CurrentFreeSlots = 0; 51 | } 52 | 53 | if (CurrentFreeSlots == RequiredSlots) 54 | { 55 | si = sf - RequiredSlots + 1; 56 | break; 57 | } 58 | } 59 | 60 | if (si != -1) 61 | { 62 | #ifdef RUN_ASSERTIONS 63 | if (sf != si + RequiredSlots - 1) 64 | { 65 | std::cerr << "Error in Wavelength Assignment" << std::endl; 66 | abort(); 67 | } 68 | #endif 69 | for (auto &link : Seg.Links) 70 | { 71 | Slots.emplace(link, std::vector> 72 | (link.lock()->Slots.begin() + si, 73 | link.lock()->Slots.begin() + sf + 1)); 74 | } 75 | } 76 | 77 | return Slots; 78 | } 79 | 80 | void FirstFit::save(std::string SimConfigFileName) 81 | { 82 | SpectrumAssignmentAlgorithm::save(SimConfigFileName); 83 | } 84 | -------------------------------------------------------------------------------- /src/RMSA/SpectrumAssignmentAlgorithms/BestFit.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/SpectrumAssignmentAlgorithms/BestFit.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::SA; 8 | 9 | BestFit::BestFit(std::shared_ptr T) : 10 | SpectrumAssignmentAlgorithm(T, SpectrumAssignmentAlgorithm::BF) 11 | { 12 | 13 | } 14 | 15 | mapSlots BestFit::assignSlots(std::shared_ptr C, TransparentSegment Seg) 16 | { 17 | 18 | int RequiredSlots = Seg.ModScheme.get_NumSlots(C->Bitrate); 19 | std::map, std::vector>, 20 | std::owner_less>> Slots; 21 | Slots.clear(); 22 | 23 | bool SlotsAvailability[Link::NumSlots + 1]; 24 | std::set> PossibleBlocks; 25 | 26 | for (int i = 0; i < Link::NumSlots; i++) 27 | { 28 | SlotsAvailability[i] = true; 29 | } 30 | SlotsAvailability[Link::NumSlots] = false; 31 | 32 | for (auto &link : Seg.Links) 33 | { 34 | auto locklink = link.lock(); 35 | 36 | for (auto &slot : locklink->Slots) 37 | { 38 | SlotsAvailability[slot->numSlot] &= slot->isFree; 39 | } 40 | } 41 | 42 | int CurrentFreeSlots = 0; 43 | 44 | for (int sf = 0; sf <= Link::NumSlots; sf++) 45 | { 46 | if (SlotsAvailability[sf]) 47 | { 48 | CurrentFreeSlots++; 49 | } 50 | else 51 | { 52 | if (CurrentFreeSlots != 0 && CurrentFreeSlots >= RequiredSlots) 53 | { 54 | PossibleBlocks.emplace(CurrentFreeSlots, sf - CurrentFreeSlots); 55 | } 56 | CurrentFreeSlots = 0; 57 | } 58 | } 59 | 60 | if (!PossibleBlocks.empty()) 61 | { 62 | int si = PossibleBlocks.begin()->second; 63 | for (auto &link : Seg.Links) 64 | { 65 | Slots.emplace(link, std::vector> 66 | (link.lock()->Slots.begin() + si, 67 | link.lock()->Slots.begin() + si + RequiredSlots)); 68 | } 69 | } 70 | 71 | return Slots; 72 | } 73 | 74 | void BestFit::save(std::string SimConfigFileName) 75 | { 76 | SpectrumAssignmentAlgorithm::save(SimConfigFileName); 77 | } 78 | -------------------------------------------------------------------------------- /src/GeneralClasses/Power.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | Power::Power(double value, InitType Type) 6 | { 7 | if (Type == InitType::dBm) 8 | { 9 | value_Watts = 0.001L * pow(10, 0.1 * value); 10 | } 11 | else if (Type == InitType::Watt) 12 | { 13 | #ifdef RUN_ASSERTIONS 14 | if (value < 0) 15 | { 16 | std::cerr << "A power, in Watts, can't be negative." << std::endl; 17 | abort(); 18 | } 19 | #endif 20 | value_Watts = value; 21 | } 22 | } 23 | 24 | Power::Power(const Power &Value) 25 | { 26 | value_Watts = Value.in_Watts(); 27 | } 28 | 29 | Power Power::operator *(Gain G) 30 | { 31 | return Power(value_Watts * G.in_Linear(), Power::Watt); 32 | } 33 | 34 | Power &Power::operator *=(Gain &G) 35 | { 36 | value_Watts *= G.in_Linear(); 37 | return *this; 38 | } 39 | 40 | Power Power::operator +(const Power &P) 41 | { 42 | return Power(value_Watts + P.in_Watts(), Power::Watt); 43 | } 44 | 45 | Power &Power::operator +=(const Power &P) 46 | { 47 | value_Watts += P.in_Watts(); 48 | return *this; 49 | } 50 | 51 | double Power::in_dBm() const 52 | { 53 | return 10 * log10(value_Watts) + 30; 54 | } 55 | 56 | double Power::in_Watts() const 57 | { 58 | return value_Watts; 59 | } 60 | 61 | bool Power::operator <(const Power &P) const 62 | { 63 | return value_Watts < P.value_Watts; 64 | } 65 | 66 | bool Power::operator <=(const Power &P) const 67 | { 68 | return ((operator <(P)) || (operator ==(P))); 69 | } 70 | 71 | bool Power::operator >(const Power &P) const 72 | { 73 | return value_Watts > P.value_Watts; 74 | } 75 | 76 | bool Power::operator >=(const Power &P) const 77 | { 78 | return ((operator >(P)) || (operator ==(P))); 79 | } 80 | 81 | Gain Power::operator /(const Power &P) const 82 | { 83 | return Gain(value_Watts / P.value_Watts, Gain::Linear); 84 | } 85 | 86 | bool Power::operator ==(const Power &P) const 87 | { 88 | return (value_Watts == P.value_Watts); 89 | } 90 | 91 | bool Power::operator !=(const Power &P) const 92 | { 93 | return !(operator ==(P)); 94 | } 95 | 96 | std::ostream& operator<<(std::ostream& os, const Power &P) 97 | { 98 | return os << P.in_dBm() << "dBm"; 99 | } 100 | -------------------------------------------------------------------------------- /tests/Calls/CallGeneratorTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include "include/Calls/CallGenerator.h" 4 | #include "include/Calls/Call.h" 5 | #include "include/Calls/Event.h" 6 | #include 7 | 8 | class CallGeneratorTest : public ::testing::Test 9 | { 10 | public: 11 | void SetUp(); 12 | 13 | static constexpr int numCalls = 20; 14 | std::shared_ptr T; 15 | std::shared_ptr CG; 16 | std::shared_ptr Calls[numCalls]; 17 | }; 18 | 19 | void CallGeneratorTest::SetUp() 20 | { 21 | T = std::make_shared(); 22 | 23 | T->add_Node(1); 24 | T->add_Node(2); 25 | T->add_Node(3); 26 | 27 | CG = std::make_shared(T, 100); 28 | EXPECT_EQ(CG->simulationTime, 0) << "Call Generator internal time should start at zero."; 29 | 30 | for (unsigned c = 0; c < numCalls; ++c) 31 | { 32 | Calls[c] = CG->generate_Call(); 33 | } 34 | } 35 | 36 | TEST_F(CallGeneratorTest, Constructor) 37 | { 38 | EXPECT_EQ(CG->T, T) << "Constructor not working as it should."; 39 | EXPECT_EQ(CG->h, 100) << "Constructor not working as it should."; 40 | } 41 | 42 | TEST_F(CallGeneratorTest, SettingValues) 43 | { 44 | //Network load setting 45 | CG->set_Load(200); 46 | EXPECT_EQ(CG->h, 200) << "Network load is not being set."; 47 | } 48 | 49 | TEST_F(CallGeneratorTest, CallGeneration) 50 | { 51 | //Tests whether the generated events make sense 52 | for (unsigned c = 0; c < numCalls; ++c) 53 | { 54 | EXPECT_GT(*(Calls[c]->CallEnding.lock()), *(Calls[c]->CallRequisition.lock())) << "Call " << c << " should end after it starts."; 55 | EXPECT_NE(*(Calls[c]->Origin.lock()), *(Calls[c]->Destination.lock())) << "Call " << c << " must be stablished between different source and destination nodes."; 56 | if (c != 0) 57 | { 58 | EXPECT_LT(*(Calls[c - 1]->CallRequisition.lock()), *(Calls[c]->CallRequisition.lock())) << "Call " << c - 1 << " should start before Call " << c << "."; 59 | } 60 | } 61 | 62 | //Tests whether the events are being correctly being saved into the priority queue 63 | EXPECT_EQ(CG->Events.size(), 2 * numCalls) << "There should be two events per generated call."; 64 | EXPECT_EQ(*(Calls[0]->CallRequisition.lock()), *(CG->Events.top())) << "The first event should be the beginning of the first call"; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/RMSA/SpectrumAssignmentAlgorithms/RandomFit.cpp: -------------------------------------------------------------------------------- 1 | #include "include/RMSA/SpectrumAssignmentAlgorithms/RandomFit.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace RMSA::SA; 8 | 9 | RandomFit::RandomFit(std::shared_ptr T) : 10 | SpectrumAssignmentAlgorithm(T, SpectrumAssignmentAlgorithms::RF) 11 | { 12 | 13 | } 14 | 15 | mapSlots RandomFit::assignSlots(std::shared_ptr C, TransparentSegment Seg) 16 | { 17 | int RequiredSlots = Seg.ModScheme.get_NumSlots(C->Bitrate); 18 | std::map, std::vector>, 19 | std::owner_less>> Slots; 20 | std::vector PossibleLastSlots; 21 | 22 | bool SlotsAvailability[Link::NumSlots]; 23 | 24 | for (int i = 0; i < Link::NumSlots; i++) 25 | { 26 | SlotsAvailability[i] = true; 27 | } 28 | 29 | for (auto &link : Seg.Links) 30 | { 31 | auto locklink = link.lock(); 32 | 33 | for (auto &slot : locklink->Slots) 34 | { 35 | SlotsAvailability[slot->numSlot] &= slot->isFree; 36 | } 37 | } 38 | 39 | int CurrentFreeSlots = 0; 40 | 41 | for (int sf = 0; sf < Link::NumSlots; sf++) 42 | { 43 | if (SlotsAvailability[sf]) 44 | { 45 | CurrentFreeSlots++; 46 | } 47 | else 48 | { 49 | CurrentFreeSlots = 0; 50 | } 51 | 52 | if (CurrentFreeSlots >= RequiredSlots) 53 | { 54 | PossibleLastSlots.push_back(sf); 55 | } 56 | } 57 | 58 | if (!PossibleLastSlots.empty()) 59 | { 60 | std::uniform_int_distribution SlotChoose(0, PossibleLastSlots.size() - 1); 61 | auto SF = PossibleLastSlots.begin(); 62 | std::advance(SF, SlotChoose(random_generator)); 63 | 64 | for (auto &link : Seg.Links) 65 | { 66 | Slots.emplace(link, std::vector> 67 | (link.lock()->Slots.begin() + *SF - RequiredSlots + 1, 68 | link.lock()->Slots.begin() + *SF + 1)); 69 | } 70 | } 71 | 72 | return Slots; 73 | } 74 | 75 | void RandomFit::save(std::string SimConfigFileName) 76 | { 77 | SpectrumAssignmentAlgorithm::save(SimConfigFileName); 78 | } 79 | -------------------------------------------------------------------------------- /include/GeneralPurposeAlgorithms/NSGA-II/NSGA2_Generation.h: -------------------------------------------------------------------------------- 1 | #ifndef NSGA2_GENERATION_H 2 | #define NSGA2_GENERATION_H 3 | 4 | #include 5 | #include 6 | 7 | namespace NSGA_II 8 | { 9 | 10 | class NSGA2_Individual; 11 | 12 | /** 13 | * @brief The NSGA2_Generation class represents a single generation of NSGA2. 14 | */ 15 | class NSGA2_Generation 16 | { 17 | friend class NSGA2; 18 | 19 | public: 20 | /** 21 | * @brief NSGA2_Generation is the standard constructor. 22 | */ 23 | NSGA2_Generation(); 24 | 25 | /** 26 | * @brief eval evaluates the parameters of each Generation's Individuals, and 27 | * then sorts them into their Pareto Fronts and lastly evaluates their 28 | * Crowding Distance into each Front. 29 | */ 30 | void eval(); 31 | /** 32 | * @brief print prints all individuals in a certain Pareto Front. 33 | * @param paretoFront is the Pareto Front to print. 34 | */ 35 | void print(std::string filename = "NO_FILE_GIVEN", int paretoFront = 1); 36 | 37 | /** 38 | * @brief operator += clones the Individual i and adds it to this Generation. 39 | * @param i is the Individual to be added. 40 | */ 41 | void operator +=(std::shared_ptr i); 42 | /** 43 | * @brief operator += clones each individual in Generation g and adds it to 44 | * this Generation. 45 | * @param g is the Generation to be added. 46 | */ 47 | void operator += (std::shared_ptr g); 48 | 49 | /** 50 | * @brief getParetoFront returns a vector with all Individuals in the i-th 51 | * Pareto Front. 52 | * @param i is the i-th Pareto Front. 53 | * @return a vector with all Individuals in the i-th Pareto Front. 54 | */ 55 | std::vector> getParetoFront(int i); 56 | /** 57 | * @brief binaryTournament does binaryTournament in the remaining Individuals 58 | * and returns a fit Individual. 59 | * @return a fit Individual. 60 | */ 61 | std::shared_ptr binaryTournament(); 62 | 63 | protected: 64 | bool isEvaluated; 65 | 66 | std::vector> people; 67 | void evalCrowdingDistances(int ParetoFront); 68 | void evalCrowdingDistances(); 69 | void evalParetoFront(); 70 | 71 | void breed(unsigned int a, unsigned int b, NSGA2_Generation &dest); 72 | }; 73 | } 74 | 75 | #endif // NSGA2_GENERATION_H 76 | -------------------------------------------------------------------------------- /tests/GeneralClasses/GainTest.cpp: -------------------------------------------------------------------------------- 1 | #ifdef RUN_TESTS 2 | 3 | #include 4 | #include "GeneralClasses/Gain.h" 5 | 6 | TEST(GainTest, Constructors) 7 | { 8 | Gain G1(123); 9 | Gain G2(G1); 10 | 11 | EXPECT_EQ(G1, G2) << "Copy constructor not working as expected."; 12 | } 13 | 14 | TEST(GainTest, Conversions) 15 | { 16 | Gain G1(0); 17 | Gain G2(0, Gain::dB); 18 | Gain G3(1, Gain::Linear); 19 | Gain G4(1, Gain::dB); 20 | Gain G5(10, Gain::dB); 21 | 22 | EXPECT_EQ(G1, G2) << "Gains should be, by default, specified in dB."; 23 | 24 | EXPECT_EQ(G1, G3) << "Conversion from dB to linear units failed."; 25 | EXPECT_EQ(G1.in_dB(), G3.in_dB()) << "Conversion from dB to linear units failed."; 26 | EXPECT_EQ(G1.in_Linear(), G3.in_Linear()) << "Conversion from dB to linear units failed."; 27 | 28 | EXPECT_NE(G3, G4) << "Conversion between dB and linear units not working as expected."; 29 | 30 | EXPECT_GT(G5.in_Linear(), 1) << "A gain of " << G5 << "should be greater than 1."; 31 | } 32 | 33 | TEST(GainTest, BasicOperations) 34 | { 35 | Gain G1(0); 36 | Gain G2(0); 37 | 38 | //Summing and subtracting gains 39 | EXPECT_EQ(G1 + G1, G1) << G1 << " + " << G1 << "should be equal to " << G1 << "."; 40 | EXPECT_EQ(G1 + G2, G1) << G1 << " + " << G2 << "should be equal to " << G1 << "."; 41 | EXPECT_EQ(G1 - G1, G1) << G1 << " - " << G1 << "should be equal to " << G1 << "."; 42 | EXPECT_EQ(G1 - G2, G1) << G1 << " - " << G2 << "should be equal to " << G1 << "."; 43 | 44 | //Assignments 45 | G1 = G1 + G1; 46 | EXPECT_EQ(G1, G2) << G1 << " + " << G1 << "should be equal to " << G2 << "."; 47 | G2 = G2 - G2; 48 | EXPECT_EQ(G1, G2) << G2 << " - " << G2 << "should be equal to " << G1 << "."; 49 | 50 | //Symmetrical gains 51 | Gain G3(1, Gain::Linear); 52 | EXPECT_EQ(G3, -G3) << "A gain of 1 should be equal to a gain of 1/1."; 53 | 54 | Gain G4(10); 55 | EXPECT_LE(G1, G4) << "A gain of " << G1 << " should be less than or equal to a gain of " << G4 << "."; 56 | EXPECT_LT(G1, G4) << "A gain of " << G1 << " should be less than a gain of " << G4 << "."; 57 | EXPECT_GE(G1, -G4) << "A gain of " << G1 << " should be greater than or equal to a gain of " << -G4 << "."; 58 | EXPECT_GT(G1, -G4) << "A gain of " << G1 << " should be greater than a gain of " << -G4 << "."; 59 | 60 | EXPECT_LT((-G4).in_Linear(), 1) << "A gain of " << -G4 << " should be greater than 1."; 61 | } 62 | 63 | #endif 64 | --------------------------------------------------------------------------------