User Manual, Developers Guide and API Documentation

FairSINR.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2009
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <WNS/scheduler/strategy/apcstrategy/FairSINR.hpp>
00029 #include <WNS/scheduler/strategy/apcstrategy/APCStrategy.hpp>
00030 #include <WNS/scheduler/strategy/StrategyInterface.hpp>
00031 #include <WNS/scheduler/SchedulerTypes.hpp>
00032 #include <vector>
00033 #include <iostream>
00034 #include <algorithm>
00035 
00036 using namespace wns::scheduler;
00037 using namespace wns::scheduler::strategy;
00038 using namespace wns::scheduler::strategy::apcstrategy;
00039 
00040 STATIC_FACTORY_REGISTER_WITH_CREATOR(FairSINR,
00041                                      APCStrategyInterface,
00042                                      "FairSINR",
00043                                      wns::PyConfigViewCreator);
00044 
00045 FairSINR::FairSINR(const wns::pyconfig::View& config)
00046     : APCStrategy(config),
00047       fair_sinr(wns::Ratio()),
00048       fair_sinrdl(config.get<double>("fair_sinrdl")),
00049       fair_sinrul(config.get<double>("fair_sinrul"))
00050 {
00051 }
00052 
00053 FairSINR::~FairSINR()
00054 {
00055 }
00056 
00057 // called before each timeSlot/frame
00058 void
00059 FairSINR::initialize(SchedulerStatePtr schedulerState,
00060                      SchedulingMapPtr schedulingMap)
00061 {
00062     APCStrategy::initialize(schedulerState,schedulingMap); // must always initialize base class too
00063     MESSAGE_SINGLE(NORMAL, logger, "FairSINR::initialize("<<apcstrategyName<<")");
00064 } // initialize
00065 
00066 
00067 APCResult
00068 FairSINR::doStartAPC(RequestForResource& request,
00069                      SchedulerStatePtr schedulerState,
00070                      SchedulingMapPtr schedulingMap)
00071 {
00072     APCResult apcResult;
00073     wns::scheduler::PowerCapabilities powerCapabilities =
00074         schedulerState->strategy->getPowerCapabilities(request.user);
00075 
00076     wns::Ratio pathloss     = request.cqiOnSubChannel.pathloss;
00077     wns::Power interference = request.cqiOnSubChannel.interference;
00078 
00079     assure(request.subChannel>=0,"need a valid subChannel");
00080     assure(request.timeSlot  >=0,"need a valid timeSlot");
00081 
00082     if (schedulerState->defaultTxPower!=wns::Power())
00083     { // predefined, e.g. in slave mode
00084         apcResult.txPower = schedulerState->defaultTxPower;
00085         apcResult.sinr = apcResult.txPower/(interference*pathloss);
00086         apcResult.estimatedCandI = wns::CandI(apcResult.txPower/pathloss,interference);
00087         apcResult.phyModePtr = schedulerState->defaultPhyModePtr;
00088     } else {
00089         if (schedulerState->schedulerSpot = wns::scheduler::SchedulerSpot::DLMaster())
00090         {
00091             fair_sinr.set_dB(fair_sinrdl);
00092         }
00093         else
00094         {
00095             fair_sinr.set_dB(fair_sinrul);
00096         }
00097         wns::Power fairTxPower = wns::Power::from_mW(fair_sinr.get_factor() * pathloss.get_factor() * interference.get_mW());
00098         wns::Power totalPower = powerCapabilities.maxOverall;
00099         wns::Power remainingTxPowerOnAllSubChannels = schedulingMap->getRemainingPower(totalPower,request.timeSlot);
00100 
00101         if ( remainingTxPowerOnAllSubChannels == wns::Power())
00102         {
00103             apcResult.txPower = wns::Power();
00104             return apcResult;
00105         }
00106 
00107         if (fairTxPower > powerCapabilities.maxPerSubband)
00108         {
00109             fairTxPower = powerCapabilities.maxPerSubband;
00110 
00111             if (fairTxPower > remainingTxPowerOnAllSubChannels)
00112             {
00113                 apcResult.txPower = remainingTxPowerOnAllSubChannels;
00114             }
00115             else
00116             {
00117                 apcResult.txPower = fairTxPower;
00118             }
00119             apcResult.sinr =  apcResult.txPower/(interference * pathloss);
00120         }
00121         else
00122         {
00123             if (fairTxPower > remainingTxPowerOnAllSubChannels)
00124             {
00125                 apcResult.txPower = remainingTxPowerOnAllSubChannels;
00126                 apcResult.sinr =  apcResult.txPower/(interference * pathloss);
00127             }
00128             else
00129             {
00130                 apcResult.txPower = fairTxPower;
00131                 apcResult.sinr = fair_sinr;
00132             }
00133         }
00134         apcResult.estimatedCandI = wns::CandI(apcResult.txPower/pathloss,interference);
00135         apcResult.phyModePtr = phyModeMapper->getBestPhyMode(apcResult.sinr);
00136     }
00137     MESSAGE_SINGLE(NORMAL, logger,"doStartAPC("<<request.toString()<<"): "
00138                    <<"SINR="<<apcResult.sinr<<", PhyMode="<<*(apcResult.phyModePtr)<<", txPower="<<apcResult.txPower);
00139     return apcResult;
00140 }
00141 

Generated on Wed May 23 03:31:49 2012 for openWNS by  doxygen 1.5.5