複数のリスト項目を連結するJMP12.2 の使用 - リストの項目数が同じであると仮定して、2 つの異なるリストのリスト項目を 1 対 1 で連結する高速な方法を探しています。 これは非常に大きなテーブルで For Each Row として使用されるため、可能であれば反復関数は使用しない方がよいと考えています。
これが私が達成したいことの例です:
list1 = {"a"、"b"、"c"、"d"、"e"、"f"、"g"};
list2 = {"1"、"2"、"3"、"4"、"5"、"6"、"7"};
受け入れられる結果は文字列またはリストです。 文字列が区切り文字で区切られている場合。
リスト結果: {"a,1","b,2","c,3","d,4","e,5","f,6","g,7"};
文字列結果: "a:1,b:2,c:3,d:4,e:5,f:6,g:7";
マスカスタマイゼーションRe: 複数のリスト項目を連結するめちゃくちゃにしてしまった! 以下は、おそらく古いバージョンの JMP で正しく動作する更新バージョンです。
dtGraph = New Table( "stats",
Add Rows( 0 ),
New Column( "size", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "table time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "loop time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) )
);
For( n = 1, n < 1e7, n *= 2,
dtGraph << addrows( 1 );
dtGraph:size[N Rows( dtGraph )] = n * 3;// 3 items repeated...
list1 = Repeat( {"a", "b", "c"}, n );
list2 = Repeat( {"1", "2", "3"}, n );
start = HP Time(); // data table method begins here
dt = New Table( "temp",
New Column( "a", Character, "Nominal", Set Values( list1 ) ),
New Column( "b", Character, "Nominal", Set Values( list2 ) ),
New Column( "c", Character, "Nominal", formula( a || ":" || b ) ),
invisible
);
dt << runformulas;
result = dt:c << getvalues;
Close( dt, nosave );
stop = HP Time(); // data table method ends here
Show( stop - start );
result = Concat Items( result, "," );
Show( Length( result ), Left( result, 100 ) );
dtGraph:table time[N Rows( dtGraph )] = (stop - start) / 1e6;
result = {};
start = HP Time(); // loop method begins here
While(
aa = Remove From( list1, 1 );
bb = Remove From( list2, 1 );
N Items( aa ); // as long as something was removed...
, // do this...
Insert Into( result, aa[1] || ":" || bb[1], 1 ) // <<<<<<<<< here
);
result=reverse(result); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< and here
stop = HP Time(); // loop method ends here
Show( stop - start );
result = Concat Items( result, "," );
Show( Length( result ), Left( result, 100 ) );
dtGraph:loop time[N Rows( dtGraph )] = (stop - start) / 1e6;
Wait( 1 );
);
dtGraph << Graph Builder(
Size( 1200, 500 ),
Show Control Panel( 0 ),
Variables( X( :size ), Y( :table time ), Y( :loop time, Position( 1 ) ) ),
Elements( Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ), Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) ) ),
SendToReport(
Dispatch( {}, "size", ScaleBox, {Scale( "Log" ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "table time", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} )
)
);見るファーストリスト説明のために。 RemoveFrom 関数に集中していて、Insert Into 関数のことを忘れていました。
Insert Into needs a 3rd argument to insert at the beginning of the list, and then a reverse when done.Insert Into needs a 3rd argument to insert at the beginning of the list, and then a reverse when done.Insert Into には、リストの先頭に挿入する 3 番目の引数が必要で、完了したらその逆が必要です。
また、データ テーブルの列を一時変数として使用しないように、ループ内の変数の名前も変更しました。
Re: 複数のリスト項目を連結する私の問題は解決しました。これは、あなたや役立つと思われる他の人のための参考情報です。
JMP14.3 にアクセスできますが、組織内の互換性のためにスクリプトは JMP12.2 で実行する必要があります。
私はあなたの分析を試みましたが、JMP14.3についてはあなたと同様の結果が得られました - おそらく計算能力にいくつかの違いがあります。

ただし、JMP12.2 のループのパフォーマンスは完全に規格外です。 時間は指数関数的に増加しており、24 行目に到達することは決してなかったため、98304 以降の JMP.exe プロセスを強制終了する必要がありました。

