Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Monte Carlo Optimization' topicStudent Support Forum > General > Archives > "Monte Carlo Optimization"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
04/25/13 4:38pm

In Response To 'Re: Re: Monte Carlo Optimization'
Reap and Sow can be used with tags. You can use those to "put labels" on items tossed into the bag and later select items from the bag based on the tags. I have never made sense of that.

What I hoped to do, and certainly could have made mistakes doing, was to try to simulate your process of saving the result of each iteration if your For[] into one list or another by throwing everything into the Table[] and afterwards extracting those labeled BPS and separately extracting those labeled TS.

From your reply it sounds like you are seeing a bug and somehow my use of Cases to extract the two sets of items is actually extracting the same set.

It is certainly possible that I've made a mistake. Using symbols like BPS and TS without having assigned values like 1 and 2 to those can sometimes cause confusion with == or ===. So I would be very skeptical until you are certain that I haven't just given you a piece of buggy code.

When I run your code and immediately after that cell do:

In[41]:= {Length[tbl], Length[bestParamSets], Length[thrownsets]}

Out[41]= {9999, 5064, 4935}

That sort of looks like something different is going into bestParamSets and thrownsets and the total number of items in both match the number in tbl.

I didn't study the details of the content of what you were doing with AppendTo in your original code, perhaps you were storing something that I didn't understand.

I am worried when I try to display the contents of bestParamSets or even Short[bestParamSets] that it seems to take an extremely long time. I'm also puzzled when I display bestParamSets[[1]] and don't see a list of 5 numbers that I expected, but instead see some vast long list.

Short[bestParamSets] finally finishes with

In[45]:= Short[bestParamSets]

Out[45]//Short= {{1, 1,2.60009*^-143, 1, 2.01849*^-226, 1, <<9989>>, 1, 1.82739*^-17, 6.05927*^-15, 1, 0}, <<5063>>}

So it appears to me that you are actually throwing vectors with ten thousand elements into the bag on every iteration of your For[] (or Table[]) and doing that ten thousand times, true?

If we can verify that there is some error in this then we can try to track down what went wrong and see if we can fix it.

Is there some specific test I can do that will confirm this?

URL: ,

Subject (listing for 'Monte Carlo Optimization')
Author Date Posted
Monte Carlo Optimization Patrick 04/19/13 10:11am
Re: Monte Carlo Optimization Bill Simpson 04/21/13 11:00pm
Re: Re: Monte Carlo Optimization Patrick 04/24/13 7:33pm
Re: Re: Re: Monte Carlo Optimization Bill Simpson 04/25/13 4:38pm
Re: Re: Re: Re: Monte Carlo Optimization Patrick 05/01/13 09:23am
Re: Re: Re: Re: Re: Monte Carlo Optimization Bill Simpson 05/02/13 9:08pm
Re: Re: Re: Re: Re: Re: Monte Carlo Optimization Patrick 05/03/13 1:12pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic