00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #define _CRSTRTGY_SOURCE_
00037
00038 #include <stdio.h>
00039 #define _STDIO_INCLUDED_
00040 #include <string.h>
00041
00042 #include "setup.h"
00043
00044 #if DEFRULE_CONSTRUCT
00045
00046 #include "constant.h"
00047 #include "pattern.h"
00048 #include "reteutil.h"
00049 #include "argacces.h"
00050 #include "agenda.h"
00051 #include "envrnmnt.h"
00052 #include "memalloc.h"
00053
00054 #include "crstrtgy.h"
00055
00056 #define GetMatchingItem(x,i) ((x->basis->binds[i].gm.theMatch != NULL) ? \
00057 (x->basis->binds[i].gm.theMatch->matchingItem) : NULL)
00058
00059
00060
00061
00062
00063 static ACTIVATION *PlaceDepthActivation(ACTIVATION *,struct salienceGroup *);
00064 static ACTIVATION *PlaceBreadthActivation(ACTIVATION *,struct salienceGroup *);
00065 static ACTIVATION *PlaceLEXActivation(void *,ACTIVATION *,struct salienceGroup *);
00066 static ACTIVATION *PlaceMEAActivation(void *,ACTIVATION *,struct salienceGroup *);
00067 static ACTIVATION *PlaceComplexityActivation(ACTIVATION *,struct salienceGroup *);
00068 static ACTIVATION *PlaceSimplicityActivation(ACTIVATION *,struct salienceGroup *);
00069 static ACTIVATION *PlaceRandomActivation(ACTIVATION *,struct salienceGroup *);
00070 static int ComparePartialMatches(void *,ACTIVATION *,ACTIVATION *);
00071 static char *GetStrategyName(int);
00072 static unsigned long long *SortPartialMatch(void *,struct partialMatch *);
00073
00074
00075
00076
00077
00078 globle void PlaceActivation(
00079 void *theEnv,
00080 ACTIVATION **whichAgenda,
00081 ACTIVATION *newActivation,
00082 struct salienceGroup *theGroup)
00083 {
00084 ACTIVATION *placeAfter = NULL;
00085
00086
00087
00088
00089
00090
00091 EnvSetAgendaChanged(theEnv,TRUE);
00092
00093
00094
00095
00096
00097
00098
00099 if (*whichAgenda != NULL)
00100 {
00101 switch (AgendaData(theEnv)->Strategy)
00102 {
00103 case DEPTH_STRATEGY:
00104 placeAfter = PlaceDepthActivation(newActivation,theGroup);
00105 break;
00106
00107 case BREADTH_STRATEGY:
00108 placeAfter = PlaceBreadthActivation(newActivation,theGroup);
00109 break;
00110
00111 case LEX_STRATEGY:
00112 placeAfter = PlaceLEXActivation(theEnv,newActivation,theGroup);
00113 break;
00114
00115 case MEA_STRATEGY:
00116 placeAfter = PlaceMEAActivation(theEnv,newActivation,theGroup);
00117 break;
00118
00119 case COMPLEXITY_STRATEGY:
00120 placeAfter = PlaceComplexityActivation(newActivation,theGroup);
00121 break;
00122
00123 case SIMPLICITY_STRATEGY:
00124 placeAfter = PlaceSimplicityActivation(newActivation,theGroup);
00125 break;
00126
00127 case RANDOM_STRATEGY:
00128 placeAfter = PlaceRandomActivation(newActivation,theGroup);
00129 break;
00130 }
00131 }
00132 else
00133 {
00134 theGroup->first = newActivation;
00135 theGroup->last = newActivation;
00136 }
00137
00138
00139
00140
00141
00142 if (placeAfter == NULL)
00143 {
00144 newActivation->next = *whichAgenda;
00145 *whichAgenda = newActivation;
00146 if (newActivation->next != NULL) newActivation->next->prev = newActivation;
00147 }
00148 else
00149 {
00150 newActivation->next = placeAfter->next;
00151 newActivation->prev = placeAfter;
00152 placeAfter->next = newActivation;
00153 if (newActivation->next != NULL)
00154 { newActivation->next->prev = newActivation; }
00155 }
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165 static ACTIVATION *PlaceDepthActivation(
00166 ACTIVATION *newActivation,
00167 struct salienceGroup *theGroup)
00168 {
00169 ACTIVATION *lastAct, *actPtr;
00170 unsigned long long timetag;
00171
00172
00173
00174
00175
00176 timetag = newActivation->timetag;
00177 if (theGroup->prev == NULL)
00178 { lastAct = NULL; }
00179 else
00180 { lastAct = theGroup->prev->last; }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 actPtr = theGroup->first;
00192 while (actPtr != NULL)
00193 {
00194 if (timetag < actPtr->timetag)
00195 {
00196 lastAct = actPtr;
00197 if (actPtr == theGroup->last)
00198 { break; }
00199 else
00200 { actPtr = actPtr->next; }
00201 }
00202 else
00203 { break; }
00204 }
00205
00206
00207
00208
00209
00210 if ((lastAct == NULL) ||
00211 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00212 { theGroup->first = newActivation; }
00213
00214 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00215 { theGroup->last = newActivation; }
00216
00217
00218
00219
00220
00221 return(lastAct);
00222 }
00223
00224
00225
00226
00227
00228
00229
00230
00231 static ACTIVATION *PlaceBreadthActivation(
00232 ACTIVATION *newActivation,
00233 struct salienceGroup *theGroup)
00234 {
00235 unsigned long long timetag;
00236 ACTIVATION *lastAct, *actPtr;
00237
00238
00239
00240
00241
00242 timetag = newActivation->timetag;
00243 if (theGroup->last == NULL)
00244 {
00245 if (theGroup->prev == NULL)
00246 { lastAct = NULL; }
00247 else
00248 { lastAct = theGroup->prev->last; }
00249 }
00250 else
00251 { lastAct = theGroup->last; }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 actPtr = theGroup->last;
00263 while (actPtr != NULL)
00264 {
00265 if (timetag < actPtr->timetag)
00266 {
00267 if (actPtr == theGroup->first)
00268 {
00269 if (theGroup->prev == NULL)
00270 { lastAct = NULL; }
00271 else
00272 { lastAct = theGroup->prev->last; }
00273 break;
00274 }
00275 else
00276 { actPtr = actPtr->prev; }
00277 }
00278 else
00279 {
00280 lastAct = actPtr;
00281 break;
00282 }
00283 }
00284
00285
00286
00287
00288
00289 if ((lastAct == NULL) ||
00290 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00291 { theGroup->first = newActivation; }
00292
00293 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00294 { theGroup->last = newActivation; }
00295
00296
00297
00298
00299
00300 return(lastAct);
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310 static ACTIVATION *PlaceLEXActivation(
00311 void *theEnv,
00312 ACTIVATION *newActivation,
00313 struct salienceGroup *theGroup)
00314 {
00315 unsigned long long timetag;
00316 ACTIVATION *lastAct, *actPtr;
00317 int flag;
00318
00319
00320
00321
00322
00323 timetag = newActivation->timetag;
00324 if (theGroup->prev == NULL)
00325 { lastAct = NULL; }
00326 else
00327 { lastAct = theGroup->prev->last; }
00328
00329
00330
00331
00332
00333
00334 actPtr = theGroup->last;
00335 if (actPtr != NULL)
00336 {
00337 flag = ComparePartialMatches(theEnv,actPtr,newActivation);
00338
00339 if ((flag == LESS_THAN) ||
00340 ((flag == EQUAL) && (timetag > actPtr->timetag)))
00341 {
00342 theGroup->last = newActivation;
00343
00344 return(actPtr);
00345 }
00346 }
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 actPtr = theGroup->first;
00357 while (actPtr != NULL)
00358 {
00359 flag = ComparePartialMatches(theEnv,actPtr,newActivation);
00360
00361 if (flag == LESS_THAN)
00362 {
00363 lastAct = actPtr;
00364 if (actPtr == theGroup->last)
00365 { break; }
00366 else
00367 { actPtr = actPtr->next; }
00368 }
00369 else if (flag == GREATER_THAN)
00370 { break; }
00371 else
00372 {
00373 if (timetag > actPtr->timetag)
00374 {
00375 lastAct = actPtr;
00376 if (actPtr == theGroup->last)
00377 { break; }
00378 else
00379 { actPtr = actPtr->next; }
00380 }
00381 else
00382 { break; }
00383 }
00384 }
00385
00386
00387
00388
00389
00390 if ((lastAct == NULL) ||
00391 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00392 { theGroup->first = newActivation; }
00393
00394 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00395 { theGroup->last = newActivation; }
00396
00397
00398
00399
00400
00401 return(lastAct);
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411 static ACTIVATION *PlaceMEAActivation(
00412 void *theEnv,
00413 ACTIVATION *newActivation,
00414 struct salienceGroup *theGroup)
00415 {
00416 unsigned long long timetag;
00417 ACTIVATION *lastAct, *actPtr;
00418 int flag;
00419 long long cWhoset = 0, oWhoset = 0;
00420 intBool cSet, oSet;
00421
00422
00423
00424
00425
00426 timetag = newActivation->timetag;
00427 if (theGroup->prev == NULL)
00428 { lastAct = NULL; }
00429 else
00430 { lastAct = theGroup->prev->last; }
00431
00432
00433
00434
00435
00436
00437 actPtr = theGroup->last;
00438 if (actPtr != NULL)
00439 {
00440 if (GetMatchingItem(newActivation,0) != NULL)
00441 {
00442 cWhoset = GetMatchingItem(newActivation,0)->timeTag;
00443 cSet = TRUE;
00444 }
00445 else
00446 { cSet = FALSE; }
00447
00448 if (GetMatchingItem(actPtr,0) != NULL)
00449 {
00450 oWhoset = GetMatchingItem(actPtr,0)->timeTag;
00451 oSet = TRUE;
00452 }
00453 else
00454 { oSet = FALSE; }
00455
00456 if ((cSet == FALSE) && (oSet == FALSE))
00457 { flag = ComparePartialMatches(theEnv,actPtr,newActivation); }
00458 else if ((cSet == TRUE) && (oSet == FALSE))
00459 { flag = GREATER_THAN; }
00460 else if ((cSet == FALSE) && (oSet == TRUE))
00461 { flag = LESS_THAN; }
00462 else if (oWhoset < cWhoset)
00463 { flag = GREATER_THAN; }
00464 else if (oWhoset > cWhoset)
00465 { flag = LESS_THAN; }
00466 else
00467 { flag = ComparePartialMatches(theEnv,actPtr,newActivation); }
00468
00469 if ((flag == LESS_THAN) ||
00470 ((flag == EQUAL) && (timetag > actPtr->timetag)))
00471 {
00472 theGroup->last = newActivation;
00473
00474 return(actPtr);
00475 }
00476 }
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486 actPtr = theGroup->first;
00487 while (actPtr != NULL)
00488 {
00489 cWhoset = -1;
00490 oWhoset = -1;
00491 if (GetMatchingItem(newActivation,0) != NULL)
00492 { cWhoset = GetMatchingItem(newActivation,0)->timeTag; }
00493
00494 if (GetMatchingItem(actPtr,0) != NULL)
00495 { oWhoset = GetMatchingItem(actPtr,0)->timeTag; }
00496
00497 if (oWhoset < cWhoset)
00498 {
00499 if (cWhoset > 0) flag = GREATER_THAN;
00500 else flag = LESS_THAN;
00501 }
00502 else if (oWhoset > cWhoset)
00503 {
00504 if (oWhoset > 0) flag = LESS_THAN;
00505 else flag = GREATER_THAN;
00506 }
00507 else
00508 { flag = ComparePartialMatches(theEnv,actPtr,newActivation); }
00509
00510 if (flag == LESS_THAN)
00511 {
00512 lastAct = actPtr;
00513 if (actPtr == theGroup->last)
00514 { break; }
00515 else
00516 { actPtr = actPtr->next; }
00517 }
00518 else if (flag == GREATER_THAN)
00519 { break; }
00520 else
00521 {
00522 if (timetag > actPtr->timetag)
00523 {
00524 lastAct = actPtr;
00525 if (actPtr == theGroup->last)
00526 { break; }
00527 else
00528 { actPtr = actPtr->next; }
00529 }
00530 else
00531 { break; }
00532 }
00533 }
00534
00535
00536
00537
00538
00539 if ((lastAct == NULL) ||
00540 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00541 { theGroup->first = newActivation; }
00542
00543 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00544 { theGroup->last = newActivation; }
00545
00546
00547
00548
00549
00550 return(lastAct);
00551 }
00552
00553
00554
00555
00556
00557
00558
00559
00560 static ACTIVATION *PlaceComplexityActivation(
00561 ACTIVATION *newActivation,
00562 struct salienceGroup *theGroup)
00563 {
00564 int complexity;
00565 unsigned long long timetag;
00566 ACTIVATION *lastAct, *actPtr;
00567
00568
00569
00570
00571
00572 timetag = newActivation->timetag;
00573 complexity = newActivation->theRule->complexity;
00574 if (theGroup->prev == NULL)
00575 { lastAct = NULL; }
00576 else
00577 { lastAct = theGroup->prev->last; }
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587 actPtr = theGroup->first;
00588 while (actPtr != NULL)
00589 {
00590 if (complexity < (int) actPtr->theRule->complexity)
00591 {
00592 lastAct = actPtr;
00593 if (actPtr == theGroup->last)
00594 { break; }
00595 else
00596 { actPtr = actPtr->next; }
00597 }
00598 else if (complexity > (int) actPtr->theRule->complexity)
00599 { break; }
00600 else if (timetag > actPtr->timetag)
00601 {
00602 lastAct = actPtr;
00603 if (actPtr == theGroup->last)
00604 { break; }
00605 else
00606 { actPtr = actPtr->next; }
00607 }
00608 else
00609 { break; }
00610 }
00611
00612
00613
00614
00615
00616 if ((lastAct == NULL) ||
00617 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00618 { theGroup->first = newActivation; }
00619
00620 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00621 { theGroup->last = newActivation; }
00622
00623
00624
00625
00626
00627 return(lastAct);
00628 }
00629
00630
00631
00632
00633
00634
00635
00636
00637 static ACTIVATION *PlaceSimplicityActivation(
00638 ACTIVATION *newActivation,
00639 struct salienceGroup *theGroup)
00640 {
00641 int complexity;
00642 unsigned long long timetag;
00643 ACTIVATION *lastAct, *actPtr;
00644
00645
00646
00647
00648
00649 timetag = newActivation->timetag;
00650 complexity = newActivation->theRule->complexity;
00651 if (theGroup->prev == NULL)
00652 { lastAct = NULL; }
00653 else
00654 { lastAct = theGroup->prev->last; }
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664 actPtr = theGroup->first;
00665 while (actPtr != NULL)
00666 {
00667 if (complexity > (int) actPtr->theRule->complexity)
00668 {
00669 lastAct = actPtr;
00670 if (actPtr == theGroup->last)
00671 { break; }
00672 else
00673 { actPtr = actPtr->next; }
00674 }
00675 else if (complexity < (int) actPtr->theRule->complexity)
00676 { break; }
00677 else if (timetag > actPtr->timetag)
00678 {
00679 lastAct = actPtr;
00680 if (actPtr == theGroup->last)
00681 { break; }
00682 else
00683 { actPtr = actPtr->next; }
00684 }
00685 else
00686 { break; }
00687 }
00688
00689
00690
00691
00692
00693 if ((lastAct == NULL) ||
00694 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00695 { theGroup->first = newActivation; }
00696
00697 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00698 { theGroup->last = newActivation; }
00699
00700
00701
00702
00703
00704 return(lastAct);
00705 }
00706
00707
00708
00709
00710
00711
00712
00713
00714 static ACTIVATION *PlaceRandomActivation(
00715 ACTIVATION *newActivation,
00716 struct salienceGroup *theGroup)
00717 {
00718 int randomID;
00719 unsigned long long timetag;
00720 ACTIVATION *lastAct, *actPtr;
00721
00722
00723
00724
00725
00726 timetag = newActivation->timetag;
00727 randomID = newActivation->randomID;
00728 if (theGroup->prev == NULL)
00729 { lastAct = NULL; }
00730 else
00731 { lastAct = theGroup->prev->last; }
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741 actPtr = theGroup->first;
00742 while (actPtr != NULL)
00743 {
00744 if (randomID > actPtr->randomID)
00745 {
00746 lastAct = actPtr;
00747 if (actPtr == theGroup->last)
00748 { break; }
00749 else
00750 { actPtr = actPtr->next; }
00751 }
00752 else if (randomID < actPtr->randomID)
00753 { break; }
00754 else if (timetag > actPtr->timetag)
00755 {
00756 lastAct = actPtr;
00757 if (actPtr == theGroup->last)
00758 { break; }
00759 else
00760 { actPtr = actPtr->next; }
00761 }
00762 else
00763 { break; }
00764 }
00765
00766
00767
00768
00769
00770 if ((lastAct == NULL) ||
00771 ((theGroup->prev != NULL) && (theGroup->prev->last == lastAct)))
00772 { theGroup->first = newActivation; }
00773
00774 if ((theGroup->last == NULL) || (theGroup->last == lastAct))
00775 { theGroup->last = newActivation; }
00776
00777
00778
00779
00780
00781 return(lastAct);
00782 }
00783
00784
00785
00786
00787
00788 static unsigned long long *SortPartialMatch(
00789 void *theEnv,
00790 struct partialMatch *binds)
00791 {
00792 unsigned long long *nbinds;
00793 unsigned long long temp;
00794 int flag;
00795 unsigned j, k;
00796
00797
00798
00799
00800
00801
00802
00803 nbinds = (unsigned long long *) get_mem(theEnv,sizeof(long long) * binds->bcount);
00804
00805 for (j = 0; j < (unsigned) binds->bcount; j++)
00806 {
00807 if ((binds->binds[j].gm.theMatch != NULL) &&
00808 (binds->binds[j].gm.theMatch->matchingItem != NULL))
00809 { nbinds[j] = binds->binds[j].gm.theMatch->matchingItem->timeTag; }
00810 else
00811 { nbinds[j] = 0; }
00812 }
00813
00814
00815
00816
00817
00818 for (flag = TRUE, k = binds->bcount - 1;
00819 flag == TRUE;
00820 k--)
00821 {
00822 flag = FALSE;
00823 for (j = 0 ; j < k ; j++)
00824 {
00825 if (nbinds[j] < nbinds[j + 1])
00826 {
00827 temp = nbinds[j];
00828 nbinds[j] = nbinds[j+1];
00829 nbinds[j+1] = temp;
00830 flag = TRUE;
00831 }
00832 }
00833 }
00834
00835
00836
00837
00838
00839 return(nbinds);
00840 }
00841
00842
00843
00844
00845
00846
00847
00848 static int ComparePartialMatches(
00849 void *theEnv,
00850 ACTIVATION *actPtr,
00851 ACTIVATION *newActivation)
00852 {
00853 int cCount, oCount, mCount, i;
00854 unsigned long long *basis1, *basis2;
00855
00856
00857
00858
00859
00860
00861 basis1 = SortPartialMatch(theEnv,newActivation->basis);
00862 basis2 = SortPartialMatch(theEnv,actPtr->basis);
00863
00864
00865
00866
00867
00868
00869
00870 cCount = newActivation->basis->bcount;
00871 oCount = actPtr->basis->bcount;
00872
00873 if (oCount > cCount) mCount = cCount;
00874 else mCount = oCount;
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884 for (i = 0 ; i < mCount ; i++)
00885 {
00886 if (basis1[i] < basis2[i])
00887 {
00888 rtn_mem(theEnv,sizeof(long long) * cCount,basis1);
00889 rtn_mem(theEnv,sizeof(long long) * oCount,basis2);
00890 return(LESS_THAN);
00891 }
00892 else if (basis1[i] > basis2[i])
00893 {
00894 rtn_mem(theEnv,sizeof(long long) * cCount,basis1);
00895 rtn_mem(theEnv,sizeof(long long) * oCount,basis2);
00896 return(GREATER_THAN);
00897 }
00898 }
00899
00900 rtn_mem(theEnv,sizeof(long long) * cCount,basis1);
00901 rtn_mem(theEnv,sizeof(long long) * oCount,basis2);
00902
00903
00904
00905
00906
00907
00908
00909
00910 if (cCount < oCount) return(LESS_THAN);
00911 else if (cCount > oCount) return(GREATER_THAN);
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921 if (newActivation->theRule->complexity < actPtr->theRule->complexity)
00922 { return(LESS_THAN); }
00923 else if (newActivation->theRule->complexity > actPtr->theRule->complexity)
00924 { return(GREATER_THAN); }
00925
00926
00927
00928
00929
00930
00931
00932 return(EQUAL);
00933 }
00934
00935
00936
00937
00938
00939 globle int EnvSetStrategy(
00940 void *theEnv,
00941 int value)
00942 {
00943 int oldStrategy;
00944
00945 oldStrategy = AgendaData(theEnv)->Strategy;
00946 AgendaData(theEnv)->Strategy = value;
00947
00948 if (oldStrategy != AgendaData(theEnv)->Strategy) EnvReorderAgenda(theEnv,NULL);
00949
00950 return(oldStrategy);
00951 }
00952
00953
00954
00955
00956
00957 globle int EnvGetStrategy(
00958 void *theEnv)
00959 {
00960 return(AgendaData(theEnv)->Strategy);
00961 }
00962
00963
00964
00965
00966
00967 globle void *GetStrategyCommand(
00968 void *theEnv)
00969 {
00970 EnvArgCountCheck(theEnv,"get-strategy",EXACTLY,0);
00971
00972 return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
00973 }
00974
00975
00976
00977
00978
00979 globle void *SetStrategyCommand(
00980 void *theEnv)
00981 {
00982 DATA_OBJECT argPtr;
00983 char *argument;
00984 int oldStrategy;
00985
00986 oldStrategy = AgendaData(theEnv)->Strategy;
00987
00988
00989
00990
00991
00992 if (EnvArgCountCheck(theEnv,"set-strategy",EXACTLY,1) == -1)
00993 { return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
00994
00995 if (EnvArgTypeCheck(theEnv,"set-strategy",1,SYMBOL,&argPtr) == FALSE)
00996 { return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv)))); }
00997
00998 argument = DOToString(argPtr);
00999
01000
01001
01002
01003
01004 if (strcmp(argument,"depth") == 0)
01005 { EnvSetStrategy(theEnv,DEPTH_STRATEGY); }
01006 else if (strcmp(argument,"breadth") == 0)
01007 { EnvSetStrategy(theEnv,BREADTH_STRATEGY); }
01008 else if (strcmp(argument,"lex") == 0)
01009 { EnvSetStrategy(theEnv,LEX_STRATEGY); }
01010 else if (strcmp(argument,"mea") == 0)
01011 { EnvSetStrategy(theEnv,MEA_STRATEGY); }
01012 else if (strcmp(argument,"complexity") == 0)
01013 { EnvSetStrategy(theEnv,COMPLEXITY_STRATEGY); }
01014 else if (strcmp(argument,"simplicity") == 0)
01015 { EnvSetStrategy(theEnv,SIMPLICITY_STRATEGY); }
01016 else if (strcmp(argument,"random") == 0)
01017 { EnvSetStrategy(theEnv,RANDOM_STRATEGY); }
01018 else
01019 {
01020 ExpectedTypeError1(theEnv,"set-strategy",1,
01021 "symbol with value depth, breadth, lex, mea, complexity, simplicity, or random");
01022 return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(EnvGetStrategy(theEnv))));
01023 }
01024
01025
01026
01027
01028
01029 return((SYMBOL_HN *) EnvAddSymbol(theEnv,GetStrategyName(oldStrategy)));
01030 }
01031
01032
01033
01034
01035
01036
01037 static char *GetStrategyName(
01038 int strategy)
01039 {
01040 char *sname;
01041
01042 switch (strategy)
01043 {
01044 case DEPTH_STRATEGY:
01045 sname = "depth";
01046 break;
01047 case BREADTH_STRATEGY:
01048 sname = "breadth";
01049 break;
01050 case LEX_STRATEGY:
01051 sname = "lex";
01052 break;
01053 case MEA_STRATEGY:
01054 sname = "mea";
01055 break;
01056 case COMPLEXITY_STRATEGY:
01057 sname = "complexity";
01058 break;
01059 case SIMPLICITY_STRATEGY:
01060 sname = "simplicity";
01061 break;
01062 case RANDOM_STRATEGY:
01063 sname = "random";
01064 break;
01065 default:
01066 sname = "unknown";
01067 break;
01068 }
01069
01070 return(sname);
01071 }
01072
01073 #endif
01074