I know in veins the FINISH function is done when the car comes out of the simulation.
In My simulation, the car travel time is calculated.This parameter is stored in a file when the cars exit the simulation by the FINISH function.
But when I check this file, there are several times recorded for each car.
Whereas for each car, one travel time must be recorded in the file and the FINISH function is executed once (when cars are out of simulation).
I think the FINISH function is executed many times. Does anyone know the reason?
i am using omnetpp-5.0, sumo-0.25.0 and veins-veins-4.4. Can anyone help me?
Related
I'm new to programming. I want to create a flowchart for my algorithm. In my algorithm there is a coordinator which waits for values from several devices. Each time it receives a value, it does some operation on it and after finishing the operation, waits for the next value to come.
So my question is that should I put an oval at the end of the the flowchart to show the end of each operation on a value or I should just connect the last rectangle (showing the last operation done on the received value) to the start part of the flowchart?
The attached photo is the flowchart I mean. Is it wrong to omit the end oval? If I put an end symbol (oval), won't it be wrong since the coordinator should wait for the next values?
I would put a wait for values node before the start, which would go with a directed vertice into start and operation2 would go into the wait.
Your chart, as it is suggests that the next chunk of work is started right away when the current is finished, yet, you need to illustrate the fact that there might be a wait time. Take a look at this chart:
You see the "Wait for data processing result" node. This is the wait symbol, which you need before start, as your very first node.
My project is to build a VANET-based smart parking simulation for a small-scale urban area. I dynamically define a route for vehicles to traverse to, then park for 'x' amount of time. Implementation for that is complete, the next step was to define a new exit route for them to exit the simulation after the 'x' amount of time is up. Reason being is that I want to simulate cars vacating parking spaces so that other vehicles may be able to avail of them (I don't want them to simply just to disappear upon reaching the end of their route)
So my question is, is it true that they just exit simulation after route is complete? Is it possible to avoid this?
Veins uses SUMO to simulate vehicle mobility. After a SUMO vehicle reaches the end of its route, it is removed from the simulation. You can, however, use SUMO to simulate a vehicle that drives to an intermediate point, parks for a set duration, then starts driving to its final destination. Such a vehicle will simply be marked as stopped/parking and will remain in the simulation.
My field of study is about travel time of cars so to evaluate my proposed methods it's very important to know how much time it takes for each individual car to reach to its destination
I use Veins 3.0, Sumo0.21.0 and Omnet++ 4.6 for simulation. I record destination of each car and base on their position, I record the exit time when a car reaches to its destination.
Is there a straightforward way to get notified when a car left the simulation?
Veins 3.0 already records several metrics in each TraCIMobility module. Among them are each vehicle's startTime, stopTime, and totalTime in the simulation.
Vehicles get removed from the simulation when they arrive. This means that, if you want to execute arbitrary code when a vehicle leaves the simulation, you can just add this code to the finish method of any module contained in the vehicle.
I'm not sure if the title is right but...
I want to animate (with html + canvas + javascript) a section of a road with a given density/flow/speed configuration. For that, I need to have a "source" of vehicles in one end, and a "sink" in the other end. Then, a certain parameter would determine how many vehicles per time unit are created, and their (constant) speed. Then, I guess I should have a "clock" loop, to increment the position of the vehicles at a given frame-rate. Preferrably, a user could change some values in a form, and the running animation would update accordingly.
The end result should be a (much more sophisticated, hopefully) variation of this (sorry for the blinking):
Actually this is a very common problem, there are thousands of screen-savers that use this effect, most notably the "star field", which has parameters for star generation and star movement. So, I believe there must be some "design pattern", or more widespread form (maybe even a name) for this algoritm. What would solve my problem would be some example or tutorial on how to achieve this with common control flows (loops, counters, ifs).
Any idea is much appreciated!
I'm not sure of your question, this doesn't seem an algorithm question, more like programming advice. I have a game which needs exactly this (for monsters not cars), this is what I did. It is in a sort of .Net psuedocode but similar stuff exists in other environments.
If you are running an animation by hand, you essentially need a "game-loop".
while (noinput):
timenow = getsystemtime();
timedelta = timenow - timeprevious;
update_object_positions(timedelta);
draw_stuff_to_screen();
timeprevious = timenow;
noinput = check_for_input()
The update_object_positions(timedelta) moves everything along timedelta, which is how long since this loop last executed. It will run flat-out redrawing every timedelta. If you want it to run at a constant speed, say once every 20 mS, you can stick in a thread.sleep(20-timedelta) to pad out the time to 20mS.
Returning to your question. I had a car class that included its speed, lane, type etc as well as the time it appears. I had a finite number of "cars" so these were pre-generated. I held these in a list which I sorted by the time they appeared. Then in the update_object_position(time) routine, I saw if the next car had a start time before the current time, and if so I popped cars off the list until the first (next) car had a start time in the future.
You want (I guess) an infinite number of cars. This requires only a slight variation. Generate the first car for each lane, record its start time. When you call update_object_position(), if you start a car, find the next car for that lane and its time and make that the next car. If you have patterns that you want to repeat, generate the whole pattern in one go into a list, and then generate a new pattern when that list is emptied. This would also work well in terms of letting users specify variable pattern flows.
Finally, have you looked at what happens in real traffic flows as the volume mounts? Random small braking activities cause cars behind to slightly over-react, and as the slight over-reactions accumulate it turns into cars completely stopping a kilometre back up the road. Its quite strange, and so might be a great effect in your wallpaper/screensaver whatever as well as being a proper simulation.
I'm having trouble computing the critical path of a network of activities. The data I have to work with is a little different than what I have seen in simple examples on the web. That is I have the start and end times of each activities, from whom I deduce the length. I have been using that algorithm to compute earliest and latest start and end times for each activity :
"To find the earliest start times, start at activities with no predecessors, and say they start at time zero. Then repeatedly find an activity whose predecessors' start times have all been filled, and set the start time to the maximum predecessor finish time.
To find the latest start times, run the preceding algorithm backwards. Start at activities with no successors. Set their finish time to the maximum finish time from the previous phase. Repeatedly find a predecessor whose successors have all been evaluated. Set its finish time to the earliest successor's start time.
Now it is trivial to evaluate slack = latest start – earliest start. Some chain of events will have slack time equal to zero; this is the critical path."
source : https://stackoverflow.com/questions/6368404/find-the-critical-path-and-slack-time
My code is identifying sometimes correctly the critical activities which compose the critical path, but due to the data I have, it sometimes fail. I have found when it does happen : it's when the given times for an activity (from whom cost is deduced) does not respect the early and latest times computed. Right now I only take into account the cost of each activity, but obviously it is not enough because in case like the one in picture below, critical path computed is not accurate :
one fail case for algorithm above http://imageshack.us/a/img688/2420/casemp.png
Obviously activity B is critical (if its end time is shifted, the end of project is also shifted) but the algorithm compute a slack of 1...
I don't know how to change the algorithm to make it work for case above.
I found some easy way to identify the critical activities from the data I have. For each activity, I simulate one second delay (add one second to the end time) and propagate that delay to all successors and test if it affects the time of last activity. If so, that task is critical.
This way works great, I have now a list of all the critical activities, but for some case it can take several seconds (23 seconds for 450 activities with a lot of dependances !). So still trying to find a better way.