Hi,

I am working in Matlab, I need help to write KNN algorithm. Please reply.

This page got nothing in it.

I thought they are execteables directly, when I came to know I have to call them I did mention. But sorry about that.

Thank you so much for the replies. They are really helpful. BUT I am working in Matlab. Can anyone guide me how to use them in MATLAB plzzzzzz

Thank you so much for your reply, it is http://a4wsn.di.univaq.it/index.html this I want ti run and know about it.

Hi,
I need help in running a software, thay have plugins in the from of jar files. which I dont know how to run and execute. I have JDK installed. Please suggest. Thank you so much.

Thankyou very much for your reply. I have seen the use of the nullptr keyword instead of 0 to indicate a null pointer value.

is that OK to write

while(!(cat1->Empty()))

But still I am not getting the results what I want. PLEASE HELP !!!!!!!!!!!!!!!!!!!!!!!!!

Hi,

I have written some code for priority queuing but this code is only processing items with priority 1. Can you help with this code please.......I am helpless

no=noofmsg-1;
     if(Analysis[no].prio==1)
         cat1->Enqueue(no);

     else if(Analysis[no].prio==2)
         cat2->Enqueue(no);

     else if(Analysis[no].prio==3)
         cat3->Enqueue(no);

      while(!(cat1->Empty()))
         {
            p= cat1->Next();
            TimDep= currtime+expntl();
           // slist->Add(TimDep,"D");

            Analysis[p].TEsf=TimDep;
            Console::WriteLine(" the value at  is  Analysis{0} is {1}", p, Analysis[p].TEsf );
            /*avg1= Analysis[p].TEsf-Analysis[p].TEa;
            Console::WriteLine(" The priority 1 messages has a waiting time of {0} ", avg1 );*/
            cat1->Dequeue();

         }

  if(cat1->Empty())
     {
      while(!(cat2->Empty()))
         {
            p= cat2->Next();
            TimDep= currtime+expntl();
            //slist->Add(TimDep,"D");

            Analysis[p].TEsf=TimDep;
            //Console::WriteLine(" the value at  is  Analysis{0} is {1}", p, Analysis[p].TEsf );
            cat2->Dequeue();
         }
      }
   if((cat1->Empty())&&(cat2->Empty()))
     {
      while(!(cat3->Empty()))
         {
            p= cat3->Next();
            TimDep= currtime+expntl();
            //slist->Add(TimDep,"D");

            Analysis[p].TEsf=TimDep;
            //Console::WriteLine(" the value at  is  Analysis{0} is {1}", p, Analysis[p].TEsf );
            cat3->Dequeue();
         }
      }

yes you are right, Can you help me to write the code well. I mean only the iteration part of all the items of one queue then second and then third.

I have a queue class code is given below:

struct ListNode
{
    ListNode(int value);
    int value;
    ListNode* next;
}; 
ListNode::ListNode(int value): value(value), next(nullptr) {}

public class queue
{
public:
    queue();
    ~queue();
    bool Empty() const;
    int Next() const;
    void Enqueue(int value);
    void Dequeue();
        void DisplayAll() const;
        int getP() const;

      private:
    // Disable copying to keep the example simple

   queue(queue const& obj);

    ListNode* head;
    ListNode* tail;
    gcroot<String^> name; // Added this
};

queue::queue():head(nullptr), tail(nullptr) {}

queue::~queue()
{
    while (head != nullptr)
    {
        Dequeue();
    }
}

bool queue::Empty() const
{
    return head == nullptr;
}

int queue::Next() const
{
    return head->value;
}

void queue::Enqueue(int value)
{
    if (head == nullptr)
    {
        head = tail = new ListNode(value);
    }
    else
    {
        tail->next = new ListNode(value);
        tail = tail->next;
    }
}

void queue::Dequeue()
{
    ListNode* temp = head->next;
    delete head;
    head = temp;
}

void queue::DisplayAll() const
{
    for (ListNode* p = head; p; p = p->next)
    {
        Console::WriteLine("the element is {0}", p->value);
    }

}

