void do_experiment(swp_t&swp, sind_t&sind, rng_t&rng) { constant_indicator mind( moran_probability(swp.mutantFitness()/swp.residentFitness(), swp.n_individuals())); relative_indicator_t<sind_t, constant_indicator> rind(sind,mind); if (parameters.experiment() == "SWEEP") { IndicatorsDisplayController<swp_t,ParamsClass> ind_display; ind_display.inheritParametersFrom(swp); ind_display.setrecordEvery(0); ind_display.setdisplayEvery(0); ind_display.installIndicator(rind,"fixation/Moran prob"); // // cout << "fixation / Moran probability is " << rind(swp) << endl; // for (double rsr = 0.001; rsr <= 1000; rsr *= 1.1/*1.01*/) // // for (swp.room_switch_rate = 1000; swp.room_switch_rate >= 0.001; // // swp.room_switch_rate /= 1.01) // { double p_switch = rsr / (1 + rsr); // swp.setroom_switch_rate(rsr); // ind_display.update(p_switch,swp); // } for (double mp = 0.01; mp < 1; mp += 0.01) { swp.setlattice_move_probability(mp); ind_display.update(mp,swp); } } else if (parameters.experiment() == "SAMPLE") { cout << "swarming pattern:\n" << canonical(swp); double pfix = sind(swp); cout << "fixation probability: " << pfix << '\n'; cout << "Moran probability: " << mind(swp) << '\n'; } else if (parameters.experiment() == "OPTIMIZE") { cout << "Moran probability: " << mind(swp) << '\n'; do_optimize(swp,sind,swp,rng); } }
/* ---------------------------------------------------------------- space --- */ static int space(float dim[], /* first 4 args: arrays of 2 elements */ float source[], float warp1[], float warp2[], float dec, float rndval) { int i; double pow1, pow2, pow3, pow4, rval, xval, x; float rndseed, bounce[NTAPS][2]; float xxx, xlist[2]; rndseed = (rndval == 0.0) ? 0.3 : rndval; pow1 = log((double)warp1[0]) / log(0.5); pow2 = log((double)warp1[1]) / log(0.5); pow3 = log((double)warp2[0]) / log(0.5); pow4 = log((double)warp2[1]) / log(0.5); for (i = 0; i < 2; i++) { source[i] *= dim[i]; x = (double)i / 2.0; rval = ((double)rind(0.5, &rndseed) + 0.5) / 2.0 + x; xval = exp(log(rval) / pow1); bounce[i][0] = (float)rval; bounce[i][1] = (float)pow(xval, pow2); rval = ((double)rind(0.5, &rndseed) + 0.5) / 2.0 + x; xval = exp(log(rval) / pow3); bounce[i + 4][0] = (float)rval; bounce[i + 4][1] = (float)pow(xval, pow4); rval = ((double)rind(0.5, &rndseed) + 0.5) / 2.0 + x; xval = exp(log(rval) / pow2); bounce[i + 2][1] = (float)rval; bounce[i + 2][0] = (float)pow(xval, pow1); rval = ((double)rind(0.5, &rndseed) + 0.5) / 2.0 + x; xval = exp(log(rval) / pow4); bounce[i + 6][1] = (float)rval; bounce[i + 6][0] = (float)pow(xval, pow3); bounce[i + 8][0] = (rind(0.5, &rndseed) + 0.5) / 2.0 + x; bounce[i + 10][0] = (rind(0.5, &rndseed) + 0.5) / 2.0 + x; bounce[i + 8][1] = bounce[i + 10][1] = 0.0; bounce[NTAPS - 1][i] = source[i]; } for (i = 0; i < 4; i++) { bounce[i][0] *= (0.5 * dim[0]); bounce[i][1] *= dim[1]; bounce[i + 4][0] = (1.0 - bounce[i + 4][0] * 0.5) * dim[0]; bounce[i + 4][1] *= dim[1]; } for (i = 8; i < 10; i++) { bounce[i][0] *= 0.5 * dim[0]; bounce[i + 2][0] = (1.0 - bounce[i + 2][0] * 0.5) * dim[0]; } xlist[0] = 0.5 * dim[0]; xlist[1] = 0.0; bounce[NTAPS - 1][0] = source[0]; bounce[NTAPS - 1][1] = source[1]; xxx = 0; for (i = 0; i < NTAPS; i++) { float d, s, a; specs(source, &bounce[i][0], xlist, dec, &d, &s, &a); delay[i] = d; sloc[i] = s; amp[i] = a * boost(s); xxx += amp[i]; } printf(" x-loc y-loc delay sloc amp\n"); for (i = 0; i < NTAPS; i++) { amp[i] /= xxx; delay[i] -= delay[NTAPS - 1]; printf("%7.2f %7.2f %6.5f %6.5f %6.5f\n", bounce[i][0], bounce[i][1], delay[i], sloc[i], amp[i]); } return 0; }
void pio_drq_block_in(struct ata_channel *channel, unsigned int addr_datareg, unsigned int buf_addr, long word_cnt ) { long bcnt; int mem_dt_opt; unsigned int data_regaddr; unsigned int *uip1; unsigned int *uip2; unsigned char *ucp1; unsigned char *ucp2; unsigned int reg_addr = channel->pio_reg_addrs[ addr_datareg ]; // NOTE: word_cnt is the size of a DRQ data block/packet // in words. The maximum value of wordCnt is normally: // a) For ATA, 16384 words or 32768 bytes (64 sectors, // only with READ/WRITE MULTIPLE commands), // b) For ATAPI, 32768 words or 65536 bytes // (actually 65535 bytes plus a pad byte). if ( channel->pio_linear ) { // PCMCIA Memory mode data transfer. // set Data reg address per pio_memory_dt_opt data_regaddr = 0x0; mem_dt_opt = channel->pio_memory_dt_opt; if ( mem_dt_opt == PIO_MEMORY_DT_OPT8 ) data_regaddr = 0x8; if ( mem_dt_opt == PIO_MEMORY_DT_OPTB ) { data_regaddr = 0x400; } if ( channel->pio_xfer_width == 8 ) { // PCMCIA Memory mode 8-bit bcnt = word_cnt * 2; ucp1 = (unsigned char*)channel->pio_linear + data_regaddr; for ( ; bcnt > 0; bcnt -- ) { ucp2 = (unsigned char*) buf_addr; * ucp2 = * ucp1; buf_addr++; if ( mem_dt_opt == PIO_MEMORY_DT_OPTB ) { data_regaddr++; data_regaddr = ( data_regaddr & 0x03ff ) | 0x0400; ucp1 = (unsigned char*) channel->pio_linear + data_regaddr; } } } else { // PCMCIA Memory mode 16-bit uip1 = (unsigned int*) channel->pio_linear + data_regaddr; for ( ; word_cnt > 0; word_cnt -- ) { uip2 = (unsigned int*)buf_addr; *uip2 = *uip1; buf_addr += 2; if ( mem_dt_opt == PIO_MEMORY_DT_OPTB ) { data_regaddr += 2; data_regaddr = ( data_regaddr & 0x03fe ) | 0x0400; uip1 = (unsigned int*) channel->pio_linear + data_regaddr; } } } } else { int pxw; long wc; // adjust pio_xfer_width - don't use DWORD if wordCnt is odd. pxw = channel->pio_xfer_width; if ( ( pxw == 32 ) && ( word_cnt & 0x1 ) ) pxw = 16; // Data transfer using INS instruction. // Break the transfer into chunks of 32768 or fewer bytes. while ( word_cnt > 0 ) { if ( word_cnt > 16384 ) wc = 16384; else wc = word_cnt; if ( pxw == 8 ) { // do REP INSB rinb( reg_addr, buf_addr, wc * 2 ); } else if ( pxw == 32 ) { // do REP INSD rind( reg_addr, buf_addr, wc / 2 ); } else { // do REP INSW rinw( reg_addr, buf_addr, wc ); } buf_addr = buf_addr + ( wc * 2 ); word_cnt = word_cnt - wc; } } return; }