دانلود پایان نامه ارشد با موضوع /********************************************************************************************/، public، -1;

دانلود پایان نامه ارشد

aClustering.getState() == 1){ // state == CH
* if (neighborCounts neighborAverage())
* nCountP = 1;
* else
* nCountP = -1;
* if (clusterChoices.isEmpty() )
* cCountP = 1;
* else
* cCountP = -1;
* rewardP = weightEnergy * energyP + weightUniform * ((nCountP /2 ) + (cCountP /2)) ;
* if(rewardP 0 )
* laClustering.setRewardCH(a );
* else
* laClustering.setPenaltyCH(b);
* }
* else{ // state == NonCH
* if (neighborCounts = neighborAverage())
* nCountP = 1;
* else
* nCountP = -1;
* if(clusterChoices.isEmpty() ){
*
* cCountP = -1;
* }
* else{
* cCountP = 1;
* }
* rewardP = -weightEnergy * energyP + weightUniform * ((nCountP /2 ) + (cCountP / 2)) ;
* if(rewardP 0 )
* laClustering.setRewardCH(a );
* else
* laClustering.setPenaltyCH(b);
* }
* }
* /********************************************************************************************/
* public void decideClusterHead(){
* laClustering.chooseState();
* itterCount++;
* this.sendState();
* vTimer = setTimeout(“vl_timer”,sendTime/2);
* }
* /********************************************************************************************/
* public void startLearning(){
* this.steady_state = false;
* this.laClustering.setFirstProbCH(firstProbCH);
* if (sendDataTimer != null)
* cancelTimeout(sendDataTimer);
* if (iTimer != null)
* cancelTimeout(iTimer);
* memCount = joinedNodes.size();
* joinedNodes.clear();
* clusterChoices.clear();
* lTimer = setTimeout(“la_timer”, (generator.nextDouble() / 5));
* }
* /********************************************************************************************/
* protected void sendState() {
* TOTAL_ROUND_LEARNING++;
* LaClusteringPacket newPacket = new LaClusteringPacket(this.nid, this.myPos, datasize, laClustering.getState(), getEnergy());
* this.WakeUp();
* if (!(this.sensorDEAD)) {
*
* downPort.doSending(new SensorAppWirelessAgentContract.Message
* (SensorAppWirelessAgentContract.BROADCAST_SENSOR_PACKET, LA_CLUSTER_PACKET, this.nid, datasize, newPacket));
* eID++;
* } else {
* System.out.println(“You are trying to send with dead sensor” + this.nid);
* return;
* }
* //Transmit data periodically
* if ((!this.sensorDEAD) && (!this.steady_state)) {
* lTimer = setTimeout(“la_timer”, sendTime);
* }
* }
* /********************************************************************************************/
* public void setMaxClusterSize(int size_){
* maxClusterSize = size_;
* }
* /********************************************************************************************/
* public void setWeightEnergy(double weight_){
* weightEnergy = weight_;
* }
*
* /********************************************************************************************/
* public void setWeightUniform(double weight_){
* weightUniform = weight_;
* }
* /********************************************************************************************/
* public boolean isNeighbor(long id){
* for(int i=0; i * if(((neighbor)neighbors.get(i)).getNid() == id)
* return true;
* }
* return false;
* }
* /********************************************************************************************/
* public int getNeighborCount(){
* return neighbors.size();
* }
* /********************************************************************************************/
* public void setMaxEnergy(double energy_){
* maxEnergy = energy_;
* }
* /********************************************************************************************/
* public int maxNeighborCount(){
* int max = neighborCounts;
* for(int i=0; i < neighbors.size() ; i++){
* if(((neighbor)neighbors.get(i)).getNeighborCounts() > max)
* max = ((neighbor)neighbors.get(i)).getNeighborCounts();
* }
* return max;
* }
* /********************************************************************************************/
* public double neighborAverage(){
* double total = neighborCounts;
* for(int i=0; i * total += (((neighbor)neighbors.get(i)).getNeighborCounts());
* }
* return total / (neighbors.size() + 1);
* }
*
* /********************************************************************************************/
* public void addNeighborCount(long id_, int count_){
* for(int i=0; i * if (((neighbor)neighbors.get(i)).getNid() == id_) {
* ((neighbor)neighbors.get(i)).setNeighborCounts(count_);
* }
* }
* }
* /********************************************************************************************/
* void recieveLaPkt(LaClusteringPacket msg){
* double distance;
* for(int i=0; i * if(((neighbor)neighbors.get(i)).getNid() == msg.getId()){
* ((neighbor)neighbors.get(i)).setEnergy(msg.getEnergy());
* ((neighbor)neighbors.get(i)).setState(msg.getState());
* if((msg.getState() == 1) || (msg.getState() == 4)){
* distance = this.distance(this.getX(),msg.getSenderX(),this.getY(),msg.getSenderY());
* LaClusteringApp.CHinfo ch_ = new LaClusteringApp.CHinfo(msg.getId(), distance, msg.getSenderPos(),0,msg.getState());
* clusterChoices.add(ch_);
* }
* }
* }
* }
* /********************************************************************************************/
* public void WakeUp() {
* //set the CPU to ACTIVE
* if (this.cpuMode != 2) {
* this.setCPUMode(2); //CPU_IDLE=0, CPU_SLEEP=1, CPU_ACTIVE=2, CPU_OFF=3
* }
* return;
* }
*
* /********************************************************************************************/
* public void GoToSleep()
* {
* //set the CPU to sleep
* if (this.cpuMode != 1) {
* this.setCPUMode(1); //CPU_IDLE=0, CPU_SLEEP=1, CPU_ACTIVE=2, CPU_OFF=3
* }
* return;
* }
* /********************************************************************************************/
* /**
* * This method is called when attempting to ‘run’ the component in TCL.
* */
* protected void _start ()
* {
* double t;
* this.WakeUp();
* this.getLocation(); //determine the most up-to-date position
*
* //start the periodic querying of the remaining energy
* rTimer = setTimeout(“getEnergy”, 2);
* laClustering.setState(0);
* joinedNodes.clear();
*
* setTimeout(“calCluster”, 0.1);
* }
* /********************************************************************************************/
* protected void calCluster(){
* double t;
* maxN = false;
* if(isMaxNeighbor() ){ //if this node has the most of neighbors between neighbor
* maxN = true;
* laClustering.setSteady(1);
* laClustering.setState(4);
* t = generator.nextDouble() / 5;
* steady_state = true;
* isch_ = true;
* setTimeout(“sendState”, t);
* }else{
* setTimeout(“findFirstCluster”, 1);
* }
* }
* /********************************************************************************************/
* protected void findFirstCluster(){
* double t;
* maxN = false;
* if(!clusterChoices.isEmpty()){
* laClustering.setSteady(1);
* steady_state = true;
* isch_ = false;
* return;
* }
* else{
* t = generator.nextDouble() / 5;
* lTimer = setTimeout(“la_timer”, t);
* }
* }
* /********************************************************************************************/
* public boolean getMaxN(){
* return maxN;
* }
* /********************************************************************************************/
* public int getTotalRound(){
* return TOTAL_ROUND_LEARNING;
* }
* /********************************************************************************************/
* protected synchronized void recvSensorEvent(Object data_)
* {
* SensorAppAgentContract.Message msg = (SensorAppAgentContract.Message) data_;
* lastSeenSNR = msg.getSNR();
* lastSeenDataSize = msg.getDataSize();
* phenomenon = data_;
* return;
* }
* /********************************************************************************************/
* protected synchronized void timeout(Object data_)
* {
* if (data_.equals(“sendData”) && (!this.isSensorDead())) {
* SendMyData();
* return;
* }
* if ( data_.equals(“calCluster”)) {
* this.calCluster();
* return;
* }
* if ( data_.equals(“findFirstCluster”)) {
* this.findFirstCluster();
* return;
* }
* if ( data_.equals(“la_timer”)) {
* this.decideClusterHead();
* return;
* }
* if ( data_.equals(“sendDirect”)) {
* this.SendMyDataToBS();
* return;
* }
* if ( data_.equals(“AckSch”)) {
* this.AckSch();
* return;
* }
* if ( data_.equals(“ack”)) {
* this.checkAck();
* return;
* }
* if ( data_.equals(“vl_timer”)) {
* this.validateState();
* for(int i = clusterChoices.size()-1; i>=0 ; i–){
* if(((CHinfo)clusterChoices.get(i)).getState()!=4){
* clusterChoices.remove(i);
* }
* }
* return;
* }
*
* if (data_.equals(“sendGet”)) {
* if(this.sendGet)
* this.sendGetClustering();
* return;
* }
* if (data_.equals(“createSchedule”)) {
* this.createSchedule();
* return;
* }
* if (data_.equals(“informClusterHead”)) {
* this.informClusterHead();
* return;
* }
* if (data_.equals(“startSteady_timer”)) {
* this.sendState();
* return;
* }
* if (data_.equals(“sendState”)) {
* this.sendState();
* return;
* }
* if (data_.equals(“setCluster”)) {
* this.setCluster();
* return;
* }
* if (data_.equals(“sendDataToBS”)) {
* this.SendDataToBS();
* return;
* }
* if (data_.equals(“startFind_timer”)) {
* this.findBestCluster();
* return;
* }
* if (data_.equals(“sleepListen”)) {
* this.GoToSleep();
* wakeUpListenTimer = setTimeout(“wakeUpListen”, timeSlice – 2 * wakeUpPeriod );
* return;
* }
* if (data_.equals(“wakeUpListen”)) {
* this.WakeUp();
* sleepListenTimer = setTimeout(“sleepListen”, 2 * wakeUpPeriod );
* return;
* }
* if (data_.equals(“findNextHop”)) {
* this.findNextHop();
* return;
* }
* if (data_.equals(“inforCmlusterHead”)) {
* this.informClusterHead();
* return;
* }
* if (data_.equals(“startSteadyState2”)) {
* this.startSteadyState2();
* return;
* }
* return;
* }
* /********************************************************************************************/
* public synchronized void recvSensorPacket(Object data_)
* {
* if ( data_ instanceof SensorPacket ) {
* SensorPacket spkt = (SensorPacket)data_ ;
* if ((spkt.getPktType() == LA_CLUSTER_PACKET)) {
* LaClusteringPacket msg = (LaClusteringPacket)spkt.getBody();
* if( isNeighbor(msg.getId()) ){
* System.out.println(“Receive a LA_CLUSTER_PACKET from ” + spkt.getSrc_nid() + ” in ” + this.nid);
* this.recieveLaPkt(msg);
* return;
* }
* }
* if (spkt.getPktType() == DATA_CLUSTER_PACKET) {
* LaClusteringDataPacket msg = (LaClusteringDataPacket) spkt.getBody();
* if (this.nid == msg.getCH_id()) {
* System.out.println(“Receive a DATA_CLUSTER_PACKET from ” + spkt.getSrc_nid() + ” in ” + this.nid + ” at time” + getTime());
* if(changeCH){
* if(this.currentCH == spkt.getSrc_nid()){
* sendGetClustering();
* }
* else{
* sendChangeClustering(msg);
* }
* }
* this.recvDATA(msg);
* }
* return;
* }
* if (spkt.getPktType() == JOIN_CLUSTER_PCKET) {
* LaClusteringJoinPacket msg = (LaClusteringJoinPacket)spkt.getBody();
* //Check to make sure I am the cluster head that this JOIN_REQ is for
* System.out.println(“Receive a JOIN_CLUSTER_PCKET from ” + spkt.getSrc_nid() + ” in ” + this.nid + ” at time” + getTime());
* this.recvJOIN_REQ(msg);
* return;
* }
*
* if (spkt.getPktType() == GET_CLUSTER_PACKET) {
* LaGetClusteringPacket msg = (LaGetClusteringPacket)spkt.getBody();
* System.out.println(“Receive a GET_CLUSTER_PACKET from ” + spkt.getSrc_nid() + ” in ” + this.nid + ” at time” + getTime());
* this.recvGET_REQ(msg);
* return;
* }
* if (spkt.getPktType() == DATA_TO_NEXTHOP_PACKET) {
* System.out.println(“Receive a DATA_TO_NEXTHOP_PACKET from ” + spkt.getSrc_nid() + ” in ” + this.nid);
* this.SendDataNextHop(spkt);
* LaClusteringDataPacket msg = (LaClusteringDataPacket)spkt.getBody();
* if(changeCH){
* sendNotNextHop(msg);
* }
* return;
* }
* if (spkt.getPktType() == CHANGE_CLUSTER_PACKET) {
* LaClusteringChangePacket msg = (LaClusteringChangePacket)spkt.getBody();
* System.out.println(“Receive a CHANGE_CLUSTER_PACKET from ” + spkt.getSrc_nid() + ” in ” + this.nid + ” at time” + getTime());
* this.currentCH = msg.getCH_id();
* this.CHloc = msg.getLoc();
* if(this.currentCH != this.nid){
* addRoute(this.nid,this.currentCH,-1);
* }
* return;
* }
* if (spkt.getPktType() == NEXTHOP_CLUSTER_PACKET) {
* LaClusteringNextHopPacket msg = (LaClusteringNextHopPacket)spkt.getBody();
* if(isClusterHead()){
* processNextHopPacket(msg);
* }
* return;
* }
* if (spkt.getPktType() == ACK_CLUSTER_PACKET) {
*

پایان نامه
Previous Entries دانلود پایان نامه ارشد با موضوع protected، public، import Next Entries دانلود پایان نامه ارشد با موضوع "، this.currentCH، double