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

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

?? agent.java

?? 人工股市(Artificial Stock Market
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
package asm;import java.util.Vector;/** * Title:        Artificial Stock Market * Description:  人工模擬股市(來源:SFI的Swarm版本)的Java版本 * Copyright:    Copyright (c) 2003 * Company:      http://agents.yeah.net * @author jake * @version 1.0 */public class Agent {  static double minstrength;//最小的規則適應度  public double demand;	/*對股票的需求量" bid or -offer"*/  public double profit;	/*當期贏得的利潤" exp-weighted moving average "*/  public double wealth;	/*總財富" total agent wealth "*/  public double position;/*股票的持有量" total shares of stock "*/  public double cash;/*當期的現金量" total agent cash position "*/  public double initialcash;//初始時刻的現金  public double minholding;//最小的持股量  public double mincash;//最小現金量  public double intrate;//利率  public double intratep1;//利率+1  public double price;//當前的股票價格 price is maintained by World  public double dividend;//當前的股息 dividend is maintained by World  public int myID;  int currentTime; /*當前時間"The agent regularly checks with Swarm to see what time it is"*/  int lastgatime;	/*上一次運行遺傳算法的時間" last time period when the GeneticAlgorithm was run"*/  double avspecificity; /*平均特異性'average specificity of active forecasts"*/  double forecast;       /*對price+dividend的預測值"prediction of stock price: (trialprice+dividend)*pdcoeff + offset."*/  double lforecast; /*上一次的預測值"lagged forecast: forecast value from previous period"*/  double global_mean; /*"price+dividend"*/  double realDeviation;  /*預測與現實的差" ftarget-lforecast: how far off was the agent's forecast?"*/  double variance;   /*一個加權平均數公式:bv*variance + av*deviation*deviation"an Exp.Weighted MA of the agent's historical variance: Combine the old variance with deviation^squared, as in:  bv*variance + av*deviation*deviation"*/  double pdcoeff;   /*預測系數" coefficient used in predicting stock price, recalculated each period in prepareForTrading"*/  double offset;    /*預測系數" coefficient used in predicting stock price, recalculated each period in prepareForTrading"*/  double divisor;   /*計算股票需求量的一個系數" a coefficient used to calculate demand for stock. It is a proportion (lambda) of forecastvar (basically, accuracy of forecasts)"*/  int gacount;     /*運行過遺傳算法的次數" how many times has the Genetic Algorithm been used?"*/  AgentParam privateParams;     /*關于agent參數的一個集合"BFParams object holds parameters of this object"*/  Vector fcastList;        /*預測規則的列表"A Swarm Array, holding the forecasts that the agent might use"*/  Vector activeList;       /*激活的預測規則列表"A Swarm list containing a subset of all forecasts"*/  Vector oldActiveList;    /*激活的預測規則列表的拷貝"A copy of the activeList from the previous time step"*/  Vector History;         //關于agent的歷史紀錄  World  worldForAgent;   //當前的世界狀態和編碼  AsmModel local;         //對于AsmModel的一個拷貝/*"This tells BFagents where they should look to get the default  parameters. it should give the agent an object from the BFParams  class."*/void setBFParameterObject(AgentParam x){    privateParams=x;}/*" Sets a world for an agent.  It is a class method as it is used inboth class and instance methods in BFagent."*/void setWorld(World aWorld){  worldForAgent = aWorld;}/*"  Sets the IVAR intrate and uses that to calculate intratep1 (intrate + 1)."*/void setintrate(double rate){  //設定利率  intrate = rate;  intratep1 = intrate + 1.0;}/*" Sets the borrowing and short selling constraints, i.e., the  //      values can be negative. It sets values of the IVARS minholding and mincash"*/void setminHolding(double holding,double minimumcash){  minholding = holding;  mincash = minimumcash;}/*" Sets the initial stock holdings of each agent. It is the * designated initializer.  Most agent classes will have additional * initialization, but should do [super setInitialHoldings] to run * this first. It will initialize instance variables common to all * agents, setting profit,wealth, and position equal to 0, and it sets * the variable cash equal to initialcash "*/void setInitialHoldings(){  //幾個參數的初始化  profit = 0.0;  wealth = 0.0;  cash = initialcash;  position = 0.0;}/*" Sets an instance variable of agent, price, to the current price  which is controlled by the object known as "world". Please note this  assumes world is already set. "*/void getPriceFromWorld(){  price = worldForAgent.getPrice();}/*"Sets an instance variable of agent, dividend, to the current dividend. That information is retrieved from the object known as "world"."*/void getDividendFromWorld(){  dividend = worldForAgent.getDividend();}void creditEarningsAndPayTaxes()/*"Sent to each agent after a dividend is declared.  The agents * receive the dividend for each unit of stock they hold.  Their cash" * in the fixed asset account also receives its interest.  Then taxes * are charged on the previous total wealth, at a rate that balances * the interest on cash -- so if the agent had everything in cash it * would end up at the same place. * This is done in each period after the new dividend is declared.  It is * not normally overridden by subclases.  The taxes are assessed on the * previous wealth at a rate so that there's no net effect on an agent * with position = 0. * * In principle we do: *	wealth = cash + price*position;			// previous wealth *	cash += intrate * cash + position*dividend;	// earnings *	cash -= wealth*intrate;				// taxes * but we cut directly to the cash: *	cash -= (price*intrate - dividend)*position" */{//對每個agent進行征稅和分紅  getPriceFromWorld();  getDividendFromWorld();// Update cash  cash -= (price*intrate - dividend)*position;  if (cash < mincash)cash = mincash;// Update wealth  wealth = cash + price*position;}double constrainDemand(double slope[],double trialprice)/*" Method used by agents to constrain their demand according to the * mincash and minholding constraints. * It checks "demand" against the * mincash and minholding constraints and clips it if necessary, then * also setting *slope.  For use within subclass implementations of * getDemandAndSlope: forPrice:.  Used only by agents that work with * the Slope Specialist."*/{//檢查交宜人的需求量是否過量。如果是買入,則察看他的現金是否還夠,否則察看他能否賣出那么多股票。// If buying, we check to see if we're within borrowing limits,// remembering to handle the problem of negative dividends  -// cash might already be less than the min.  In that case we// freeze the trader.  if (demand > 0.0) {    if (demand*trialprice > (cash - mincash))      {	if (cash - mincash > 0.0) {	  demand = (cash - mincash)/trialprice;	  slope[0] = -demand/trialprice;	}	else	  {	    demand = 0.0;	    slope[0] = 0.0;	  }      }  }// If selling, we check to make sure we have enough stock to sell  else if (demand < 0.0 && demand + position < minholding)    {      demand = minholding - position;      slope[0] = 0.0;    }  return demand;}/*"initForecasts. Creates BFCast objects (forecasts) and puts them  into an array called fCastList.  These are the "meat" of this  agent's functionality, as they are repeatedly updated, improved, and  tested in the remainder of the class.  Please note each BFagent has  a copy of the default params object called privateParams.  It can be  used to set individualized values of settings in BFParams for each  agent. That would allow true diversity! I don't see how that diversity  would be allowed for in the ASM-2.0."*/void initForecasts(){  //初始化自己所有的預測規則  int  sumspecificity = 0;  int i;  Forecast aForecast=new Forecast(privateParams.condbits);  int numfcasts;// Initialize our instance variables  //all instances of BFagent can use the same BFParams object.  //ASM-2.0 was written that way, something like:  // privateParams= params;  // That seemed fraught with danger, with all instances having  // read/write access to a global parameter object, so now I'm  // creating a copy that each agent can have and individualize.  //privateParams = [params copy: [self getZone]];  //If you want to customize privateParams, this is the spot!  numfcasts = privateParams.numfcasts;  //fcastList=[Array create: [self getZone] setCount: numfcasts];  avspecificity = 0.0;  gacount = 0;  variance = privateParams.initvar;  getPriceFromWorld();  getDividendFromWorld();  global_mean = price + dividend;  forecast = lforecast = global_mean;  // Initialize the forecasts, put them into Swarm Array  //keep the 0'th forecast in a  "know nothing" condition  //[fcastList atOffset: 0 put: [self createNewForecast]];  //fcastList.addElement(new Forecast(worldForAgent.NWORLDBITS));  //create rest of forecasts with random conditions  //初始化每條規則,主要讓規則的if部分隨機取0,1,2,then部分在允許范圍內取值。    for(i = 0; i < numfcasts; i++){      aForecast=createNewForecast();      setConditionsRandomly(aForecast);      fcastList.addElement(aForecast); //put aForecast into Swarm array "fcastlist"     }/* Compute average specificity */  //pj: Here is the proper way to iterate over Swarm collections  //計算平均特異度  int size=fcastList.size();  for(i=0;i<size;i++){    aForecast=(Forecast)(fcastList.elementAt(i));    sumspecificity += aForecast.specificity;  }  avspecificity = (double) sumspecificity/(double)numfcasts;}/*"Creates a new forecast object (instance of BFCast), with all  condition bits set to 00 here, meaning "don't care.  It also sets  values for the other coefficients inside the BFCast.  This method is  accessed at several points throughout the BFagent class when new  forecasts are needed."*/Forecast createNewForecast(){  //新建一條規則  Forecast aForecast=new Forecast(privateParams.condbits);  //needed to set values of a,b,and c  //設置a,b,c系數的取值范圍  double abase = privateParams.a_min + 0.5*(1.0-privateParams.subrange)*privateParams.a_range;  double bbase = privateParams.b_min + 0.5*(1.0-privateParams.subrange)*privateParams.b_range;  double cbase = privateParams.c_min + 0.5*(1.0-privateParams.subrange)*privateParams.c_range;  double asubrange = privateParams.subrange*privateParams.a_range;  double bsubrange = privateParams.subrange*privateParams.b_range;  double csubrange = privateParams.subrange*privateParams.c_range;  aForecast.a=abase + Math.random()*asubrange;  aForecast.b=bbase + Math.random()*bsubrange;  aForecast.c=cbase + Math.random()*csubrange;  aForecast.condbits=privateParams.condbits;  aForecast.nnulls=privateParams.nnulls;  aForecast.bitcost=privateParams.bitcost;  aForecast.forecast=0.0;  aForecast.lforecast=global_mean;  aForecast.variance=privateParams.newfcastvar;  //same as bfagent's init  aForecast.strength=0.0;  return aForecast;}/*"Take a forecast object and randomly change the bits that govern  which conditions it monitors.  This appears to be a piece of  functionality that could move to the BFCast class itself. There were  quite a few of these details floating around in BFagent at one time,  many are gone now."*///隨機設置預測規則的if部分void setConditionsRandomly(Forecast fcastObject){  int bit;  double problist[];//概率列表,判斷每個位是否設置為不在乎2  problist=new double[privateParams.condbits];  String conditions="";  getProbList(problist);// = double[privateParams.getProbListPtr];  for(bit=0; bit< privateParams.condbits; bit++){       if (Math.random() < problist[bit]){	  conditions+=String.valueOf((int)(Math.random()*2));	  fcastObject.incrSpecificity();	  fcastObject.updateSpecfactor();	}      else{          conditions+="2";      }    }    fcastObject.conditions=conditions;}void prepareForTrading()  /*" * Set up a new active list for this agent's forecasts, and compute the * coefficients pdcoeff and offset in the equation *	forecast = pdcoeff*(trialprice+dividend) + offset * * The active list of all the fcasts matching the present conditions is saved * for later updates. "*/{  //準備交易,根據當前的世界的編碼信息,激活規則  double weight, countsum, forecastvar=0.0;  int mincount;  int nactive;  String myworld;  Forecast  aForecast=new Forecast(privateParams.condbits);  Forecast  bestForecast;  double maxstrength;  currentTime = getCurrentTime();  //如果滿足條件,則激活遺傳算法優化每一個規則  if (currentTime >= privateParams.firstgatime && Math.random() < privateParams.gaprob)    {      local.localasm.setStatus("正在執行遺傳算法");      performGA();      activeList.removeAllElements();    }  //this saves a copy of the agent's last as lforecast.  lforecast = forecast;  //得到世界當前的編碼  myworld = collectWorldData();  //根據編碼激活規則  updateActiveList(myworld);  maxstrength = -1e50;  bestForecast = null;  nactive = 0;  mincount = privateParams.mincount;  //在激活的規則列表中找出適應度最高的規則  int size=activeList.size();  for(int i=0;i<size;i++){      aForecast=(Forecast)activeList.elementAt(i);      if(i==0&&bestForecast==null)bestForecast=aForecast;      aForecast.lastactive=currentTime;      if(aForecast.incrCount()>= mincount){	  double strength=aForecast.strength;	  ++nactive;	  if (strength > maxstrength||(strength<-1e50&&maxstrength==-1e50)){	      maxstrength = strength;	      bestForecast= aForecast;          }	}    }  //如果有規則被激活,則選擇最好的規則作為參數  if (nactive>=1)  // meaning that at least some forecasts are active    {      pdcoeff = bestForecast.a;      offset = bestForecast.b*dividend + bestForecast.c;      if(privateParams.individual==1){       forecastvar = bestForecast.variance;      }else{        forecastvar = variance;      }    }  else  //如果沒有規則被激活 meaning "nactive" zero, no forecasts are active    {      countsum = 0.0;      pdcoeff = 0.0;      double pdcoeff1=0;      double offset1=0;      offset = 0.0;      mincount = privateParams.mincount;      //針對每條規則計算加權平均的預測系數

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩一区二区不卡| 亚洲国产婷婷综合在线精品| 亚洲精品第1页| 六月丁香婷婷色狠狠久久| 国产成人免费视频网站高清观看视频 | 欧洲生活片亚洲生活在线观看| 精品欧美黑人一区二区三区| 亚洲精品福利视频网站| 高清国产一区二区| 日韩欧美色综合网站| 亚洲成人免费观看| 高清不卡一区二区| 久久毛片高清国产| 裸体歌舞表演一区二区| 在线电影国产精品| 亚洲老妇xxxxxx| a级精品国产片在线观看| 国产午夜精品在线观看| 奇米综合一区二区三区精品视频| 在线视频欧美区| 亚洲欧洲韩国日本视频| 成人深夜在线观看| 亚洲国产精品v| 成人黄色av电影| 国产日韩精品久久久| 国产精品亚洲第一区在线暖暖韩国 | 久久日韩精品一区二区五区| 日韩激情一区二区| 欧美一区二区三区四区五区| 午夜天堂影视香蕉久久| 欧美福利一区二区| 天堂在线一区二区| 欧美一区二区高清| 美日韩一区二区| 日韩精品一区二区三区中文不卡| 日韩和欧美一区二区| 91精品国产91久久久久久最新毛片| 亚洲成在人线在线播放| 欧美视频在线播放| 男男视频亚洲欧美| 欧美videossexotv100| 国产呦萝稀缺另类资源| 久久久久99精品一区| 成人免费福利片| 亚洲精品国产无套在线观| 在线中文字幕不卡| 午夜欧美一区二区三区在线播放| 91精品欧美一区二区三区综合在| 人人精品人人爱| 日韩精品一区二| 成人99免费视频| 亚洲精品ww久久久久久p站| 欧美三级中文字| 久久99精品久久久久| 国产欧美一区二区三区沐欲 | 欧美久久一区二区| 天堂一区二区在线| 日韩三级视频中文字幕| 国产黄人亚洲片| 亚洲愉拍自拍另类高清精品| 欧美体内she精视频| 精品综合久久久久久8888| 中文字幕欧美激情一区| 欧美日精品一区视频| 免费高清在线视频一区·| 国产欧美日本一区视频| 欧美视频一区二区三区在线观看| 韩国三级在线一区| 亚洲免费在线观看视频| 欧美一区二区播放| 99视频在线精品| 日本网站在线观看一区二区三区| 国产欧美久久久精品影院| 精品视频资源站| 成人h版在线观看| 丝袜亚洲另类欧美| 日韩一区在线免费观看| 日韩精品一区二区三区在线| 99精品桃花视频在线观看| 日本亚洲免费观看| 亚洲另类在线制服丝袜| 久久久国际精品| 欧美另类久久久品| 91丨porny丨国产| 国产成人在线免费| 日日摸夜夜添夜夜添国产精品 | 91精品久久久久久久99蜜桃| 成人av影院在线| 国产一区二区三区观看| 日韩av二区在线播放| 亚洲精品写真福利| 国产视频911| 欧美日韩国产首页| 91麻豆文化传媒在线观看| 久久av资源网| 秋霞国产午夜精品免费视频| 亚洲综合丁香婷婷六月香| 欧美国产日本视频| 久久精品夜色噜噜亚洲aⅴ| 91精品国产综合久久精品app| 91伊人久久大香线蕉| 国产资源在线一区| 久久国内精品视频| 美美哒免费高清在线观看视频一区二区| 一区二区三区日韩欧美精品| 国产精品妹子av| 中文字幕乱码一区二区免费| 国产视频视频一区| 亚洲国产精品成人综合| 中文幕一区二区三区久久蜜桃| 欧美xxxxx裸体时装秀| 日韩欧美中文字幕公布| 欧美日高清视频| 制服丝袜亚洲色图| 日韩一区二区电影在线| 欧美成人一区二区三区| 精品成人佐山爱一区二区| 日韩三级电影网址| 精品国产网站在线观看| 2020国产精品自拍| 久久九九影视网| 国产精品蜜臀av| 一区二区三区日韩精品视频| 亚洲电影一级黄| 日本亚洲天堂网| 久久99精品国产麻豆婷婷| 国产精品1区2区3区在线观看| 丰满少妇在线播放bd日韩电影| 成人免费三级在线| 欧美最猛性xxxxx直播| 欧美老人xxxx18| 亚洲精品一线二线三线无人区| 2024国产精品视频| 亚洲丝袜精品丝袜在线| 五月婷婷另类国产| 国产一区二区在线免费观看| 成人一区二区三区视频在线观看| 色偷偷久久一区二区三区| 欧美久久久久免费| 国产日韩一级二级三级| 一区二区三区蜜桃网| 日韩不卡手机在线v区| 精品一区二区免费看| 成人黄页毛片网站| 欧美性生交片4| 精品成人免费观看| 1024成人网色www| 日本色综合中文字幕| 高清久久久久久| 8v天堂国产在线一区二区| 久久久精品欧美丰满| 一区二区三区精品在线| 激情久久久久久久久久久久久久久久| 国产电影精品久久禁18| 欧美色男人天堂| 中文字幕免费不卡| 免费高清在线视频一区·| a在线播放不卡| 久久久影视传媒| 日韩国产在线一| av综合在线播放| 欧美精品一区二区蜜臀亚洲| 一区二区三区四区蜜桃| 国产精品资源在线观看| 欧美嫩在线观看| 亚洲狼人国产精品| 国产成人精品免费网站| 日韩一区二区三区观看| 亚洲一区在线播放| 波多野结衣欧美| 国产色综合一区| 久久国产尿小便嘘嘘尿| 欧美日本韩国一区二区三区视频| 国产精品成人一区二区艾草| 麻豆久久一区二区| 欧洲av在线精品| 亚洲免费在线播放| 99久久er热在这里只有精品15| 精品国产91乱码一区二区三区| 日韩精品福利网| 欧美日韩一区二区三区在线| 亚洲美女视频在线观看| 成人免费高清在线观看| 国产人伦精品一区二区| 国产精品888| 久久久国产精品午夜一区ai换脸| 蜜臂av日日欢夜夜爽一区| 欧美日韩国产另类不卡| 夜夜爽夜夜爽精品视频| 91福利社在线观看| 日韩美女视频一区二区| 成人午夜精品一区二区三区| 久久嫩草精品久久久精品| 久久99精品国产麻豆婷婷 | 亚洲欧美在线视频观看| 成人丝袜18视频在线观看| 欧美激情一区在线观看| 国产91精品一区二区麻豆网站| 久久午夜国产精品| 国产91在线观看|