Testing Lists

• To: mathgroup at smc.vnet.net
• Subject: [mg15043] Testing Lists
• From: Jorge Zickermann <jzickermann at mail.EUnet.pt>
• Date: Wed, 9 Dec 1998 04:12:26 -0500
• Organization: Personal
• Sender: owner-wri-mathgroup at wolfram.com

Dear Sirs,

I am trying to use, as an alternative to iteration, variation of
parameters to create all possible solutions to a problem and then
choose the best one.
In the example I send, I am varying the Length (L), Breadth (B) and
Block Coefficient (CB), one percent on each side of each average value
obtained from statistics of existant ships simillar to the one I
pretend to design.
Therefore, given the resultrange of 1 percent and a precision of 1
percent, I obtain a list of 3 values being the centre one the value
obtained from the statistics.
Using the 'Outer' function I can create all posible combinations of
ships with the Lengths, Bradths, etc varying.
In this simple example I use three parameters and a resultrange and
precision such that I obtain 3x3x3 = 27 ships for study. Eventually I
will use many more parameters, a wider resultrange and a higher
precision in order to create a table of millions of ships to be
analysed. Up to here everything works fine.
The idea is then to apply a function (in the example sent the function
is Ship and is not defined) of the parameters considered to each
possible ship and obtain a result for each one.

First problem;
I haven't managed to create a composed function of the style,

Ship[L,B,CB] = f[g[L,B,CB]]

How can I get round to to achieving that?

Second problem;
Once I obtain a table of results for each ship (so far I've managed
that using simple functions 'Ship[L,B,CB]'), I want to select the
positions of ships whoose results are in between two values defined by
me. What happens is that if I test the result to be equal to a certain
value, the program returns the list of positions of the ships that meet
the test requirements. However, if the test function is an inequality,
I am always given back the empty set result.

How can I test values in lists with an inequality test function?

A last but important question;
Given the explanation of what I intend to do, am I completely off
course regarding the best way to tackle the problem?

In[63]:=
L = 182

Out[63]=
182

In[64]:=
resultrange = 0.01;

In[65]:=
precision = 0.01;

In[66]:=
L = Range[(1-resultrange)*L,(1+resultrange)*L,precision*L]

Out[66]=
{180.18,182.,183.82}

In[67]:=
Length[%]

Out[67]=
3

In[68]:=
B = 28.4

Out[68]=
28.4

In[69]:=
B = Range[(1-resultrange)*B,(1+resultrange)*B,precision*B]

Out[69]=
{28.116,28.4,28.684}

In[70]:=
Length[%]

Out[70]=
3

In[71]:=
CB = 0.85

Out[71]=
0.85

In[72]:=
CB = Range[(1-resultrange)*CB,(1+resultrange)*CB,precision*CB]

Out[72]=
{0.8415,0.85,0.8585}

In[73]:=
Length[%]

Out[73]=
3

In[74]:=
PossibleShips= Outer[Ship,L,B,CB]//TableForm

TableForm[ {{{
Ship[ 180.18, 28.116, 0.8415],
Ship[ 180.18, 28.116, 0.85],
Ship[ 180.18, 28.116, 0.8585]}, {
Ship[ 180.18, 28.4, 0.8415],
Ship[ 180.18, 28.4, 0.85],
Ship[ 180.18, 28.4, 0.8585]}, {
Ship[ 180.18, 28.684, 0.8415],
Ship[ 180.18, 28.684, 0.85],
Ship[ 180.18, 28.684, 0.8585]}}, {{
Ship[ 182.0, 28.116, 0.8415],
Ship[ 182.0, 28.116, 0.85],
Ship[ 182.0, 28.116, 0.8585]}, {
Ship[ 182.0, 28.4, 0.8415],
Ship[ 182.0, 28.4, 0.85],
Ship[ 182.0, 28.4, 0.8585]}, {
Ship[ 182.0, 28.684, 0.8415],
Ship[ 182.0, 28.684, 0.85],
Ship[ 182.0, 28.684, 0.8585]}}, {{
Ship[ 183.82, 28.116, 0.8415],
Ship[ 183.82, 28.116, 0.85],
Ship[ 183.82, 28.116, 0.8585]}, {
Ship[ 183.82, 28.4, 0.8415],
Ship[ 183.82, 28.4, 0.85],
Ship[ 183.82, 28.4, 0.8585]}, {
Ship[ 183.82, 28.684, 0.8415],
Ship[ 183.82, 28.684, 0.85],
Ship[ 183.82, 28.684, 0.8585]}}}]]\)

In[75]:=
Dimensions[%]

Out[75]=
{3,3,3}

• Prev by Date: Re: Manipulating the Front End from the Kernel (moving Graphics)
• Next by Date: Re: What's wrong in this plot?
• Previous by thread: Re: Manipulating the Front End from the Kernel (moving Graphics)
• Next by thread: Re: Testing Lists