-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSuccessUniformGainFunction.cpp
More file actions
executable file
·46 lines (42 loc) · 1.54 KB
/
SuccessUniformGainFunction.cpp
File metadata and controls
executable file
·46 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// SuccessUniformGainFunction.cpp
// AggregationNS3
//
// Created by Alper Sinan Akyurek on 8/22/16.
// Copyright © 2016 Alper Sinan Akyurek. All rights reserved.
//
#include "SuccessUniformGainFunction.hpp"
#include "UniformDeadlineProcess.hpp"
SuccessUniformGainFunction::TGain
SuccessUniformGainFunction::GetGain( const TTransmissionTime & x ) const
{
UniformDeadlineProcess::TBoundSeconds xSeconds = x.GetSeconds();
if ( xSeconds <= this->m_lower )
{
return ( this->m_generationProcess->GetMeanGenerationRate() );
}
return ( ( this->m_upper - xSeconds ) * this->m_generationProcess->GetMeanGenerationRate() / ( this->m_upper - this->m_lower ) );
}
SuccessUniformGainFunction::TGain
SuccessUniformGainFunction::GetGainDerivative( const TTransmissionTime & x ) const
{
UniformDeadlineProcess::TBoundSeconds xSeconds = x.GetSeconds();
if ( xSeconds <= this->m_lower )
{
return ( ( this->m_lower - xSeconds ) / xSeconds );
}
return ( -this->m_generationProcess->GetMeanGenerationRate() / ( this->m_upper - this->m_lower ) );
}
void
SuccessUniformGainFunction::SetProcesses( const TGenerationPtr & gen,
const TDeadlinePtr & deadline )
{
auto uniformDeadline = ns3::DynamicCast< UniformDeadlineProcess >( deadline );
this->m_generationProcess = gen;
this->m_lower = uniformDeadline->GetLowerBound();
this->m_upper = uniformDeadline->GetUpperBound();
if ( this->m_lower >= this->m_upper )
{
this->m_upper = this->m_lower + 0.000001;
}
}