0

I'm using omnetpp-5.4.1 , veins-4.7.1 , sumo-0.30.0 .I'm going to do fuzzy clustering by RSU in veins.I created a new module called FCM in veins/modules/application/traci and inherited the TraCIDemo11p and wrote the clustering code in it. Because I want to RSU start clustering,I used the initialize method in the TraCIDemoRSU11p to call the method inside the FMC at the start of work.

    void TraCIDemoRSU11p::initialize(int stage) {
    BaseWaveApplLayer::initialize(stage);

    std::cout<<"starting clustering";
    FCM * fcm_clustering;
    fcm_clustering->clustering();


}

When I run the program, it is not allowed to run at the start of the program, saying "finish with error" and the program stops running. What can I do to call the clustering by RSU at the beginning of the simulation?

please help me to solvemy problem. Thanks.

Faezeh
  • 1
  • 4
  • To find out if the initialize method was working or not, I cleaned all the code inside the method except the "cout<<" and then ran the program. When the program was run, after receiving a message coming from the vehicle to the RSU, RSU did not send a message to the vehicles and the "cou<<" I wrote inside the method will not be printed.Is it right to use initialize method? Where should I call clustering to perform clustering by RSU? – Faezeh Sep 14 '19 at 08:56

1 Answers1

0

You have defined a pointer fcm_clustering but you didn't initialize it. Therefore an attempt to use it ends up with memory violation.
Try to create FCM object, for example:

FCM * fcm_clustering = new FCM();
Jerzy D.
  • 6,707
  • 2
  • 16
  • 22
  • Thanks for your guide Unfortunately, it makes the same error and stops the simulation – Faezeh Sep 14 '19 at 09:11
  • So in your `omnetpp.ini` set `debug-on-errors=true`, and run simulation in Debug mode - an example is [here](https://docs.omnetpp.org/tutorials/tictoc/part2/#23-debugging). The simulation will stop on the line that causes an error. – Jerzy D. Sep 14 '19 at 09:21
  • Thank you very much, your guide on defined a pointer helped me a lot I do what you said carefully again, and my code was executed, and I realized where the code was right and where the code was wrong with the help of "cout<<" – Faezeh Sep 14 '19 at 09:44