亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? xcs.c

?? XCS is a new algorithm for artificial intelligent
?? C
字號:
/*
/       (XCS)
/	------------------------------------
/	Learning Classifier System based on accuracy
/
/     by Martin Butz
/     University of Wuerzburg / University of Illinois at Urbana/Champaign
/     butz@illigal.ge.uiuc.edu
/     Last modified: 10-17-99
/
/     Main program
*/

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

//#include <unistd.h>
#include <time.h>
//#include <resource.h>

#include "classifierList.h"
#include "actionSelection.h"
#include "xcs.h"
#include "env.h"
#include "xcsMacros.h"

int main(int args,char *argv[])
{
  FILE *env_file=NULL;

  /* set the priority */
//  setpriority(PRIO_PROCESS, getpid(), 5);

  /* randomize the pseudo-number generator */
  randomize();


  if(args!=2 && IS_MULTI_STEP){
    printf("Usage: xcs.out FILE\n");
    return 0;
  }

  if(args==2){
    if ((env_file = fopen(argv[1], "rt"))
	== NULL)
      {
	fprintf(stderr, "Cannot open file %s.\n",argv[1]);
	return 0;
      }
  }
  /* Initialize the environment (not always necessary) */
  if(!initEnv(env_file))
    return 0;
  
  if(args==2)
    fclose(env_file);

  /* start the experiments */
  startExperiments();
  
  freeEnv();

  return 1;
}

void startExperiments()
{
  int expcounter;
  struct xClassifierSet *pop;
  FILE *tabFile;

  /*Open files for statistics*/
  if ((tabFile = fopen(TABOUTFILE, "wt"))
      == NULL)
    {
      fprintf(stderr, "Cannot open file");
      fprintf(stderr,TABOUTFILE);
      return;
    }

  /* start the experiments */
  for( expcounter=0 ; expcounter<NR_EXPS ; expcounter++ ) {
    fprintf(tabFile,"Next Experiment\n");
    
    /* Initialize the population */
    pop=NULL;
    if(INITIALIZE_POP)
      pop=createRandomClassifierSet(CONDITION_LENGTH, ACTION_LENGTH);

    if(IS_MULTI_STEP)
      startOneMultiStepExperiment(tabFile, &pop);
    else
      startOneSingleStepExperiment(tabFile, &pop);
    
    freeClassifierSet(&pop);
  }
}


/* ########################## in a single step environment ########################## */

void startOneSingleStepExperiment(FILE *tabFile, struct xClassifierSet **pop)
{
  int trialCounter, exploit=1;
  int correct[50];
  double sysError[50];
  char state[CONDITION_LENGTH+1];

  /* set the \0 char at the end of action and state */
  state[CONDITION_LENGTH]='\0';

  /* Start one experiment, trialCounter counts the number of problems (trials)*/
  for( trialCounter=0 ; trialCounter<MAX_NR_STEPS ; trialCounter+=exploit) {

    /* change from explore to exploit and backwards */
    exploit= (exploit+1)%2;

    resetState(state);
     
    if(!exploit)
      doOneSingleStepProblemExplore(pop, state, trialCounter);
    else
      doOneSingleStepProblemExploit(pop, state, trialCounter, &correct[trialCounter%50], &sysError[trialCounter%50]);

    if( trialCounter%50==0 && exploit && trialCounter>0 ){
      writePerformance(tabFile, *pop, correct, sysError, trialCounter);
    }

    /* write the trialCounter every 1000 trials, to see the progress */
    if(trialCounter%1000==0 && exploit)
      printf("%d\n",trialCounter);
  }
}

void doOneSingleStepProblemExplore(struct xClassifierSet **pop, char *state, int trialCounter)
{        
  struct xClassifierSet *mset, *aset, *killset=NULL;
  char action[ACTION_LENGTH+1];
  double reward=0., predictionArray[NUMBER_OF_ACTIONS];
  int correct;

  /* get the match set */
  mset=getMatchSet(state,pop,&killset,trialCounter);
  /* no updates are necessary in this case */
  freeSet(&killset);

  /* get the Prediction array */
  getPredictionArray(mset, predictionArray);
    
  /* Get the action, that wins in the prediction array */
  action[ACTION_LENGTH]='\0';
  actionWinner(action, predictionArray);
    
  /* Get the action set according to the chosen action aw */
  aset = getActionSet(action, mset);

  /* execute the action and get reward
   * correct represents a boolean for the right or wrong action */
  reward = doAction(state, aset->cl->act, &correct);
        
  /* Give immediate reward */
  adjustActionSet(aset,0,reward);

  /* Exectue the discovery mechanism */
  discoveryComponent(&aset,pop,&killset,trialCounter);
  /* no update necessary here */
  freeSet(&killset);

  /* Clean up */
  freeSet(&mset);
  freeSet(&aset);
}

void doOneSingleStepProblemExploit(struct xClassifierSet **pop, char *state, int trialCounter, 
				   int *correct, double *sysError)
{        
  struct xClassifierSet *mset, *aset, *killset=NULL;
  char action[ACTION_LENGTH+1];
  double reward=0., predictionArray[NUMBER_OF_ACTIONS];

  /* get the match set*/
  mset=getMatchSet(state,pop,&killset,trialCounter);
  /* no updates are necessary in this case */
  freeSet(&killset);
    
  /* get the Prediction array */
  getPredictionArray(mset, predictionArray);
  
  /* Get the action, that wins in the prediction array */
  action[ACTION_LENGTH]='\0';
  deterministicActionWinner(action, predictionArray);
    
  /* Get the action set according to the chosen action aw */
  aset = getActionSet(action, mset);

  /* execute the action and get reward
   * correct represents a boolean for the right or wrong action */
  reward = doAction(state, aset->cl->act, correct);
    
  /* remember the system error */
  *sysError=(double)(abs((int)(reward - predictionArray[getActInt(action)])))/(double)PAYMENT_RANGE;

  /* Clean up */
  freeSet(&mset);
  freeSet(&aset);
}


/* ########################## in a multi step environment ########################## */

void startOneMultiStepExperiment(FILE *tabFile, struct xClassifierSet **pop)
{
  int counter, trialCounter, exploit=0;
  int stepToFood[50];
  double sysError[50];
  char state[CONDITION_LENGTH+1];

  /* set the \0 char at the end of action and state */
  state[CONDITION_LENGTH]='\0';
     
  /* Start one experiment, trialCounter counts the number of exploit problems (trials)*/
  for( trialCounter=0, counter=0 ; trialCounter<MAX_NR_STEPS ; trialCounter+=exploit) {
    
    exploit= (exploit+1)%2;
    
    if(!exploit)
      doOneMultiStepProblemExplore(pop, state, &counter);
    else
      doOneMultiStepProblemExploit(pop, state, &counter, &stepToFood[trialCounter%50], &sysError[trialCounter%50]);
    
    /* write out the performance every 50 trials */
    if( trialCounter%50==0 && exploit && trialCounter>0 ){
      writePerformance(tabFile, *pop, stepToFood, sysError, trialCounter);
    }
    /* write the trialCounter every 500 trials, to see the progress */
    if(trialCounter%500==0 && exploit)
      printf("%d\n",trialCounter);
  }
}

void doOneMultiStepProblemExplore(struct xClassifierSet **pop, char *state, int *counter)
{
  double reward=0., predictionArray[NUMBER_OF_ACTIONS];
  char action[ACTION_LENGTH+1];
  struct xClassifierSet *mset, *aset, *paset=NULL, *killset=NULL;
  int stepCounter, reset=0;

  /* set the \0 char at the end of action */
  action[ACTION_LENGTH]='\0';
  resetState(state);

  /* Start one problem, stepCounter counts the number of steps executed */
  for( stepCounter=0 ; stepCounter<TELETRANSPORTATION && !reset; stepCounter++, (*counter)++) {

    /* get the match set and update the previous action set*/
    mset=getMatchSet(state,pop,&killset,(*counter));
    if( paset!=NULL)
      updateSet(&paset,killset);
    freeSet(&killset);

    /* get the Prediction array */
    getPredictionArray(mset, predictionArray);

    /* Get the action, that wins in the prediction array */
    actionWinner(action, predictionArray);

    /* Get the action set according to the chosen action aw */
    aset = getActionSet(action, mset);

    /* execute the action and get reward */
    reward = doAction(state, aset->cl->act, &reset);

    /* Backpropagate the reward to the previous action set and apply the GA */
    if( paset!=NULL){
      adjustActionSet(paset,predictionArray[detActWinInt(predictionArray)],0);
      discoveryComponent(&paset,pop,&killset,(*counter));
      updateSet(&aset,killset);
      freeSet(&killset);
    }

    /* Give immediate reward, if a reset will take place and apply the GA, too */
    if( reset ){
      adjustActionSet(aset,0,reward);
      discoveryComponent(&aset,pop,&killset,(*counter));
      updateSet(&aset,killset);
      freeSet(&killset);
    }
    /* Clean up */
    freeSet(&mset);
    freeSet(&paset);
    paset=aset;
  }
  freeSet(&paset);
}

void doOneMultiStepProblemExploit(struct xClassifierSet **pop, char *state, int *counter, int *stepToFood, double *sysError )
{
  double reward=0., predictionArray[NUMBER_OF_ACTIONS], predictionValue, previousPrediction=0.;
  char action[ACTION_LENGTH+1];
  struct xClassifierSet *mset, *aset, *paset=NULL, *killset=NULL;
  int stepCounter, reset=0;

  /* set the \0 char at the end of action and init the sysError*/
  action[ACTION_LENGTH]='\0';
  *sysError=0;
  resetState(state);

  /* Start one problem, stepCounter counts the number of steps executed */
  for( stepCounter=0 ; stepCounter<TELETRANSPORTATION && !reset ; stepCounter++) {

    /* get the match set and update the previous action set*/
    mset=getMatchSet(state,pop,&killset,(*counter));
    if( paset!=NULL)
      updateSet(&paset,killset);
    freeSet(&killset);

    /* get the Prediction array */
    getPredictionArray(mset, predictionArray);

    /* Get the action, that wins in the prediction array */
    deterministicActionWinner(action, predictionArray);
    predictionValue= predictionArray[detActWinInt(predictionArray)];

    /* Get the action set according to the chosen action aw */
    aset = getActionSet(action, mset);

    /* execute the action and get reward */
    reward = doAction(state, aset->cl->act, &reset);

    /* Give immediate reward, if a reset will take place */
    if( reset ){
      adjustActionSet(aset,0,reward);
      (*sysError) += (double)(abs((int)(reward - predictionValue)))/(double)PAYMENT_RANGE;
    }

    /* Backpropagate the reward to the previous action set */
    if( paset!=NULL){
      adjustActionSet(paset,predictionArray[detActWinInt(predictionArray)],0);
      (*sysError) += (double)(abs((int)(GAMMA*predictionValue - previousPrediction))) / (double)PAYMENT_RANGE;
    }
    /* remind the prediction for the system Error */
    previousPrediction=predictionValue;

    /* Clean up */
    freeSet(&mset);
    freeSet(&paset);
    paset=aset;
  }
  freeSet(&paset);
  *stepToFood=stepCounter;
  (*sysError)/=stepCounter;
}



/* writes the performance averaged over the last 50 trials */
void writePerformance(FILE *tabFile,struct xClassifierSet *pop, int *correct,double *sysError,int counter)
{
  double corr=0.,serr=0.;
  int i, popsize;

  for( popsize=0 ; pop!=NULL ; pop=pop->next, popsize++ );/* Just count the size of the population */

  for(i=0;i<50;i++){
    corr+=correct[i];
    serr+=sysError[i];
  }
  corr/=50.;
  serr/=50.;
  fprintf(tabFile,"%d;%f;%f;%f\n",counter,corr,serr,(double)popsize/PAYMENT_RANGE);
}



