Click here to Skip to main content
15,880,392 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,
Recently i have been working on a simple Simulation Code (Discrete Event Simulation) with a single queue and single server and deterministic number of clients with Python , i just want to know if my code is correct or i'm i missing something , because i'm having some difficulites in the Queue , how to fill it if the new Arrivals of a clients are < to the Departure Time of a previous Client .. my code work but its just fill one client at a time then pop it from the queue to start the service .. etc
what i'm i missing here ?

What I have tried:

I have Tried this code here : [Python] Simulation Queue Python - Pastebin.com[^] i wrote it using class , and i still didn't try Simpy Framework .


i'm supposed to have the algorithm like this .. the first client arrive , the server start the service directly and then after it finish the client leave , while the server is busy , there is a possibility that another client has come , so the server can't treat the 2nd client , and the 2nd will enter the Queue , waiting for the 1st client to finish .. and so on , which means if the third client come he also enter the Queue , My Code he is only queuing one client at a time , i mean the Queue never fills up with the clients waiting , it fill only one client , then pop it when server finish , then queuing the 3rd client .. and so on .. you got my point here ?
Posted
Updated 18-Jul-17 11:09am
v4
Comments
Patrice T 17-Jul-17 16:04pm    
Show your code
TheVoidDz 17-Jul-17 16:22pm    
it is here https://pastebin.com/7WmXrnXJ , (its long code)
Patrice T 17-Jul-17 16:27pm    
Paste your code here !
Use Improve question to update your question.
So that everyone can pay attention to this information.
TheVoidDz 17-Jul-17 16:31pm    
Done !

1 solution

Quote:
i just want to know if my code is correct or i'm i missing something ,

As programmer, it is your task to make your code right and to know that it is so.
Quote:
i'm having some difficulites in the Queue

This is not informative, describe the problem, give example.
Quote:
my code work but its just fill one client at a time then pop it from the queue to start the service .. etc

To see what your code is doing, use the debugger.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]
phpdbg | php debugger[^]
Debugging techniques for PHP programmers[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
Comments
TheVoidDz 17-Jul-17 20:57pm    
Yeah, i could really use the debugger to find out the problem .. anyway , it is just that i'm certain that there is something wrong in the code .. i will keep trying .. thank you :)
Patrice T 17-Jul-17 20:59pm    
Try to describe how it is wrong.
TheVoidDz 18-Jul-17 6:53am    
i'm supposed to have the algorithm like this .. the first client arrive , the server start the service directly and then after it finish the client leave , while the server is busy , there is a possibility that another client has come , so the server can't treat the 2nd client , and the 2nd will enter the Queue , waiting for the 1st client to finish .. and so on , which means if the third client come he also enter the Queue , My Code he is only queuing one client at a time , i mean the Queue never fills up with the clients waiting , it fill only one client , then pop it when server finish , then queuing the 3rd client .. and so on .. you got my point here ?
Patrice T 18-Jul-17 7:39am    
Use Improve question to update your question.
So that everyone can pay attention to this information.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900