15 #include "../scheduling/Clock.h"
16 #include "../scheduling/testScheduling.h"
18 #include "../builtins/Arith.h"
36 Id child = shell->
doCreate(
"Neutral",
Id(),
"test", 1 );
54 assert( f2a !=
Id() );
56 assert( f2b !=
Id() );
58 assert( f2c !=
Id() );
60 assert( f3aa !=
Id() );
62 assert( f3ab !=
Id() );
64 assert( f3ba !=
Id() );
67 Id f5 = shell->
doCreate(
"SimpleSynHandler",
ObjId(f4, i++),
"syns", 10 );
70 for (
unsigned int i = 0; i < 10; ++i ) {
78 assert( me ==
ObjId( f3aa, 0 ) );
80 assert( me ==
ObjId( f3ba, 0 ) );
82 assert( me ==
ObjId( f2c, 0 ) );
88 assert( pa ==
ObjId( f2a, 3 ) );
90 assert( pa ==
ObjId( f2a, 4 ) );
92 assert( pa ==
ObjId( f1, 1 ) );
94 assert( pa ==
ObjId(
Id(), 0 ) );
103 assert( kids.size() == 1 );
104 assert( kids[0] == f2a );
106 assert( kids.size() == 1 );
107 assert( kids[0] == f2b );
109 assert( kids.size() == 1 );
110 assert( kids[0] == f2c );
113 assert( kids.size() == 3 );
114 assert( kids[0] == f2a );
115 assert( kids[1] == f2b );
116 assert( kids[2] == f2c );
119 assert( kids.size() == 2 );
120 assert( kids[0] == f3aa );
121 assert( kids[1] == f3ab );
124 assert( kids.size() == 0 );
126 assert( kids.size() == 1 );
127 assert( kids[0] == f3ba );
130 assert( kids.size() == 0 );
132 cout <<
"." << flush;
137 string path = syns.path();
138 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse" );
139 ObjId oi( syns, 8, 3 );
141 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[8]/synapse[3]" );
143 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse" );
147 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[4]" );
149 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell" );
151 cout <<
"." << flush;
157 assert( path ==
"/f1[0]/f2a[3]/f3aa[0]" );
159 assert( path ==
"/f1[0]/f2a[4]/f3ab[0]" );
161 assert( path ==
"/f1[1]/f2b[5]/f3ba[0]" );
163 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[0]" );
165 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[0]/synapse[0]" );
167 assert( path ==
"/f1[1]/f2b[5]/f3ba[6]/cell[7]/syns[8]/synapse[3]" );
170 assert( path ==
"/f1[0]/f2a[7]" );
172 assert( path ==
"/f1[1]/f2b[2]" );
174 assert( path ==
"/f1[2]/f2c[0]" );
176 assert( path ==
"/f1[0]" );
178 assert( path ==
"/" );
182 cout <<
"." << flush;
188 assert( shell->
doFind(
"/f1/f2a/tralalalala" ).
bad() );
189 assert( shell->
doFind(
"/f1/f2a[723]/f3aa" ).
bad() );
190 assert( shell->
doFind(
"/f1/f2a/f3aa[12]" ).
bad() );
192 cout <<
"\nTesting warning for bad path indexing: ";
193 assert( shell->
doFind(
"/f1/f2a/f3aa[-1]" ).
bad() );
196 assert( ret == f3aa );
197 ret = shell->
doFind(
"/f1/f2a[4]/f3ab" );
198 assert( ret == f3ab );
199 ret = shell->
doFind(
"/f1[1]/f2b[5]/f3ba" );
200 assert( ret == f3ba );
201 ret = shell->
doFind(
"/f1[1]/f2b[5]/f3ba[6]" );
202 assert( ret ==
ObjId( f3ba, 6 ) );
203 ret = shell->
doFind(
"/f1[1]/f2b[5]/f3ba/.." );
204 assert( ret ==
ObjId( f2b, 5 ) );
205 assert( shell->
doFind(
"f1[1]/f2b[5]/f3ba" ) == f3ba );
206 assert( shell->
doFind(
"./f1[1]/f2b[5]/f3ba" ) == f3ba );
207 assert( shell->
doFind(
"./f1[1]/f2b/.." ) ==
ObjId( f1, 1 ) );
211 assert( shell->
doFind(
"f3ba" ) == f3ba );
212 assert( shell->
doFind(
"f3ba[7]" ) ==
ObjId( f3ba, 7 ) );
213 assert( shell->
doFind(
"f3ba/" ) == f3ba );
214 assert( shell->
doFind(
"f3ba/.." ) ==
ObjId( f2b, 5 ) );
216 assert( shell->
doFind(
"f3ba/../../" ) ==
ObjId( f1, 1 ) );
217 assert( shell->
doFind(
"../../f1/f2a[4]/f3ab" ) == f3ab );
220 cout <<
"." << flush;
230 cout <<
"." << flush;
240 Id f2a = shell->
doCreate(
"Neutral", f1,
"f2a", 1 );
241 Id f2b = shell->
doCreate(
"Neutral", f1,
"f2b", 1 );
242 Id f3aa = shell->
doCreate(
"Neutral", f2a,
"f3aa", 1 );
262 cout <<
"." << flush;
271 assert( kids.size() == 2 );
272 assert( kids[0] == f2a );
273 assert( kids[1] == f2b );
280 assert( tree.size() == 6 );
281 assert( tree[5] == f1 );
282 assert( tree[3] == f2a );
283 assert( tree[2] == f3 );
284 assert( tree[0] == f4a );
285 assert( tree[1] == f4b );
286 assert( tree[4] == f2b );
296 Id f2a = shell->
doCreate(
"Neutral", f1,
"f2a", 1 );
297 Id f2b = shell->
doCreate(
"Neutral", f1,
"f2b", 1 );
298 Id f3 = shell->
doCreate(
"Neutral", f2a,
"f3", 1 );
299 Id f4a = shell->
doCreate(
"Neutral", f3,
"f4a", 1 );
300 Id f4b = shell->
doCreate(
"Neutral", f3,
"f4b", 1 );
306 cout <<
"\nTesting warning for creating element with existing name: ";
307 Id fx1 = shell->
doCreate(
"Neutral", f1,
"f2b", 1 );
308 assert( fx1 ==
Id() );
315 cout <<
"\nTesting warning for name change to existing name: ";
320 cout <<
"." << flush;
330 Id f2a = shell->
doCreate(
"Neutral", f1,
"f2a", 1 );
331 Id f2b = shell->
doCreate(
"Neutral", f1,
"f2b", 1 );
332 Id f3 = shell->
doCreate(
"Neutral", f2a,
"f3", 1 );
333 Id f4a = shell->
doCreate(
"Neutral", f3,
"f4a", 1 );
334 Id f4b = shell->
doCreate(
"Neutral", f3,
"f4b", 1 );
338 assert( pa ==
ObjId( f3, 0 ) );
340 assert( pa ==
ObjId( f1, 0 ) );
342 assert( path ==
"/f1[0]/f2a[0]/f3[0]/f4a[0]" );
346 assert( kids.size() == 2 );
347 assert( kids[0] == f2a );
348 assert( kids[1] == f2b );
352 assert( kids.size() == 2 );
353 assert( kids[0] == f4a );
354 assert( kids[1] == f4b );
361 assert( pa ==
ObjId( f1, 0 ) );
364 assert( kids.size() == 3 );
365 assert( kids[0] == f2a );
366 assert( kids[1] == f2b );
367 assert( kids[2] == f4a );
369 assert( kids.size() == 1 );
370 assert( kids[0] == f4b );
373 shell->
doMove( f2a, f4a );
376 assert( pa ==
ObjId( f4a, 0 ) );
378 assert( path ==
"/f1[0]/f4a[0]/f2a[0]/f3[0]/f4b[0]" );
381 assert( kids[0] == f2b );
382 assert( kids[1] == f4a );
385 cout <<
"." << flush;
403 assert( pa ==
ObjId( f2a, 0 ) );
405 assert( pa ==
ObjId( f1, 0 ) );
407 assert( path ==
"/f1[0]/f2a[0]/f3[0]" );
410 Id dupf2a = shell->
doCopy( f2a,
Id(),
"TheElephantsAreLoose", 1,
false,
false );
415 assert( dupf2a !=
Id() );
420 Id dupf3 = f2aDupData->child( dupf2a.
eref(),
"f3" );
421 assert( dupf3 !=
Id() );
422 assert( dupf3 != f3 );
424 vector< Id > kids = f2aDupData->getChildren( dupf2a.
eref() );
425 assert( kids.size() == 1 );
426 assert( kids[0] == dupf3 );
431 assert( kids.size() == 2 );
432 assert( kids[0].element()->getName() ==
"f4a" );
433 assert( kids[1].element()->getName() ==
"f4b" );
437 cout <<
"." << flush;
444 unsigned int size = 10;
445 unsigned int size2 = 17;
447 Id origSynId( origId.
value() + 1 );
450 Element* syn = origSynId.element();
452 assert( syn->
getName() ==
"synapse" );
453 assert( syn->
numData() == size );
454 assert( origChild.element()->numData() == size2 );
457 vector< unsigned int > vec(size);
465 for (
unsigned int i = 0; i < size; ++i ) {
471 for (
unsigned int i = 0; i < size; ++i ) {
472 vector< double > delay;
473 for (
unsigned int j = 0; j < i; ++j ) {
474 delay.push_back( 3.14 * j + i * i );
478 assert( ret == ( i > 0 ) );
485 vector< Id > origChildren;
487 assert( origChildren.size() == 2 );
489 unsigned int numCopy = 2;
491 Id copyId = shell->
doCopy( origId,
Id(),
"dup", numCopy,
false,
false);
495 origChildren.resize( 0 );
497 vector< Id > copyChildren;
500 assert( origChildren.size() == 2 );
501 assert( origChildren[0] == origSynId );
502 assert( origChildren.size() == copyChildren.size() );
503 Id copySynId = copyChildren[0];
504 Id copyChild = copyChildren[1];
506 Element* copySynElm = copySynId.element();
509 assert ( copySynElm != 0 );
510 assert ( copySynElm->
getName() ==
"synapse" );
511 assert( copySynElm->
numData() == numCopy * size );
512 unsigned int numSyn = 0;
513 for (
unsigned int i = 0; i < numCopy * size; ++i ) {
516 ObjId( copySynId, i ),
"numField" );
517 assert( nf == i % size );
521 assert ( copyChild.
element() != 0 );
525 for (
unsigned int i = 0; i < numCopy * size; ++i ) {
526 unsigned int k = i % size;
527 vector< double > delay;
528 vector< double > delay2;
537 assert( delay.size() == k );
538 assert( delay == delay2 );
539 for (
unsigned int j = 0; j < k; ++j ) {
540 assert(
doubleEq( delay[j], 3.14 * j + k * k ) );
546 cout <<
"." << flush;
553 unsigned int s1 = 10;
555 unsigned int s3 = 23;
558 unsigned int index1 = 1;
559 unsigned int index2 = 0;
560 unsigned int index3 = 3;
561 unsigned int index4 = 0;
562 unsigned int index5 = 5;
564 Id level1 = shell->
doCreate(
"SimpleSynHandler",
Id(),
"f1", s1 );
565 Id origSynId( level1.
value() + 1 );
569 ObjId origSynObj( origSynId, 7, 5 );
576 ObjId( level1, index1 ),
"f2", s2 );
578 ObjId( level2, index2 ),
"f3", s3 );
580 ObjId( level3, index3 ),
"f4", s4 );
582 ObjId( level4, index4 ),
"f5", s5 );
584 ObjId oi( level5, index5 );
586 assert( path ==
"/f1[1]/f2[0]/f3[3]/f4[0]/f5[5]" );
588 ObjId readPath( path );
589 assert( readPath.
id == level5 );
594 assert( path ==
"/f1[1]/f2[0]/f3[3]/f4[0]" );
598 assert( path ==
"/f1[1]/f2[0]/f3[3]" );
602 assert( path ==
"/f1[1]/f2[0]" );
606 assert( path ==
"/f1[1]" );
610 assert( path ==
"/" );
611 assert( f0 ==
Id() );
614 Id level6 = shell->
doCreate(
"Neutral",
Id(),
"foo", 1 );
615 Id level7 = shell->
doCreate(
"Neutral", level6,
"bar", 1 );
616 Id level8 = shell->
doCreate(
"Neutral", level7,
"zod", 1 );
618 shell->
doMove( level1, level8 );
620 ObjId noi(
"/foo/bar/zod/f1[1]/f2[0]/f3[3]/f4[0]/f5[5]" );
622 assert( noi.
id == level5 );
625 ObjId syn(
"/foo/bar/zod/f1[7]/synapse[5]" );
628 assert( syn.
id == origSynId );
634 cout <<
"." << flush;
696 if ( shell->
myNode() != 0 )
702 cout <<
"." << flush;
713 if ( shell->
myNode() == 0 ) {
714 unsigned int size = 6139;
715 child = shell->
doCreate(
"Neutral",
Id(),
"test", size );
721 cout <<
"." << flush;
728 const unsigned int size = 100;
729 vector< double > val;
735 for (
unsigned int i = 0; i < size; ++i ) {
736 val.push_back( i * i * i );
740 for (
unsigned int i = 0; i < size; ++i ) {
746 for (
unsigned int i = 0; i < size; ++i ) {
754 for (
unsigned int i = 0; i < size; ++i ) {
755 assert(
doubleEq( val[i], i * i * i ) );
759 cout <<
"." << flush;
763 double v0,
double v1,
double v2,
double v3,
double v4 )
767 Eref e0(
id.element(), 0 );
768 double val =
reinterpret_cast< Arith*
>( e0.
data() )->getArg1();
769 ret = ret && ( fabs( val - v0 ) < 1e-6 );
770 if (report) cout <<
"( " << v0 <<
", " << val <<
" ) ";
772 Eref e1(
id.element(), 1 );
773 val =
reinterpret_cast< Arith*
>( e1.
data() )->getArg1();
774 ret = ret && ( fabs( val - v1 ) < 1e-6 );
775 if (report) cout <<
"( " << v1 <<
", " << val <<
" ) ";
777 Eref e2(
id.element(), 2 );
778 val =
reinterpret_cast< Arith*
>( e2.
data() )->getArg1();
779 ret = ret && ( fabs( val - v2 ) < 1e-6 );
780 if (report) cout <<
"( " << v2 <<
", " << val <<
" ) ";
782 Eref e3(
id.element(), 3 );
783 val =
reinterpret_cast< Arith*
>( e3.
data() )->getArg1();
784 ret = ret && ( fabs( val - v3 ) < 1e-6 );
785 if (report) cout <<
"( " << v3 <<
", " << val <<
" ) ";
787 Eref e4(
id.element(), 4 );
788 val =
reinterpret_cast< Arith*
>( e4.
data() )->getArg1();
789 ret = ret && ( fabs( val - v4 ) < 1e-6 );
790 if (report) cout <<
"( " << v4 <<
", " << val <<
" )\n";
796 double v0,
double v1,
double v2,
double v3,
double v4 )
801 vector< double > correct;
802 correct.push_back( v0 );
803 correct.push_back( v1 );
804 correct.push_back( v2 );
805 correct.push_back( v3 );
806 correct.push_back( v4 );
808 vector< double > actual(5);
809 for (
unsigned int i = 0; i < 5; ++i ) {
811 ret = ret &&
doubleEq( actual[i], correct[i] );
813 if (report || !ret ) {
815 for (
unsigned int i = 0; i < 5; ++i )
816 cout <<
"(" << correct[i] <<
", " << actual[i] <<
") ";
840 unsigned int size = 5;
873 ObjId( a1, 3 ),
"output",
ObjId( a2, 1 ),
"arg3" );
874 assert( m1 !=
ObjId() );
878 ObjId( b1, 2 ),
"output",
ObjId( b2, 0 ),
"arg3" );
879 assert( m2 !=
ObjId() );
883 ObjId( c1, 0 ),
"output",
ObjId( c2, 0 ),
"arg3" );
884 assert( m3 !=
ObjId() );
888 ObjId( d1, 0 ),
"output",
ObjId( d2, 0 ),
"arg3" );
889 assert( m4 !=
ObjId() );
893 ObjId( e1, 0 ),
"output",
ObjId( e2, 0 ),
"arg3" );
894 assert( m5 !=
ObjId() );
897 m5,
"setEntry", 0, 4, 0 );
900 m5,
"setEntry", 1, 3, 0 );
903 m5,
"setEntry", 2, 2, 0 );
906 m5,
"setEntry", 3, 1, 0 );
909 m5,
"setEntry", 4, 0, 0 );
913 for (
unsigned int i = 0; i < 5; ++i ) {
915 ObjId( f1, i ),
"output",
ObjId( f2, i ),
"arg3" );
916 assert( m6 !=
ObjId() );
921 ObjId( g1, 0 ),
"output",
ObjId( g2, 0 ),
"arg3" );
922 assert( m7 !=
ObjId() );
923 for (
unsigned int i = 0; i < 5; ++i ) {
924 for (
unsigned int j = 0; j < 5; ++j ) {
927 m7,
"setEntry", i, j, 0 );
946 assert( numTgts == 0 );
948 shell->
doUseClock(
"a1,a2,b1,b2,c1,c2,d1,d2,e1,e2,f1,f2,g1,g2",
"process", 0 );
950 assert( numTgts == 14 );
958 vector< double >
init;
959 for (
unsigned int i = 1; i < 6; ++i )
997 for (
unsigned int i = 0; i < 5; ++i ) {
1005 vector< double > retVec( 0 );
1007 for (
unsigned int i = 0; i < 5; ++i )
1008 assert(
doubleEq( retVec[i], i + 1 ) );
1012 for (
unsigned int i = 0; i < 5; ++i )
1013 assert(
doubleEq( retVec[i], i + 1 ) );
1017 for (
unsigned int i = 0; i < 5; ++i )
1018 assert(
doubleEq( retVec[i], i + 1 ) );
1078 cout <<
"." << flush;
1088 unsigned int size = 5;
1115 vector< double >
init;
1116 for (
unsigned int i = 1; i < 6; ++i )
1117 init.push_back( i );
1135 ObjId( a1, 3 ),
"output",
ObjId( a2, 1 ),
"arg1" );
1136 assert( m1 !=
ObjId() );
1140 ObjId( b1, 2 ),
"output",
ObjId( b2, 0 ),
"arg1" );
1141 assert( m2 !=
ObjId() );
1145 ObjId( c1, 0 ),
"output",
ObjId( c2, 0 ),
"arg1" );
1146 assert( m3 !=
ObjId() );
1150 ObjId( d1, 0 ),
"output",
ObjId( d2, 0 ),
"arg1" );
1151 assert( m4 !=
ObjId() );
1155 ObjId( e1, 0 ),
"output",
ObjId( e2, 0 ),
"arg1" );
1156 assert( m5 !=
ObjId() );
1159 m5,
"setEntry", 0, 4, 0 );
1162 m5,
"setEntry", 1, 3, 0 );
1165 m5,
"setEntry", 2, 2, 0 );
1168 m5,
"setEntry", 3, 1, 0 );
1171 m5,
"setEntry", 4, 0, 0 );
1182 Id pa2 = shell->
doCopy( pa,
Id(),
"pa2", 1,
false,
false );
1188 assert ( kids.size() == 10 );
1192 assert( kids[j].element()->getName() ==
"a1" ); ++j;
1193 assert( kids[j].element()->getName() ==
"a2" ); ++j;
1194 assert( kids[j].element()->getName() ==
"b1" ); ++j;
1195 assert( kids[j].element()->getName() ==
"b2" ); ++j;
1196 assert( kids[j].element()->getName() ==
"c1" ); ++j;
1197 assert( kids[j].element()->getName() ==
"c2" ); ++j;
1198 assert( kids[j].element()->getName() ==
"d1" ); ++j;
1199 assert( kids[j].element()->getName() ==
"d2" ); ++j;
1200 assert( kids[j].element()->getName() ==
"e1" ); ++j;
1201 assert( kids[j].element()->getName() ==
"e2" ); ++j;
1209 for (
unsigned int i = 0; i < 5; ++i ) {
1243 cout <<
"." << flush;
1251 cout <<
"." << flush;
1291 assert( ret == 123 );
1293 cout <<
"." << flush;
1298 vector< string > args;
1301 assert( args.size() == 1 );
1302 assert( args[0] ==
"." );
1305 assert( args.size() == 0 );
1308 assert( args.size() == 1 );
1309 assert( args[0] ==
".." );
1312 assert( args.size() == 1 );
1313 assert( args[0] ==
"." );
1316 assert( args.size() == 2 );
1317 assert( args[0] ==
"." );
1318 assert( args[1] ==
"foo" );
1321 assert( args.size() == 1 );
1322 assert( args[0] ==
"foo" );
1325 assert( args.size() == 1 );
1326 assert( args[0] ==
"foo" );
1329 assert( args.size() == 1 );
1330 assert( args[0] ==
"foo" );
1333 assert( args.size() == 1 );
1334 assert( args[0] ==
"foo" );
1337 assert( args.size() == 3 );
1338 assert( args[0] ==
"foo" );
1339 assert( args[1] ==
"bar" );
1340 assert( args[2] ==
"zod" );
1342 cout <<
"." << flush;
1347 vector< string > args;
1348 vector< unsigned int > index;
1350 assert(
Shell::chopPath(
"foo[1]/bar[2]/zod[3]", args, index ) == 0 );
1351 assert( args.size() == 3 );
1352 assert( args[0] ==
"foo" );
1353 assert( args[1] ==
"bar" );
1354 assert( args[2] ==
"zod" );
1356 assert( index.size() == 3 );
1358 assert( index[0] == 1 );
1359 assert( index[1] == 2 );
1360 assert( index[2] == 3 );
1363 args, index ) == 1 );
1364 assert( args.size() == 4 );
1365 assert( args[0] ==
"foo" );
1366 assert( args[1] ==
"bar" );
1367 assert( args[2] ==
"zod" );
1368 assert( args[3] ==
"zung" );
1370 assert( index.size() == 4 );
1372 assert( index[0] == 0 );
1373 assert( index[1] == 1 );
1374 assert( index[2] == 2 );
1375 assert( index[3] == 3 );
1377 cout <<
"." << flush;
1383 Id& parentId,
string& modelName );
1393 Id foo2 = shell->
doCreate(
"Neutral", zod,
"foo", 1 );
1403 assert( parentId == zod );
1404 assert( modelName ==
"model" );
1409 assert( parentId ==
Id() );
1410 assert( modelName ==
"model" );
1415 assert( parentId ==
Id() );
1416 assert( modelName ==
"foo" );
1421 assert( parentId == zod );
1422 assert( modelName ==
"foo" );
1428 assert( parentId == zod );
1429 assert( modelName ==
"bar" );
1434 assert( parentId ==
Id() );
1435 assert( modelName ==
"bar" );
1440 assert( parentId == foo );
1441 assert( modelName ==
"bar" );
1446 assert( parentId == foo2 );
1447 assert( modelName ==
"bar" );
1452 cout <<
"." << flush;
1463 unsigned int size = 100;
1464 Id neuronId = shell->
doCreate(
"SimpleSynHandler",
Id(),
"handler", size );
1465 assert( neuronId !=
Id() );
1466 Id synId( neuronId.
value() + 1 );
1467 Element* syn = synId.element();
1470 assert ( syn != 0 );
1471 assert ( syn->getName() ==
"synapse" );
1473 assert( syn->numData() == size );
1474 vector< unsigned int > ns( size, 0 );
1475 for (
unsigned int i = 0; i < size; ++i )
1483 for (
unsigned int i = 0; i < size; ++i ) {
1484 ObjId oi( synId, i );
1491 for (
unsigned int j = 0; j < i; ++j ) {
1492 ObjId temp( synId, i, j );
1507 cout <<
"." << flush;
1522 unsigned int numData = 5;
1527 Id a1 = shell->
doCreate(
"Arith",
Id(),
"a1", numData );
1528 Id a2 = shell->
doCreate(
"Arith",
Id(),
"a2", numData );
1530 Id b1 = shell->
doCreate(
"Arith",
Id(),
"b1", numData );
1531 Id b2 = shell->
doCreate(
"Arith",
Id(),
"b2", numData );
1533 Id c1 = shell->
doCreate(
"Arith",
Id(),
"c1", numData );
1534 Id c2 = shell->
doCreate(
"Arith",
Id(),
"c2", numData );
1536 Id d1 = shell->
doCreate(
"Arith",
Id(),
"d1", numData );
1537 Id d2 = shell->
doCreate(
"Arith",
Id(),
"d2", numData );
1539 Id e1 = shell->
doCreate(
"Arith",
Id(),
"e1", numData );
1540 Id e2 = shell->
doCreate(
"Arith",
Id(),
"e2", numData );
1547 ObjId( a1, 3 ),
"output",
ObjId( a2, 1 ),
"arg3" );
1548 assert( m1 !=
ObjId() );
1552 ObjId( a1, 2 ),
"output",
ObjId( b2, 0 ),
"arg3" );
1553 assert( m2 !=
ObjId() );
1557 ObjId( a1, 0 ),
"output",
ObjId( c2, 0 ),
"arg3" );
1558 assert( m3 !=
ObjId() );
1562 ObjId( a1, 0 ),
"output",
ObjId( d2, 0 ),
"arg3" );
1563 assert( m4 !=
ObjId() );
1567 ObjId( a1, 0 ),
"output",
ObjId( e2, 0 ),
"arg3" );
1568 assert( m5 !=
ObjId() );
1645 vector< Id > srcIds;
1647 assert( srcIds.size() == 1 );
1648 assert( srcIds[0] == a1 );
1651 assert( srcIds.size() == 1 );
1652 assert( srcIds[0] == a1 );
1655 assert( srcIds.size() == 1 );
1656 assert( srcIds[0] == a1 );
1659 ObjId( b1, 3 ),
"output",
ObjId( b2, 1 ),
"arg3" );
1660 assert( m6 !=
ObjId() );
1663 assert( srcIds.size() == 2 );
1664 assert( srcIds[0] == a1 );
1665 assert( srcIds[1] == b1 );
1666 cout <<
"." << flush;
1671 vector< Id > destIds;
1673 assert( destIds.size() == 5 );
1674 assert( destIds[0] == a2 );
1675 assert( destIds[1] == b2 );
1676 assert( destIds[2] == c2 );
1677 assert( destIds[3] == d2 );
1678 assert( destIds[4] == e2 );
1679 destIds.resize( 0 );
1681 assert( destIds.size() == 1 );
1682 assert( destIds[0] == b2 );
1683 cout <<
"." << flush;
1713 vector< vector < Eref > >& erefs,
1714 vector< vector< bool > >& targetNodes );
1720 unsigned int numSrcData = 6;
1721 unsigned int numData = 6;
1723 vector< vector< Eref > > origErefs( numSrcData );
1725 vector< vector< bool > > origTargetNodes( numSrcData );
1728 Id neuronId = shell->
doCreate(
"IntFire",
Id(),
"neurons", numData,
1731 unsigned int numPerSrcNode = 1 + ( numSrcData - 1 ) /
Shell::numNodes();
1734 for (
unsigned int i = 0; i < numSrcData; ++i ) {
1736 for (
unsigned int j = 0; j < i && j < numData; ++j )
1737 origErefs[i].push_back(
Eref (elm, j ) );
1741 vector< vector< Eref > > erefs = origErefs;
1742 vector< vector< bool > > targetNodes = origTargetNodes;
1746 false,
myNode, erefs, targetNodes );
1747 for (
unsigned int i = 0; i < numSrcData; ++i ) {
1748 unsigned int sz = 0;
1750 if ( i > numPerSrcNode *
myNode ) {
1751 unsigned int j = i - numPerNode *
myNode;
1752 if ( j > numPerNode )
1757 assert( erefs[i].size() == sz );
1759 for (
unsigned int j = 0; j < erefs[i].size(); ++j )
1760 assert( erefs[i][j].getNode() ==
myNode );
1764 assert( targetNodes[i][j] ==
false );
1766 assert( targetNodes[i][j] == ( i > j * numPerNode ) );
1771 for (
unsigned int i = 0; i < numSrcData; ++i ) {
1772 origTargetNodes[i].clear();
1773 origTargetNodes[i].resize( Shell::numNodes(),
false );
1774 origErefs[i].clear();
1778 vector< vector< Eref > > erefs = origErefs;
1779 vector< vector< bool > > targetNodes = origTargetNodes;
1782 unsigned int start = numPerSrcNode *
myNode;
1783 unsigned int end = start + 1+ (numSrcData-1) % numPerSrcNode;
1786 false, myNode, erefs, targetNodes );
1787 for (
unsigned int i = 0; i < numData; ++i ) {
1792 assert( erefs[i].size() == ( myNode == 0 ) );
1794 for (
unsigned int j = 0; j < erefs[i].size(); ++j )
1795 assert( erefs[i][j].getNode() ==
myNode );
1802 if ( i / numPerNode == myNode && j != myNode )
1803 assert( targetNodes[i][j] ==
true );
1805 assert( targetNodes[i][j] ==
false );
1811 cout <<
"." << flush;
1855 cout <<
"." << flush;
Id init(int argc, char **argv, bool &doUnitTests, bool &doRegressionTests, unsigned int &benchmark)
void doStart(double runtime, bool notify=false)
bool checkArg1(Id id, double v0, double v1, double v2, double v3, double v4)
bool findModelParent(Id cwe, const string &path, Id &parentId, string &modelName)
static ObjId parent(const Eref &e)
static bool chopString(const string &path, vector< string > &ret, char separator= '/')
ObjId getParent(const Eref &e) const
void testShellParserStart()
bool checkOutput(Id e, double v0, double v1, double v2, double v3, double v4)
void testFindModelParent()
Element * element() const
Synonym for Id::operator()()
void doSetClock(unsigned int tickNum, double dt)
std::string path(const std::string &separator="/") const
unsigned int value() const
void testChildren()
Test the Neutral::children and buildTree.
static const Cinfo * initCinfo()
static bool setRepeat(ObjId destId, const string &field, A arg)
void testShellParserCreateDelete()
bool extractIndex(const string &s, unsigned int &index)
void testShellParserQuit()
static const Cinfo * find(const std::string &name)
Id doCopy(Id orig, ObjId newParent, string newName, unsigned int n, bool toGlobal, bool copyExtMsgs)
Returns the Id of the root of the copied tree upon success.
static Id child(const Eref &e, const string &name)
static void children(const Eref &e, vector< Id > &ret)
Element * element() const
static bool set(const ObjId &dest, const string &field, A arg)
void testExtractIndices()
unsigned int buildTree(const Eref &e, vector< Id > &tree) const
ObjId doFind(const string &path) const
void testGetMsgSrcAndTarget()
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
const unsigned int ALLDATA
Used by ObjId and Eref.
vector< Id > getChildren(const Eref &e) const
bool doubleEq(double x, double y)
void verifyKids(Id f1, Id f2a, Id f2b, Id f3, Id f4a, Id f4b)
Utility function to check a commonly used tree structure.
static unsigned int myNode
static bool isDescendant(Id me, Id ancestor)
void testCopyFieldElement()
void filterOffNodeTargets(unsigned int start, unsigned int end, bool isSrcGlobal, unsigned int myNode, vector< vector< Eref > > &erefs, vector< vector< bool > > &targetNodes)
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
void testFilterOffNodeTargets()
virtual unsigned int numData() const =0
Returns number of data entries across all nodes.
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
Element * element() const
void testObjIdToAndFromPath()
void testSyncSynapseSize()
static bool chopPath(const string &path, vector< string > &ret, vector< unsigned int > &index)
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
static bool set(const ObjId &dest, const string &field, A arg)
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3)
unsigned int getNeighbors(vector< Id > &ret, const Finfo *finfo) const
static unsigned int myNode()
void doUseClock(string path, string field, unsigned int tick)
void testDescendant()
Test the Neutral::isDescendant.
static A get(const ObjId &dest, const string &field)
static unsigned int numNodes()
static void getVec(ObjId dest, const string &field, vector< A > &vec)
const string & getName() const
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
const Finfo * findFinfo(const string &name) const
void doMove(Id orig, ObjId newParent)