⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfactor.m

📁 仿真人工金融市场Jackson代码
💻 M
字号:
#import "CFactor.h"@implementation CFactor-createEnd {  return self;}	-setInitialConditions {cfpercentage = 0.0;lastCF = 0.0;lastCF1 = 0.0;cFQ=0.0;transmitEffe = 0.0;return self;}-setMin: (double) min andMax: (double) Max {minimo = min;massimo = Max;return self;}-setMedia: (double) med andVarianza: (double) Varian {media = med;  varianza = Varian;return self;}-setType: (int) n_u {tipo_random = n_u;   return self;}-(double) getLastCF {return lastCF;}// this function give the quantity product from the counterfactor-(double)getQuantityCFactor {double coeff;double cVariable;double qCF;cVariable = [[modelswarm getFirm] getVariableCost]; coeff = (cfpercentage*[[modelswarm getMarket] getBeta])/(cVariable+ [[modelswarm getMarket] getBeta]);qCF = coeff* [[modelswarm getFirm] getLastMonop];if (qCF<=0) {	qCF=0;}transmitEffe = cfpercentage;cFQ=qCF; return qCF;}-(double)getCFQ {return cFQ;}-step {lastCF=lastCF1;lastCF1 = [self getQuantityCFactor];  return self;}// Setting variables//let's calculate the shock we add to the variable f// The shock can be a uniforma ramdom or normal one, depending on the choose// of the player-shock_f {if ([modelswarm getChoiceF] !=0) {if (tipo_random ==0)  // la variabile random e' quella uniforme      [self shock_f_Uniform];else      [self shock_f_Normal];  }  else // costantecfpercentage = [modelswarm getCFactorF]; return self;}// This method calculate the uniform random between a min or a max value the player//choose in the initial probe.-shock_f_Uniform {if ([modelswarm getTime]!=0) {cfpercentage +=[modelswarm getDblWithMin: minimo withMax: massimo];if (cfpercentage >1) cfpercentage = 1;if (cfpercentage <=0) cfpercentage = 1E-9;   } return self;}// This method calculate the normal random between a min or a max value the player//choose in the initial probe.-shock_f_Normal {id aNormalDist;aNormalDist = [NormalDist create: [self getZone] setGenerator:randomGenerator setMean: media setVariance: varianza] ;cfpercentage += [aNormalDist getDoubleSample];if (cfpercentage >1) cfpercentage = 1;if (cfpercentage <=0) cfpercentage = 1E-9;return self;}-setF: (double) effe {cfpercentage = effe;return self;}-(double) getFF { if ([modelswarm getTime]==0) {  return cfpercentage; }  else {  return transmitEffe;    }}-setModel: mo {  modelswarm = mo;  return self;}-updateCF { lastCF=lastCF1;return self;}@end  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -