Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: how to make this code more efficient? Need to Compute the Min and Max of a Temperature using an equation

by NiJo (Friar)
on Apr 21, 2010 at 21:22 UTC ( [id://836137]=note: print w/replies, xml ) Need Help??


in reply to how to make this code more efficient? Need to Compute the Min and Max of a Temperature using an equation

Your program currently uses only 1 CPU. A cheap way to parallel programming is splitting your task into a 'string expander' that sends expanded strings over one by one and a seperate min/max searcher called on the shell as e. g.
string_expander <start string> | minmax
This does not need any large intermediate storage in RAM.

The classical way to store large data structures is in a file created by string_expander and read by minmax line by line. The pipe saves that step and replaces it with standard output on string_expander and standard output of minmax.

A premature micro optimisation is to move the calculation of salt effect out of the loop per string, as it is constant.

This is still the brute force method, but done better. If you put more brain to the problem, probabilities of large numbers may play to your favor. I did not grasp your temperature calculation and final application completely, but somewhere in the large number of expanded strings the maximum and minimum 2 letter combinations of %array_h and %array_s are contained. The most probable answer for min/max temperature over all expanded strings depends only on string length and best/worst case substitions. As there is only one potenial substitution for each meta letter (N, Y...) and maximum temperature and another substitution for minimum temperature, you could do the whole calculation by hand.

I have no idea what you are scientifically doing with the results of your calculations. But assuming a more or less linear relationship with your 30% spread in input variables (%array_s and %array_h), skipping the calculation might just have a +-15 % spread on output (assuming 3 standard deviations between min and max). Is 5% RSD really larger than the error margin of your theoretical calculation?

  • Comment on Re: how to make this code more efficient? Need to Compute the Min and Max of a Temperature using an equation
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://836137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found