/* randomize the pseudo random generator */
void randomize(void)
{
  int i;

  for (i=0;i<time(NULL)%1000;rand(),i++);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产拍揄自揄精品视频麻豆| 中文字幕亚洲精品在线观看| 久久综合久久综合亚洲| 亚洲欧美在线观看| 国模冰冰炮一区二区| 色乱码一区二区三区88| 久久精品视频一区二区三区| 五月天一区二区三区| 91日韩精品一区| 国产午夜一区二区三区| 男男视频亚洲欧美| 欧美三级一区二区| 亚洲欧美日韩一区二区三区在线观看| 韩国一区二区在线观看| 欧美精品 国产精品| 一区二区三区精品视频在线| 国产99久久久国产精品免费看| 欧美一区二区成人| 天堂成人免费av电影一区| 91色乱码一区二区三区| 中文字幕在线观看一区| 国产裸体歌舞团一区二区| 日韩欧美国产精品| 日韩电影一二三区| 在线综合亚洲欧美在线视频| 亚洲高清免费视频| 欧美老年两性高潮| 亚洲777理论| 欧美老肥妇做.爰bbww视频| 亚洲综合一区二区三区| 欧美中文字幕一区| 亚洲一区av在线| 欧美男生操女生| 日韩主播视频在线| 日韩欧美视频在线| 国内精品国产三级国产a久久| 日韩欧美一级精品久久| 国产在线精品一区二区夜色| 亚洲一区二区3| 欧美无乱码久久久免费午夜一区| 亚洲另类色综合网站| 在线视频中文字幕一区二区| 一区二区三区精品在线| 777奇米四色成人影色区| 日韩 欧美一区二区三区| 精品国产免费人成在线观看| 国产在线播放一区三区四| 国产校园另类小说区| kk眼镜猥琐国模调教系列一区二区| 国产精品精品国产色婷婷| 91丨国产丨九色丨pron| 亚洲第一福利一区| 日韩精品一区二区三区swag| 国产成人在线看| 综合激情成人伊人| 4hu四虎永久在线影院成人| 麻豆国产精品官网| 中文一区一区三区高中清不卡| 99综合影院在线| 视频一区中文字幕国产| 久久久久99精品一区| 日本精品一区二区三区四区的功能| 天天操天天干天天综合网| 日韩免费成人网| av电影一区二区| 日本一区中文字幕| 国产精品天干天干在线综合| 欧美三区在线观看| 国产99一区视频免费| 性做久久久久久久免费看| 久久久久亚洲蜜桃| 欧美体内she精高潮| 国产精品99久久久久久宅男| 夜夜嗨av一区二区三区中文字幕| 欧美电视剧免费全集观看| 26uuu欧美| a级精品国产片在线观看| 蜜桃视频第一区免费观看| 中文字幕日韩欧美一区二区三区| 这里只有精品99re| 91色视频在线| 粉嫩嫩av羞羞动漫久久久| 日韩精品国产欧美| 亚洲免费色视频| 国产亚洲成年网址在线观看| 91精品国产综合久久婷婷香蕉 | 国产精品一二三| 亚洲精品国产第一综合99久久| 久久一区二区三区国产精品| 欧美性色黄大片手机版| av福利精品导航| 国产一区在线精品| 青草国产精品久久久久久| 夜夜嗨av一区二区三区四季av| 国产午夜精品一区二区三区嫩草| 91精品国产品国语在线不卡| 欧洲中文字幕精品| 91丨国产丨九色丨pron| 高清国产一区二区| 国产精品亚洲专一区二区三区| 天堂va蜜桃一区二区三区漫画版| 亚洲综合在线五月| 亚洲另类在线一区| 亚洲欧美国产高清| 中文字幕一区免费在线观看| 中文字幕免费在线观看视频一区| 日韩精品一区在线观看| 日韩一卡二卡三卡| 在线观看91精品国产麻豆| 欧美主播一区二区三区| 91丨国产丨九色丨pron| 色悠久久久久综合欧美99| 精品国免费一区二区三区| 91精品国产色综合久久不卡电影 | 午夜视频一区二区三区| 亚洲午夜激情av| 午夜精品一区在线观看| 午夜精彩视频在线观看不卡| 亚洲成人免费影院| 日韩1区2区日韩1区2区| 麻豆久久一区二区| 国产乱色国产精品免费视频| 国产精品66部| 97国产一区二区| 欧美亚洲图片小说| 3d成人h动漫网站入口| 精品久久一二三区| 中文字幕精品三区| 一区二区三区在线免费视频| 亚洲一区二区三区在线| 日韩国产欧美在线播放| 国产一区二区看久久| 不卡欧美aaaaa| 欧美在线观看视频一区二区三区| 欧美午夜精品一区二区蜜桃| 欧美一级搡bbbb搡bbbb| 久久久久久久免费视频了| 亚洲欧洲无码一区二区三区| 一级日本不卡的影视| 免费不卡在线视频| 成人午夜av在线| 欧美日韩在线观看一区二区 | 91黄色小视频| 欧美精品高清视频| 久久精品男人的天堂| 成人欧美一区二区三区| 日韩精品每日更新| caoporen国产精品视频| 欧美日韩成人综合| 久久精品网站免费观看| 一区二区三区中文字幕| 久久电影网站中文字幕| av不卡免费在线观看| 日韩欧美三级在线| 亚洲三级电影网站| 久久99九九99精品| 色成年激情久久综合| 日韩美女视频在线| 综合激情成人伊人| 国产一区二区三区四| 在线观看日韩高清av| 久久久777精品电影网影网| 一卡二卡三卡日韩欧美| 国产一区二区91| 69堂亚洲精品首页| 亚洲乱码日产精品bd| 韩国三级中文字幕hd久久精品| 日本高清成人免费播放| 国产日韩成人精品| 麻豆成人在线观看| 欧美色图在线观看| 自拍av一区二区三区| 国产真实乱子伦精品视频| 欧美剧情电影在线观看完整版免费励志电影| 久久你懂得1024| 免费观看在线色综合| 欧美日韩国产小视频| 亚洲免费av高清| 成人黄色在线网站| 国产日韩欧美高清| 精品一区二区三区在线观看国产| 欧美日韩视频第一区| 亚洲自拍欧美精品| 色综合天天综合网国产成人综合天| 国产婷婷色一区二区三区四区| 久久精品国内一区二区三区 | 97久久人人超碰| 国产无遮挡一区二区三区毛片日本| 日本亚洲免费观看| 在线播放中文字幕一区| 午夜久久久久久电影| 91福利国产精品| 一区二区三区四区av| 99re视频这里只有精品| 亚洲特黄一级片| 91美女福利视频| 亚洲精品ww久久久久久p站 | 一区二区三区精品在线观看| 99精品偷自拍| 亚洲一区二区三区四区在线|