Re: 複数のリスト項目を連結するありがとう、これはうまくいきます。 反復関数を使用しているにもかかわらず、優れたパフォーマンスを発揮します。
Re: 複数のリスト項目を連結するはい、iterative(for each row) 内の iterative(for) がスクリプトのパフォーマンスに重大な影響を与えると想定していたのかもしれませんが、サンプルを構築した後は@SDF1パフォーマンスが驚くほど優れていることが示唆されました。
比較していただきありがとうございます。C++ のほうが常に高速であると思っていましたが、テーブルの方が常にオーバーヘッドが大きいのは当然です。 「データ更新の開始」や「プライベート」テーブルを使用すると、テーブルのオーバーヘッドが改善されるでしょうか?
Re: 複数のリスト項目を連結するJSL ループには不当に悪い評判があります。 ループの本質が多くの作業を行う場合、通常、ループのオーバーヘッドはそれほど問題になりません。 そして、JSL ループを使用しないソリューションには、どこか別の場所 (おそらく C++ のループ) が含まれるため、もう少し高速になりますが、それでもです。 とにかく、ここでは 2 つのメソッドの比較を示します。1 つは JSL ループを使用し、もう 1 つは JMP の C++ コードに隠されたループを使用します。
Graph showing crossover times of the two algorithms at around 39,000 elements.Graph showing crossover times of the two algorithms at around 39,000 elements.約 39,000 要素における 2 つのアルゴリズムのクロスオーバー時間を示すグラフ。
dtGraph = New Table( "stats",
Add Rows( 0 ),
New Column( "size", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "table time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) ),
New Column( "loop time", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [] ) )
);
For( n = 1, n < 1e7, n *= 2,
dtGraph << addrows( 1 );
dtGraph:size[N Rows( dtGraph )] = n * 3;// 3 items repeated...
list1 = Repeat( {"a", "b", "c"}, n );
list2 = Repeat( {"1", "2", "3"}, n );
start = HP Time(); // data table method begins here
dt = New Table( "temp",
New Column( "a", Character, "Nominal", Set Values( list1 ) ),
New Column( "b", Character, "Nominal", Set Values( list2 ) ),
New Column( "c", Character, "Nominal", formula( a || ":" || b ) ),
invisible
);
dt << runformulas;
result = dt:c << getvalues;
Close( dt, nosave );
stop = HP Time(); // data table method ends here
Show( stop - start );
result = Concat Items( result, "," );
Show( Length( result ), Left( result, 100 ) );
dtGraph:table time[N Rows( dtGraph )] = (stop - start) / 1e6;
result = {};
start = HP Time(); // loop method begins here
While(
a = Remove From( list1, 1 );
b = Remove From( list2, 1 );
N Items( a ); // as long as something was removed...
, // do this...
Insert Into( result, a[1] || ":" || b[1] )
);
stop = HP Time(); // loop method ends here
Show( stop - start );
result = Concat Items( result, "," );
Show( Length( result ), Left( result, 100 ) );
dtGraph:loop time[N Rows( dtGraph )] = (stop - start) / 1e6;
Wait( 1 );
);
dtGraph << Graph Builder(
Size( 1200, 500 ),
Show Control Panel( 0 ),
Variables( X( :size ), Y( :table time ), Y( :loop time, Position( 1 ) ) ),
Elements( Points( X, Y( 1 ), Y( 2 ), Legend( 5 ) ), Smoother( X, Y( 1 ), Y( 2 ), Legend( 6 ) ) ),
SendToReport(
Dispatch( {}, "size", ScaleBox, {Scale( "Log" ), Inc( 1 ), Minor Ticks( 1 )} ),
Dispatch( {}, "table time", ScaleBox, {Scale( "Log" ), Format( "Best", 12 ), Inc( 1 ), Minor Ticks( 1 )} )
)
);JMP 14 は私がアクセスできる中で最も古いものです。 ループ アルゴリズムは JMP 12 でも同様のパフォーマンスになると思います。 古い JMP バージョンではリストのインデックス作成が高速ではなかったので、処理中に 2 つのリストを意図的に破棄しますが、最初の要素の削除は高速です。 データ テーブル アルゴリズムはループの最初にあるため、リストが破棄される前にリストを使用できます。
JSL を振り返ってみると、どちらのアルゴリズムがより単純であるとか、従うのが簡単であるなどとは主張すべきではありません。
Re: 複数のリスト項目を連結するやあ@ts2 、
結果をどうしたいかに応じて、いくつかの異なる方法でアプローチできます。 反復関数を実行したくないのはわかりますが、あるリストの要素が別のリストの要素に接続されている正しい出力を取得するには、For ループを実行する必要があると思います。 連想配列を使用することも検討できます。
以下は、ソリューションの開始に役立つ可能性のある JSL の一部です。
names default to here(1);
list1 = {"a","b","c","d","e","f","g"};
list2 = {"1","2","3","4","5","6","7"};
AA = Associative Array(List1, List2);
i=.;
result1={};
For(i=1, i<=nitems(list1), i++,
result1[i]=list1[i]||":"||list2[i]
);
result 2 = EvalList({Concat Items(result1, ", ")});
Show(result1);
Show(result2);
Show (AA);お役に立てれば!、
DS