[Tutor] Help needed with Python programming
Suhana Vidyarthi
suhanavidyarthi at gmail.com
Tue Apr 22 03:16:20 CEST 2014
My knowledge of coding is fairly limited and I am having a hard time
writing a Python code which might be pretty simple for you :-)
Here is what I am doing and I need help with:
I have a python code that shows a set of shortest paths between nodes A and
B. Now I have to select the least risky path among them. To do that I have
to consider the risk values of each link. I know how to calculate the
path's risk using its link value.
For example: There is a path between node A and B wiht two links.
Probability of failure for link 1 is 0.001 and for link 2 is 0.003. Here is
the link with its risk values:
A o--------------------o---------------------o B
0.001 0.003
So the probability of the link being down will be: 1 - (0.999 x 0.997) =
0.996003
You can find the attached file with disaster risk values of each link.
For instance; first line is : 1,3,5,0.03 --> this means, first disaster
affects links 1-3 and 5-0 and its occurrence rate is 0.03. So you need to
assign link (1-3)'s risk to 0.03.
Then you will continue with the next disaster which is the one in the next
line. Note that, if a link gets affected by 2 disasters, you will add the
probability of those 2 disasters to find that link's risk.
If anyone can help me code the first line, I will be able to do the rest.
You need use "array list" and some functions like "file reader" and
"delimiter" I guess.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140421/2aea7b16/attachment.html>
-------------- next part --------------
1,3,5,0.03
2,3,5,5,4,0.11
3,3,5,5,4,5,8,0.04
2,5,8,7,8,0.04
3,14,10,14,13,17,13,0.04
1,14,18,0.06
4,10,13,14,13,17,13,12,13,0.04
4,11,6,11,9,11,12,11,19,0.08
3,19,20,15,20,21,20,0.24
1,21,20,0.05
3,20,21,21,16,21,22,0.27
More information about the Tutor
mailing list