![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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/UseMaxTxPower.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(UseMaxTxPower, 00041 APCStrategyInterface, 00042 "UseMaxTxPower", 00043 wns::PyConfigViewCreator); 00044 00045 UseMaxTxPower::UseMaxTxPower(const wns::pyconfig::View& config) 00046 : APCStrategy(config) 00047 { 00048 } 00049 00050 UseMaxTxPower::~UseMaxTxPower() 00051 { 00052 } 00053 00054 // called before each timeSlot/frame 00055 void 00056 UseMaxTxPower::initialize(SchedulerStatePtr schedulerState, 00057 SchedulingMapPtr schedulingMap) 00058 { 00059 APCStrategy::initialize(schedulerState,schedulingMap); // must always initialize base class too 00060 MESSAGE_SINGLE(NORMAL, logger, "UseMaxTxPower::initialize("<<apcstrategyName<<")"); 00061 } // initialize 00062 00063 APCResult 00064 UseMaxTxPower::doStartAPC(RequestForResource& request, 00065 SchedulerStatePtr schedulerState, 00066 SchedulingMapPtr schedulingMap) 00067 { 00068 // no power control, just nominal values 00069 APCResult apcResult; 00070 assure(request.subChannel>=0,"need a valid subChannel"); 00071 apcResult.txPower = schedulerState->powerCapabilities.maxPerSubband; 00072 if (apcResult.txPower==wns::Power()) // unknown power? 00073 { // get the value 00074 wns::scheduler::PowerCapabilities powerCapabilities = 00075 schedulerState->strategy->getPowerCapabilities(request.user); 00076 apcResult.txPower = powerCapabilities.maxPerSubband; 00077 } 00078 wns::Ratio pathloss = request.cqiOnSubChannel.pathloss; 00079 wns::Power interference = request.cqiOnSubChannel.interference; 00080 apcResult.sinr = apcResult.txPower/(interference*pathloss); 00081 apcResult.estimatedCandI = wns::CandI(apcResult.txPower/pathloss,interference); 00082 MESSAGE_SINGLE(NORMAL, logger,"doStartAPC("<<request.toString()<<"): " 00083 <<"TxP="<<apcResult.txPower<<", pl="<<pathloss<<", estd: I="<<interference<<", C="<<apcResult.estimatedCandI.C); 00084 if (schedulerState->defaultPhyModePtr != wns::service::phy::phymode::PhyModeInterfacePtr()) 00085 { // predefined, e.g. in slave mode 00086 apcResult.phyModePtr = schedulerState->defaultPhyModePtr; 00087 } 00088 else 00089 { 00090 apcResult.phyModePtr = phyModeMapper->getBestPhyMode(apcResult.sinr); 00091 } 00092 MESSAGE_SINGLE(NORMAL, logger,"doStartAPC("<<request.toString()<<"): " 00093 <<"SINR="<<apcResult.sinr<<", PhyMode="<<*(apcResult.phyModePtr)); 00094 request.phyModePtr = apcResult.phyModePtr; // maybe needed later 00095 return apcResult; 00096 } 00097 00098 void 00099 UseMaxTxPower::postProcess(SchedulerStatePtr schedulerState, 00100 SchedulingMapPtr schedulingMap) 00101 { 00102 wns::Power totalPowerLimit = schedulerState->powerCapabilities.maxOverall; 00103 // loop over all timeSlots. Treat each individually. 00104 for (int timeSlotIndex=0; timeSlotIndex<schedulingMap->getNumberOfTimeSlots(); ++timeSlotIndex) 00105 { 00106 wns::Power totalUsedTxPowerOnAllSubChannels = schedulingMap->getUsedPower(timeSlotIndex); 00107 if (totalUsedTxPowerOnAllSubChannels == wns::Power()) { continue; } // means empty schedulingMap 00108 wns::Ratio reductionRatio = totalUsedTxPowerOnAllSubChannels/totalPowerLimit; 00109 // make this message VERBOSE only in the future: 00110 MESSAGE_SINGLE(NORMAL, logger,"postProcess(): usedPower[timeSlot="<<timeSlotIndex<<"]="<<totalUsedTxPowerOnAllSubChannels 00111 <<", reductionRatio="<<reductionRatio); 00112 if (reductionRatio.get_factor() <= 1.0) { continue; } // no need to adjust 00113 // keep this message in the future: 00114 MESSAGE_SINGLE(NORMAL, logger,"postProcess(): POWER REDUCTION: usedPower[timeSlot="<<timeSlotIndex<<"]="<<totalUsedTxPowerOnAllSubChannels 00115 <<", reductionRatio="<<reductionRatio); 00116 /* Loop over all resources in frequency dimension and adjust power down if it is too much. 00117 Assuming that this power distribution can vary timeslot-by-timeslot */ 00118 for ( SubChannelVector::iterator iterSubChannel = schedulingMap->subChannels.begin(); 00119 iterSubChannel != schedulingMap->subChannels.end(); ++iterSubChannel) 00120 { 00121 SchedulingSubChannel& subChannel = *iterSubChannel; 00122 SchedulingTimeSlotPtr timeSlotPtr = subChannel.temporalResources[timeSlotIndex]; 00123 wns::Power powerOnSubchannel = timeSlotPtr->getTxPower(); 00124 wns::Power reducedPowerOnSubchannel = powerOnSubchannel * reductionRatio; 00125 MESSAGE_SINGLE(NORMAL, logger,"postProcess(): subChannel="<<subChannel.subChannelIndex<<"."<<timeSlotIndex 00126 <<": reducing power from "<<powerOnSubchannel<<" by "<<reductionRatio<<" to "<<reducedPowerOnSubchannel); 00127 timeSlotPtr->setTxPower(reducedPowerOnSubchannel); 00129 //for ( int spatialIndex = 0; spatialIndex < numSpatialLayers; ++spatialIndex ) 00130 //{ 00131 // wns::Ratio estimatedSINR = ... 00132 // wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr = getPhyModeUsedInResource(subChannelIndex, timeSlotIndex, spatialIndex); 00133 // wns::Ratio requiredSINRforPhyMode = phyModeMapper->getMinSINRRatio(phyModePtr); 00134 // assure(estimatedSINR < requiredSINRforPhyMode,"pm="<<*phyModePtr<<": estimatedSINR="<<estimatedSINR<<" < required="<<requiredSINRforPhyMode); 00135 //{ 00136 } 00138 } // forall timeslots 00139 } // postProcess
1.5.5