🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Logic Flaws

Started by
3 comments, last by The_Dan 23 years, 1 month ago
I am typing this because I remembered a nasty logic flaw I had in a NN simulation program I wrote 6-7 months ago, and I wonder if anyone had any pointers as to how I would go about solving it. I have had some suggestions in another board, but none really helped, thus I am asking here. The program was structured as follows: There was a simulation of the road network of a small city (it was a grid based city, with 4x4 road intersections, making a total of 16 junctions, each with 4 traffic lights. Each traffic light had only two states, Go or Stop) There was an artificial neural network, consisting of two input layers, quite a few (I''m not sure how many) hidden layers, and the output layer. The first input layer had input from the traffic lights (when the light changed, a signal is emitted), and the second got it''s input whenever a road accident ocurred. The output layer mapped to the traffic lights (whenever there was a signal, the traffic light flipped states). Each node had 5 normal and 1 inhibitory connection to other nodes. The training algo was based on the number of road accidents, and firstly randomly adjusted weightings of the connections and the values of the transformation functions, in a process similar to a genetic algorithm. When, of a series of 1000 (IIRC) trials it found the network weightings combination that caused the least accidents(usually by pure chance), it saves it and makes several variations (again, like a GA). Once a part is changed, it runs the simulation for each one and sees if there is any improvement over the parent combination. Eventually, (if the program is left on overnight) a pattern begins to emerge, where the network flips traffic lights at the right time, causing the least accidents. Here lies my logic problem. I cannot turn off the training algo, because it does not know when it is at it''s best state, so the algo keeps looking for ways to improve the network. Sometimes, when no accidents occur for a long time, the training algorithm changes the weightings of the road accident reaction part of the network so much that it is no longer functional. But, there are no road accidents so the network fitness evaluation says it''s okay. Then, an accident occurs, and suddenly the network finds that it cannot cope with it, lights are randomly switched on or off all over the city, and there is a state of anarchy. Afterwards, it is retrained to the perfect state again, and the process repeats. Any ideas on how I would go about solving it? I fiddled with the idea of introducing a forced accident on every run, to check how the network performs, but I don''t like it. Cheers for any help in advance.
Advertisement
You might want to take a look at halting the NN processing when the Time Without Accident Max is reached. But that requires a case by case analysis which you are trying to avoid.

Or you might want to take a look at a global figure of MTBA(Mean Time Between Accidents) and use that as one of the components of a MinMax function.

ZoomBoy
Developing a iso-tile 2D RPG with skills, weapons, and adventure. See my old Hex-Tile RPG GAME, character editor, diary, 3D Art resources at Check out my web-site
quote: Original post by The_Dan

The program was structured as follows:

There was a simulation of the road network of a small city (it was a grid based city, with 4x4 road intersections, making a total of 16 junctions, each with 4 traffic lights. Each traffic light had only two states, Go or Stop)

There was an artificial neural network, consisting of two input layers, quite a few (I''m not sure how many) hidden layers, and the output layer.



Without seeing the actual training data and results it''s a little difficult to analyse the problem.

However, I''m first stuck on the following questions!

Why was an artificial neural net applied to the problem of switching traffic lights? Clearly, at any given intersection, the lights should be on (''Go'') in one direction and off (''Stop'') in the other. This should inherantly prevent accidents? Why would you want to have lights on ''Go'' in both directions?

Also consider that the optimum state of the system should be for every light to be in the off (''Stop'') state, thus preventing traffic flow and hence stopping all accidents! Not a very interesting solution but certainly a valid one given the info you have provided.

If the task was to see if the ANN could learn an optimal flipping of lights, then I believe you have applied the wrong tool to the job. You would be far better applying a GA or SA algorithm to the problem as it is inherantly designed for optimisation problems.

Here, optimality is based on an objective utility function. In your case, you would be trying to minimise the number of accidents. Again though, I cannot see how you get accidents unless you have lights on in both directions of an intersection at the same time. It would seem non-sensical to do this as a starting assumption of the system!!

Regards,

Tim
Assuming the letter ''o'' represents an intersection while ''-'' or ''|'' represents a road segment, what happens when:
          Go       Stop        |         |Stop ---o---------o--- Go        |         |           Go       Stop  

? A vehicle coming from the right could go straight through and collide with a vehicle heading North/South on the left-hand road.
Yes, that is what would happen. The cars keep going until they either reach a stopped car in front of them, or they reach a traffic light on Stop

Timkin: I used an ANN because I was reading up on the structure of them for quite a few months, and I wanted to try my hand at using one. Undeniably, there probably was a better method of solving the problem (as there usually is), but I wanted to use an ANN.

[Edit: Oh yeah, and just no accidents would not have given the best solution as no cars would have reached their destinations ]


Edited by - The_Dan on May 25, 2001 4:00:35 AM

This topic is closed to new replies.

Advertisement