Changeset 7


Ignore:
Timestamp:
05/22/09 21:56:05 (15 years ago)
Author:
mwajcht
Message:
  1. Fixed bug in converter.
  2. Genotypes with resulting F1 genotype longer than 1500 characters will not be converted.
  3. Simplified choosing different condition.
Location:
cpp/f8-to-f1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpp/f8-to-f1/conv_f8tof1.cpp

    r1 r7  
    601601                int position = firstProduction->parameters.getParameterPosition(stringToSString(iter->first));
    602602                //cout << "position of " << iter->first << ": " << position << endl;
    603                 //params.insert(params.begin() + (position - 1), iter->second);
    604                 params[position - 1] = iter->second;
     603                params.insert(params.begin() + (position - 1), iter->second);
     604                //params[position - 1] = iter->second;
    605605        }
    606606       
     
    646646                if (a != NULL) {
    647647                        dst += a->getF1Genotype(p);
     648                        if (dst.len() > 1500) {
     649                                return ""; //genotype becomes too long so we abort conversion
     650                        }
    648651                }
    649652        }
  • cpp/f8-to-f1/conv_f8tof1_grammar.c

    r1 r7  
    135135*/
    136136static const YYACTIONTYPE yy_action[] = {
    137  /*     0 */    40,    4,   23,   24,   25,   26,   27,   28,   64,   67,
    138  /*    10 */    31,   71,   44,   55,    4,   41,   34,   82,   75,   64,
    139  /*    20 */    65,   68,   70,   31,   65,   44,   84,    4,   41,   34,
    140  /*    30 */    82,   75,   64,   65,   68,   70,   69,   65,   44,   20,
    141  /*    40 */    60,    4,   61,   56,    4,   47,    8,   68,   70,   46,
    142  /*    50 */    69,   32,   44,   69,   49,   44,   59,   57,    4,   47,
    143  /*    60 */    42,   68,   70,   85,   68,   70,   38,   69,   76,   44,
    144  /*    70 */    10,   45,   39,   77,   58,   15,   14,    5,   68,   70,
    145  /*    80 */    65,   71,   72,   73,   12,   13,   15,   14,   60,    9,
    146  /*    90 */    61,   91,   78,    6,   60,   48,   61,   53,    1,   33,
    147  /*   100 */    35,   10,   45,   39,   79,   33,   66,   80,   12,   13,
    148  /*   110 */    15,   14,  139,   16,   60,   60,   61,   61,   52,   60,
    149  /*   120 */    60,   61,   61,   81,   17,   36,   37,   54,   22,   51,
    150  /*   130 */    62,   63,   30,   18,   50,    3,    2,   43,   74,   11,
    151  /*   140 */    75,   88,    7,   19,   21,   83,   18,   50,   86,   29,
    152  /*   150 */    87,   89,   90,
     137 /*     0 */    46,    4,   23,   24,   26,   27,   22,   28,   85,   61,
     138 /*    10 */    31,   62,   43,   56,    4,   40,   37,   83,   76,   66,
     139 /*    20 */    63,   69,   71,   31,   72,   43,    9,    4,   40,   37,
     140 /*    30 */    83,   76,   47,    4,   69,   71,   70,   14,   43,  139,
     141 /*    40 */    17,    4,   70,   59,   43,   51,   66,   69,   71,   57,
     142 /*    50 */    70,   52,   43,   69,   71,   38,    4,   58,   15,   11,
     143 /*    60 */    84,   69,   71,   19,   61,   70,   62,   43,   12,   13,
     144 /*    70 */    15,   11,   44,   89,   30,   34,   69,   71,   16,   48,
     145 /*    80 */    75,    5,   76,   91,   66,   72,   73,   74,   12,   13,
     146 /*    90 */    15,   11,   61,   20,   62,   65,   66,    6,    1,    2,
     147 /*   100 */    65,    7,   42,   33,   35,   54,   10,   39,   41,   10,
     148 /*   110 */    39,   41,   61,   49,   62,   68,   61,   61,   62,   62,
     149 /*   120 */    61,   88,   62,   33,   67,   65,   66,   36,   32,   25,
     150 /*   130 */     8,   64,   52,   18,   16,   48,   86,   55,   29,   53,
     151 /*   140 */    60,   87,   90,   81,    3,   77,   78,   45,   21,   79,
     152 /*   150 */   140,  140,   80,   82,   50,
    153153};
    154154static const YYCODETYPE yy_lookahead[] = {
    155  /*     0 */    27,   28,   13,   14,   15,   16,   17,   18,   21,   11,
    156  /*    10 */    37,   23,   39,   27,   28,   42,   43,   44,   45,   21,
    157  /*    20 */    22,   48,   49,   37,   22,   39,   11,   28,   42,   43,
    158  /*    30 */    44,   45,   21,   22,   48,   49,   37,   22,   39,   32,
    159  /*    40 */    35,   28,   37,   44,   28,   37,    1,   48,   49,   41,
    160  /*    50 */    37,   46,   39,   37,    7,   39,   11,   44,   28,   37,
    161  /*    60 */    44,   48,   49,   41,   48,   49,   34,   37,   35,   39,
    162  /*    70 */    38,   39,   40,   35,   44,    4,    5,   19,   48,   49,
    163  /*    80 */    22,   23,   24,   25,    2,    3,    4,    5,   35,   33,
    164  /*    90 */    37,    0,   35,   11,   35,   39,   37,   34,    9,   46,
    165  /*   100 */    47,   38,   39,   40,   35,   46,   47,   35,    2,    3,
    166  /*   110 */     4,    5,   29,   30,   35,   35,   37,   37,   35,   35,
    167  /*   120 */    35,   37,   37,   35,    1,   46,   46,    6,   31,   35,
    168  /*   130 */    46,   46,   37,   36,   37,   12,    9,   20,   43,   10,
    169  /*   140 */    45,   31,   10,   10,    1,   11,   36,   37,    6,    8,
    170  /*   150 */     6,    6,    6,
     155 /*     0 */    27,   28,   13,   14,   15,   16,   17,   18,   11,   35,
     156 /*    10 */    37,   37,   39,   27,   28,   42,   43,   44,   45,   22,
     157 /*    20 */    46,   48,   49,   37,   23,   39,   33,   28,   42,   43,
     158 /*    30 */    44,   45,   39,   28,   48,   49,   37,   10,   39,   29,
     159 /*    40 */    30,   28,   37,   44,   39,   35,   22,   48,   49,   44,
     160 /*    50 */    37,   37,   39,   48,   49,   41,   28,   44,    4,    5,
     161 /*    60 */    11,   48,   49,   10,   35,   37,   37,   39,    2,    3,
     162 /*    70 */     4,    5,   44,   31,   37,   46,   48,   49,   36,   37,
     163 /*    80 */    43,   19,   45,    0,   22,   23,   24,   25,    2,    3,
     164 /*    90 */     4,    5,   35,    1,   37,   21,   22,   11,    9,    9,
     165 /*   100 */    21,   10,   34,   46,   47,   34,   38,   39,   40,   38,
     166 /*   110 */    39,   40,   35,   20,   37,   11,   35,   35,   37,   37,
     167 /*   120 */    35,    6,   37,   46,   47,   21,   22,   46,   46,   31,
     168 /*   130 */     1,   46,   37,    1,   36,   37,   41,    6,    8,    6,
     169 /*   140 */    11,    6,    6,   35,   12,   35,   35,    7,   32,   35,
     170 /*   150 */    50,   50,   35,   35,   35,
    171171};
    172 #define YY_SHIFT_USE_DFLT (-14)
     172#define YY_SHIFT_USE_DFLT (-12)
    173173#define YY_SHIFT_MAX 52
    174174static const short yy_shift_ofst[] = {
    175  /*     0 */   -13,   58,   58,   58,   58,   58,   58,   -2,   11,  -12,
    176  /*    10 */   -12,   11,   11,   11,   11,   11,    2,    2,    2,   15,
    177  /*    20 */   -12,    2,   47,  -13,  -13,  -13,  -13,  -13,  -13,  -13,
    178  /*    30 */   -11,  -11,   82,  106,  123,   45,   71,   71,   91,   89,
    179  /*    40 */   121,  127,  117,  129,  132,  133,  134,  143,  142,  144,
    180  /*    50 */   141,  145,  146,
     175 /*     0 */    79,   62,   62,   62,   62,   62,   62,  104,   74,    1,
     176 /*    10 */     1,   74,   74,   74,   74,   74,   24,   24,   24,   -3,
     177 /*    20 */    24,    1,   79,   79,   79,  140,   79,   79,   79,   79,
     178 /*    30 */   -11,  -11,   86,   66,   54,  129,   54,  132,   49,   53,
     179 /*    40 */    89,   90,   83,   91,   93,  115,  131,  135,  130,   27,
     180 /*    50 */   136,  133,   92,
    181181};
    182182#define YY_REDUCE_USE_DFLT (-28)
    183183#define YY_REDUCE_MAX 29
    184184static const signed char yy_reduce_ofst[] = {
    185  /*     0 */    83,  -27,  -14,   -1,   13,   16,   30,   53,   59,   32,
    186  /*    10 */    63,    5,   79,   80,   84,   85,   97,   95,  110,    8,
    187  /*    20 */    56,   22,    7,   33,   38,   57,   69,   72,   88,   94,
     185 /*     0 */    10,  -14,  -27,    5,   13,   28,   -1,   57,   77,   68,
     186 /*    10 */    71,  -26,   29,   81,   82,   85,   42,   98,   37,   14,
     187 /*    20 */    95,   -7,  108,  110,  111,  116,  114,  117,  118,  119,
    188188};
    189189static const YYACTIONTYPE yy_default[] = {
    190190 /*     0 */   138,  117,  117,  117,  117,  117,  117,  138,  138,   98,
    191  /*    10 */    98,  138,  138,  138,  138,  138,   95,  138,   95,  138,
     191 /*    10 */    98,  138,  138,  138,  138,  138,   95,   95,  138,  138,
    192192 /*    20 */   138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
    193  /*    30 */   138,  123,  138,  125,  138,  138,  129,  130,  138,  138,
    194  /*    40 */   138,  106,  138,  138,  138,  138,  138,  104,  138,  138,
    195  /*    50 */   138,  138,  138,   97,  100,  105,  107,  118,  119,  120,
    196  /*    60 */   127,  128,  131,  132,  133,  134,  126,  121,  122,  123,
    197  /*    70 */   124,  135,  136,  137,  109,  110,  111,  112,  113,  114,
    198  /*    80 */   115,  116,  108,  101,  102,  103,   99,   93,   94,   96,
    199  /*    90 */    92,
     193 /*    30 */   138,  123,  138,  125,  129,  138,  130,  138,  138,  138,
     194 /*    40 */   106,  138,  138,  138,  138,  138,  138,  138,  138,  138,
     195 /*    50 */   138,  138,  104,   92,   97,  100,  105,  107,  118,  119,
     196 /*    60 */   120,  127,  128,  131,  132,  133,  134,  126,  121,  122,
     197 /*    70 */   123,  124,  135,  136,  137,  109,  110,  111,  112,  113,
     198 /*    80 */   114,  115,  116,  108,  101,  102,  103,   99,   93,   94,
     199 /*    90 */    96,
    200200};
    201201#define YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0]))
     
    11841184#endif
    11851185                }
    1186                
    11871186                delete yymsp[-1].minor.yy89.actions;
    11881187                delete yymsp[-1].minor.yy89.parameters;
    11891188        }
    11901189}
    1191 #line 1193 "conv_f8tof1_grammar.c"
     1190#line 1192 "conv_f8tof1_grammar.c"
    11921191        break;
    11931192      case 28: /* real_prod ::= FORLOOP_BEGIN real_prod FORLOOP_END LPAREN single_val RPAREN real_prod */
    1194 #line 394 "conv_f8tof1_grammar.y"
     1193#line 393 "conv_f8tof1_grammar.y"
    11951194{
    11961195        if (!syntaxOnly) {
     
    12241223        }
    12251224}
    1226 #line 1228 "conv_f8tof1_grammar.c"
     1225#line 1227 "conv_f8tof1_grammar.c"
    12271226        break;
    12281227      case 29: /* prod_piece ::= prod_name LPAREN multiple_val RPAREN */
    1229 #line 426 "conv_f8tof1_grammar.y"
     1228#line 425 "conv_f8tof1_grammar.y"
    12301229{
    12311230        if (!syntaxOnly) {
     
    12451244        }
    12461245}
    1247 #line 1249 "conv_f8tof1_grammar.c"
     1246#line 1248 "conv_f8tof1_grammar.c"
    12481247        break;
    12491248      case 30: /* prod_piece ::= prod_name LPAREN RPAREN */
    1250 #line 443 "conv_f8tof1_grammar.y"
     1249#line 442 "conv_f8tof1_grammar.y"
    12511250{
    12521251        if (!syntaxOnly) {
     
    12571256                }
    12581257                yygotominor.yy89.actions = new vector<Action*>();
     1258                vector<SString> param;
    12591259                yygotominor.yy89.parameters = new vector<vector<SString> >();
     1260                yygotominor.yy89.parameters->push_back(param);
    12601261               
    12611262                Production *p = lsys->productions.find(sstringToString(*(yymsp[-2].minor.yy78.strValue)))->second;
     
    12641265        }
    12651266}
    1266 #line 1268 "conv_f8tof1_grammar.c"
     1267#line 1269 "conv_f8tof1_grammar.c"
    12671268        break;
    12681269      case 31: /* prod_piece ::= command */
    1269 #line 458 "conv_f8tof1_grammar.y"
     1270#line 459 "conv_f8tof1_grammar.y"
    12701271{
    12711272        if (!syntaxOnly) {
     
    12841285        }
    12851286}
    1286 #line 1288 "conv_f8tof1_grammar.c"
     1287#line 1289 "conv_f8tof1_grammar.c"
    12871288        break;
    12881289      case 32: /* prod_piece ::= param_name */
    1289 #line 474 "conv_f8tof1_grammar.y"
     1290#line 475 "conv_f8tof1_grammar.y"
    12901291{
    12911292        if (!syntaxOnly) {
     
    13051306        }
    13061307}
    1307 #line 1309 "conv_f8tof1_grammar.c"
     1308#line 1310 "conv_f8tof1_grammar.c"
    13081309        break;
    13091310      case 33: /* prod_piece ::= neuron */
    1310 #line 491 "conv_f8tof1_grammar.y"
     1311#line 492 "conv_f8tof1_grammar.y"
    13111312{
    13121313        if (!syntaxOnly) {
     
    13261327        }
    13271328}
    1328 #line 1330 "conv_f8tof1_grammar.c"
     1329#line 1331 "conv_f8tof1_grammar.c"
    13291330        break;
    13301331      case 34: /* multiple_val ::= single_val */
    1331 #line 509 "conv_f8tof1_grammar.y"
     1332#line 510 "conv_f8tof1_grammar.y"
    13321333{
    13331334        if (!syntaxOnly) {
     
    13421343        }
    13431344}
    1344 #line 1346 "conv_f8tof1_grammar.c"
     1345#line 1347 "conv_f8tof1_grammar.c"
    13451346        break;
    13461347      case 35: /* multiple_val ::= multiple_val COMMA multiple_val */
    1347 #line 521 "conv_f8tof1_grammar.y"
     1348#line 522 "conv_f8tof1_grammar.y"
    13481349{
    13491350        if (!syntaxOnly) {
     
    13641365        }
    13651366}
    1366 #line 1368 "conv_f8tof1_grammar.c"
     1367#line 1369 "conv_f8tof1_grammar.c"
    13671368        break;
    13681369      case 36: /* single_val ::= double_val */
    1369 #line 540 "conv_f8tof1_grammar.y"
     1370#line 541 "conv_f8tof1_grammar.y"
    13701371{
    13711372        if (!syntaxOnly) {
     
    13791380        }
    13801381}
    1381 #line 1383 "conv_f8tof1_grammar.c"
     1382#line 1384 "conv_f8tof1_grammar.c"
    13821383        break;
    13831384      case 37: /* single_val ::= param_name */
    1384 #line 551 "conv_f8tof1_grammar.y"
     1385#line 552 "conv_f8tof1_grammar.y"
    13851386{
    13861387        if (!syntaxOnly) {
     
    13941395        }
    13951396}
    1396 #line 1398 "conv_f8tof1_grammar.c"
     1397#line 1399 "conv_f8tof1_grammar.c"
    13971398        break;
    13981399      case 38: /* single_val ::= single_val PLUS single_val */
    1399 #line 562 "conv_f8tof1_grammar.y"
     1400#line 563 "conv_f8tof1_grammar.y"
    14001401{
    14011402        if (!syntaxOnly) {
     
    14101411        }
    14111412}
    1412 #line 1414 "conv_f8tof1_grammar.c"
     1413#line 1415 "conv_f8tof1_grammar.c"
    14131414        break;
    14141415      case 39: /* single_val ::= single_val MINUS single_val */
    1415 #line 574 "conv_f8tof1_grammar.y"
     1416#line 575 "conv_f8tof1_grammar.y"
    14161417{
    14171418        if (!syntaxOnly) {
     
    14261427        }
    14271428}
    1428 #line 1430 "conv_f8tof1_grammar.c"
     1429#line 1431 "conv_f8tof1_grammar.c"
    14291430        break;
    14301431      case 40: /* single_val ::= single_val TIMES single_val */
    1431 #line 586 "conv_f8tof1_grammar.y"
     1432#line 587 "conv_f8tof1_grammar.y"
    14321433{
    14331434        if (!syntaxOnly) {
     
    14421443        }
    14431444}
    1444 #line 1446 "conv_f8tof1_grammar.c"
     1445#line 1447 "conv_f8tof1_grammar.c"
    14451446        break;
    14461447      case 41: /* single_val ::= single_val DIV single_val */
    1447 #line 598 "conv_f8tof1_grammar.y"
     1448#line 599 "conv_f8tof1_grammar.y"
    14481449{
    14491450        if (!syntaxOnly) {
     
    14581459        }
    14591460}
    1460 #line 1462 "conv_f8tof1_grammar.c"
     1461#line 1463 "conv_f8tof1_grammar.c"
    14611462        break;
    14621463      case 42: /* double_val ::= DOUBLE_VAL */
    1463 #line 611 "conv_f8tof1_grammar.y"
     1464#line 612 "conv_f8tof1_grammar.y"
    14641465{
    14651466        if (!syntaxOnly) {
     
    14721473        }
    14731474}
    1474 #line 1476 "conv_f8tof1_grammar.c"
     1475#line 1477 "conv_f8tof1_grammar.c"
    14751476        break;
    14761477      case 43: /* param_name ::= PARAM_NAME */
    1477 #line 621 "conv_f8tof1_grammar.y"
     1478#line 622 "conv_f8tof1_grammar.y"
    14781479{
    14791480        if (!syntaxOnly) {
     
    14861487        }
    14871488}
    1488 #line 1490 "conv_f8tof1_grammar.c"
     1489#line 1491 "conv_f8tof1_grammar.c"
    14891490        break;
    14901491      case 44: /* prod_name ::= PROD_NAME */
    1491 #line 631 "conv_f8tof1_grammar.y"
     1492#line 632 "conv_f8tof1_grammar.y"
    14921493{
    14931494        if (!syntaxOnly) {
     
    15001501        }
    15011502}
    1502 #line 1504 "conv_f8tof1_grammar.c"
     1503#line 1505 "conv_f8tof1_grammar.c"
    15031504        break;
    15041505      case 45: /* command ::= COMMAND */
    1505 #line 641 "conv_f8tof1_grammar.y"
     1506#line 642 "conv_f8tof1_grammar.y"
    15061507{
    15071508        if (!syntaxOnly) {
     
    15141515        }
    15151516}
    1516 #line 1518 "conv_f8tof1_grammar.c"
     1517#line 1519 "conv_f8tof1_grammar.c"
    15171518        break;
    15181519      case 46: /* neuron ::= NEURON */
    1519 #line 651 "conv_f8tof1_grammar.y"
     1520#line 652 "conv_f8tof1_grammar.y"
    15201521{
    15211522        if (!syntaxOnly) {
     
    15281529        }
    15291530}
    1530 #line 1532 "conv_f8tof1_grammar.c"
     1531#line 1533 "conv_f8tof1_grammar.c"
    15311532        break;
    15321533  };
  • cpp/f8-to-f1/geno_f8.cpp

    r6 r7  
    11991199
    12001200RelationType Geno_f8::getDifferentCondition(RelationType type) {
    1201         RelationType types[5];
     1201        RelationType types[6];
     1202        types[0] = r_greater;
     1203        types[1] = r_greaterEqual;
     1204        types[2] = r_equal;
     1205        types[3] = r_different;
     1206        types[4] = r_lessEqual;
     1207        types[5] = r_less;
     1208       
     1209        for (int i = 0; i < 6; i++) {
     1210                if (types[i] == type) {
     1211                        types[i] = types[5];
     1212                        types[5] = type;
     1213                        break;
     1214                }
     1215        }
     1216       
    12021217        int randomType = randomN(5);
    1203         if (type == r_greater) {
    1204                 types[0] = r_greaterEqual;
    1205                 types[1] = r_equal;
    1206                 types[2] = r_different;
    1207                 types[3] = r_lessEqual;
    1208                 types[4] = r_less;
    1209         } else if (type == r_greaterEqual) {
    1210                 types[0] = r_greater;
    1211                 types[1] = r_equal;
    1212                 types[2] = r_different;
    1213                 types[3] = r_lessEqual;
    1214                 types[4] = r_less;
    1215         } else if (type == r_equal) {
    1216                 types[0] = r_greater;
    1217                 types[1] = r_greaterEqual;
    1218                 types[2] = r_different;
    1219                 types[3] = r_lessEqual;
    1220                 types[4] = r_less;
    1221         } else if (type == r_different) {
    1222                 types[0] = r_greater;
    1223                 types[1] = r_greaterEqual;
    1224                 types[2] = r_equal;
    1225                 types[3] = r_lessEqual;
    1226                 types[4] = r_less;
    1227         } else if (type == r_lessEqual) {
    1228                 types[0] = r_greater;
    1229                 types[1] = r_greaterEqual;
    1230                 types[2] = r_equal;
    1231                 types[3] = r_different;
    1232                 types[4] = r_less;
    1233         } else if (type == r_less) {
    1234                 types[0] = r_greater;
    1235                 types[1] = r_greaterEqual;
    1236                 types[2] = r_equal;
    1237                 types[3] = r_different;
    1238                 types[4] = r_lessEqual;
    1239         }
    12401218        return types[randomType];
    12411219}
Note: See TracChangeset for help on using the changeset viewer.