I need some help regarding queues operation, which I already have made. To help explain the problem you need to look at this code and the queue operations given in the above posted code.

if(Analysis[no].priority==1)
         cat1->Enqueue(no);
      else if(Analysis[no].priority==2)
         cat2->Enqueue(no);
      else if(Analysis[no].priority==3)
         cat3->Enqueue(no);
      while(!(cat1->Empty()))
         {
            p= cat1->Next();
            TimDep= currtime+expntl();
            slist->Add(TimDep,"D");
            Analysis[p].TEsf=TimDep;
         }

consider we have 3 queues cat1, cat2, cat 3. I want to insert items with pririty 1,2,3 respectively. which I am doing via this code. Now I want to process these inserted messages(or items "no"). First I want to ...

I have somewhat sorted out my issue, But need some help regarding queues operation, which I already have. To help explain the problem you need to look at this code and the queue operations given in the above posted code.

if(Analysis[no].priority==1)
         cat1->Enqueue(no);
      else if(Analysis[no].priority==2)
         cat2->Enqueue(no);
      else if(Analysis[no].priority==3)
         cat3->Enqueue(no);

      while(!(cat1->Empty()))
         {
            p= cat1->Next();
            TimDep= currtime+expntl();
            slist->Add(TimDep,"D");
            Analysis[p].TEsf=TimDep;
         }

consider we have 3 queues cat1, cat2, cat 3. I want to insert items with pririty 1,2,3 respectively. which I am doing via this code. Now I want to process these inserted messages(items "no"). First I want to process all messages in queue "cat1" and dequeue them one by one untill its empty, then it should move to "cat2" and same process and then to "cat3". I am stuck in the process of iterating through each element of queue how can I do that? can you help me please!!!!

Thank you very much for the helping answers. I have another query.

struct Ana    //A structure to store the arrival time, departure time with priority of each message. 
         {  
           double TEa;
           double TEsf;
           int priority;
          };
  for(int i=0; i<20; i++)   {
  TWork=Analysis[i].TEsf-Analysis[i].TEa;       
 Console::WriteLine("the arrival at queue  {0} message is {1} ",i, Analysis[i].TEa); 
 Console::WriteLine("the message priority is  {0} message is {1}",i, Analysis[i].priority);
Console::WriteLine("the finished by server is  {0} message is {1}",i, Analysis[i].TEsf);
Console::WriteLine("the response time for server is   {0}", TWork); 
               }

Actually I want to sort the average response time of each message class according to the priority of the message. like the average response time of priority 1, the average response time of priority 2, the average response time of priority 3. PLEASE HELP !

Please ignore if some of the header files are not related what I have been using.

my complete code of simulator is here. Sorry for not bing clear,But I have tried to put comments

// the program is about having random messages with random priorities and sorting them in queues and processing message whose priority is high.

//#include<stdlib.h> 
#using <System.dll>
#using <mscorlib.dll>
#include "stdafx.h"
#include"stdio.h"
#include <msclr\marshal_cppstd.h>
using namespace System::Collections;
using namespace System;
#include<string.h>
#include<time.h>
using namespace std;
using namespace msclr::interop;
#include <vcclr.h>
#include <iostream>
using namespace System::Collections::Generic;
using namespace System::Linq;
using namespace System::Text::RegularExpressions;

////////////////////////////////////////////////////////////////
struct Ana    //A structure to store the arrival time, departure time with priority of each message. 
     {  
       double TEa;
       double TEsf;
       int priority;
      };

////////////////////////////////////////////////////////////////random number generator/////////////////////////////////
double expntl()
    {
      double z,y;     /* Uniform random number from 0 to 1 */

                      /* Pull a uniform RV (0 < z < 1) */
      do
      {

          z = (((double) rand()+1.0) / RAND_MAX);
          if(z < 0)
             z = 1;
        // Console::WriteLine("exponential random varaiable generated is {0}",z);
       }
      while ((z == 0) || (z == 1));

      /* Inversion formula for exponential RV */
      y=(-1) * log(z);
    // Console::WriteLine("exponential random varaiable generated is {0}",y);
      return y;
    }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct ListNode
{
    ListNode(int value);
    int value;
    ListNode* next;
}; 
ListNode::ListNode(int value): value(value), next(nullptr) {}

