[Ncr-Python.in] [HELP] QUERIES RELATED TO PYTHON

saurabh chandra fatboyslimchandra at gmail.com
Sun Apr 21 13:24:01 CEST 2013


I am trying to develop an algorithm for a combinatorial optimization. The
problem consists of a graph network with nodes and connected arcs. In this
algorithm I have to choose an optimal combination of nodes out of all the
nodes in the graph. The successive nodes are selected as entries in the
list using a random search technique. Successive nodes share a precedence
relationship.
In each iteration of the algorithm I generate a combination of a subset of
nodes chosen randomly from the whole node-set, as a list. In the same loop
I carry out a modification of the generated list and calculate the
objective value associated with this . A particular generated list in any
loop will give rise to a single modified list.

Now I do not want same list to be generated again and again, so I maintain
a super-list of generated lists and check the membership of each new list
in this super-list. I restart the loop if same list appears again in the
algorithm. As I already said the original list gets modified within an
iteration. The problem is that although I append the super-list with the
original list before modification, as soon as I modify this original list
the list added to the super-list also changes automatically. Thus the
iteration goes on even if the same list is generated again and again.

I have tried many things: appending a copy of the original list to the
super-list (using this command L1 = L[:], so that the new list is stored at
a different address, still the same stuff happends.

Please help me out here. I did not produce my code here as its too
complicated. I can if someone is ready to help...

thanks and regards

Saurabh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ncr-python.in/attachments/20130421/43ff7558/attachment.html>


More information about the Ncr-Python.in mailing list