Click here to Skip to main content
13,199,852 members (66,467 online)
Rate this:
 
Please Sign up or sign in to vote.
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 17-Jul-17 10:01am
Updated 18-Jul-17 11:09am
v4
Comments
ppolymorphe 17-Jul-17 16:04pm
   
Show your code
TheVoidDz 17-Jul-17 16:22pm
   
it is here https://pastebin.com/7WmXrnXJ , (its long code)
ppolymorphe 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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
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 :)
ppolymorphe 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 ?
ppolymorphe 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 18 Jul 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100