public class queue
{
public:
    queue();
    ~queue();
    bool Empty() const;
    int Next() const;
    void Enqueue(int value);
    void Dequeue();
        void DisplayAll() const;
        int getP() const;

      private:
    // Disable copying to keep the example simple

        queue(queue const& obj);

    ListNode* head;
    ListNode* tail;
    gcroot<String^> name; // Added this
};

queue::queue():head(nullptr), tail(nullptr) {}

queue::~queue()
{
    while (head ...

Hi,

Thanks for the function, Now Help me for this one. Actually I want to have a simple function that create the random numbers between 1 to 3. But each time its hould give a different one.

int getP()
{
int i;
//srand((unsigned)time(NULL));
srand(clock());
i = (rand() % 3 + 1);
return i;
Console::WriteLine("the element is {0}",i);
}

when I call this function in the loop.
The output is:

the elemnt is 1
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 2
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3
the elemnt is 3

How can I have the random generation of these digits

I am using srand(clock()); in the code as well

OK can you help me for one thing if possible. Here the code for exponential distribution. I want to generate random variables using this distribution, But its giving me repeated numbers How can I solve this. AND Is it necessary to give some parameter in this function I want to just have a returned value.

*

double expntl()
    {
      double z,y;     /* Uniform random number from 0 to 1 */

                      /* Pull a uniform RV (0 < z < 1) */
      do
      {

          z = (((double) rand()+1.0) / RAND_MAX);
          if(z < 0)
             z = 1;

       }
      while ((z == 0) || (z == 1));
     Console::WriteLine("exponential random varaiable generated is {0}",z);
      /* Inversion formula for exponential RV */
      y=(-1) * log(z);
     //Console::WriteLine("exponential random varaiable generated is {0}",y);
      return y;
    }

*

Can you please imagine it without using queue, you are right with priorities it is not FIFO. Now I am working to do it without queues.

Thanks for reply, I think I am again unable to phrase my problem. I hope this code would be self explanatory. finding problem in how to set the priority and get response time of each message. I want to define three classes of messages. Like 1 priority defines the highest class and must be served first.
While 2 is on second and then 3rd. How to set the code so that the waiting time would always be higher for class 3 of messages. COde shows that message "m" is enqueued in the server queue. Its priority is checked that could be 1,2,3 . How I should deal this then. This is the question. Code is given here.

#using <System.dll>
#using <mscorlib.dll>
#include "stdafx.h"
#include"stdio.h"
#include <msclr\marshal_cppstd.h>
using namespace System::Collections;
using namespace System;
#include<string.h>
#include<time.h>
using namespace std;
using namespace msclr::interop;
#include "message.h"
#include <vcclr.h>
#include <iostream>
using namespace System::Collections::Generic;
using namespace System::Linq;
using namespace System::Text::RegularExpressions;

////////////////////////////////////////////////////////////////
struct Ana
     {  
       double TEa;
       double TEsf;
      };

////////////////////////////////////////////////////////////////random number generator/////////////////////////////////
double expntl(double x)
      {
         double z,y;     /* Uniform random number from 0 to 1 */

         /* Pull a uniform RV (0 < z < 1) */
         do
         {

                z = (((double) rand()+1.0) / RAND_MAX);
                if(z < 0)
                 z = 1;
          }
         while ((z == 0) || (z == 1));

         /* Inversion formula for exponential RV */

       //Console::WriteLine("exponential random varaiable generated is {0}",z);
         y= (-1/x) * log(z);
       // Console::WriteLine("exponential random varaiable generated is {0}",y);
         return y;
      }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct ListNode
{
    ListNode(gcroot<message^> msg);
    gcroot<message^> ...

Hi,

I have a discrete event simulator for m/m/1 queue. How can I have a program based on priority queue using M/M/1 model. PLEASE help me to have an idea about priorities and thier implementations

Thanks I got idea about this. Can you guide me about priority queueing if I send you my code.

Thanks for the reply, I already got the simulator where I have modelled the arrival of messages and service rates of server using exponential distributed random variable. That is M/M/1 queue. Now I want to work with poisson. Is this exponential distribution is poisson?

Hi,

I need help in designing a function that would model the arrival of the messages in the queue following poisson distribution. I shall be grateful for this kind help.

thanks for the reply but how can I use that. can you help me using this. I dont know semaphores and threads :(

I need your help regarding the message acknowledgement in the queue when the message reaches at the queue. Any help would be highly appreciated.
the code for my queue class is;

struct ListNode
{
    ListNode(gcroot<message^> msg);
    gcroot<message^> msg;
    ListNode* next;
}; 
ListNode::ListNode(gcroot<message^> msg): msg(msg), next(nullptr) {}

public class queue
{
public:
    queue();
    ~queue();
    bool Empty() const;
    void Enqueue(message^);
    void Dequeue();
        void DisplayAll() const;

private:
    // Disable copying to keep the example simple
        gcroot<String^> bindingkey;
        queue(queue const& obj);

    ListNode* head;
    ListNode* tail;
    gcroot<String^> name; // Added this
};

queue::queue():head(nullptr), tail(nullptr) {}

queue::~queue()
{
    while (head != nullptr)
    {
        Dequeue();
    }
}

void queue::Enqueue(message^ key)
{
    if (head == nullptr)
    {
        head = tail = new ListNode(key);
    }
    else
    {
        tail->next = new ListNode(key);
        tail = tail->next;
    }
}

void queue::Dequeue()
{
    ListNode* temp = head->next;
    delete head;
    head = temp;
}

void queue::DisplayAll() const
{
    for (ListNode* p = head; p; p = p->next)
    {
                Console::WriteLine("the element is {0}", p->msg->routingk);
    }

}

Message.h;

public ref class message
{
 public:

  property System::String^ routingk;

  message(String^ Id)
  { 
      routingk = Id;
  }

  System::String^ message::getType()
  {
   return routingk;
  }

};

Thanks for answer. Can you explain it with some coding please. What other ideas you think suit best with the situation.

Yes Emil you are right that what I want. To programatically get the name of the pointer that points to a certain queue object and store it as string.How can I do this please help.

Thanks for reply, I want to store the name of the queue like usa, weather as strings.

Thanks for reply, I want to strore the name of the queue like usa, weather as strings.

I have queue class as below

public class queue
{
public:
    queue();
    ~queue();
    bool Empty() const;
    void Enqueue(message^);
    void Dequeue();
        void DisplayAll() const;
    private:
        gcroot<String^> bindingkey;
        queue(queue const& obj);

    ListNode* head;
    ListNode* tail;
};

queue::queue():head(nullptr), tail(nullptr) {}

queue::~queue()
{
    while (head != nullptr)
    {
        Dequeue();
    }
}

//bool queue::Empty() const
//{
//    return head == nullptr;
//}

//String^ queue::Next() const
//{
//    return head->msg;
//}

void queue::Enqueue(message^ key)
{
    if (head == nullptr)
    {
        head = tail = new ListNode(key);
    }
    else
    {
        tail->next = new ListNode(key);
        tail = tail->next;
    }
}

void queue::Dequeue()
{
    ListNode* temp = head->next;
    delete head;
    head = temp;
}

void queue::DisplayAll() const
{
    for (ListNode* p = head; p; p = p->next)
    {
                Console::WriteLine("the element is {0}", p->msg->routingk);
    }

}

int main(array<System::String^> ^args)
{
  //four queues are created and added to the list of the queues
   queue *usa = new queue;
   queue *weather = new queue;
   queue *news = new queue;
   queue *europe = new queue;
 }

Can I have the name of the queue as STRING. PLEASE HELP.

thank you very much :)