void mxConfig::SetZoom (float f, int noup) {
	float prev_f=100;
	if (f==0) f=prev_f;
	int rw,rh; get_wh(f/100.f,rw,rh);
	wxString sz; sz.Printf("%.2f",f);
	if (noup!=0) tx_zoom->SetValue(sz);
	if (noup!=1) tx_ancho->SetValue(wxString()<<rw);
	if (noup!=2) tx_alto->SetValue(wxString()<<rh);
	prev_f=f;
}
void mxConfig::OnAlto (wxCommandEvent & evt) {
	if (ignore_events) return;
	ignore_events=true;
	evt.Skip();
	long h;
	if (tx_alto->GetValue().ToLong(&h)) {
		int w1,h1; get_wh(1,w1,h1);
		float z=100.f*(float(h)/float(h1));
		SetZoom(z,2);
	}
	ignore_events=false;
}
Beispiel #3
0
delivery_input_t create_delivery_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.9
    delivery_input_t din;

#ifndef USE_SAME_INPUT

    din._wh_id = get_wh(sf, specificWH, tspread);
    din._carrier_id = URand(1, 10);

#else
    // same input
    din._wh_id      = 1;
    din._carrier_id = 1;
#endif

    return (din);

}; // EOF: create_delivery
Beispiel #4
0
order_status_input_t create_order_status_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.4
    order_status_input_t osin;

#ifndef USE_SAME_INPUT

    osin._wh_id = get_wh(sf, specificWH, tspread);
    osin._d_id     = URand(1, 10);

#ifdef USE_SAFE_PATHS
    osin._c_select = URand(61, 100);
#else
    osin._c_select = URand(1, 100); /* 60% - 40% */
#endif

    if (osin._c_select <= 60) {
        // Calls the function that returns the correct cust_last
        generate_cust_last(NURand(255,0,999), osin._c_last);
    }
    else {
        osin._c_id = NURand(1023, 1, 3000);
    }

#else
    // same input
    osin._wh_id    = 1;
    osin._d_id     = 2;
    osin._c_select = 80;
    osin._c_id     = 3;
    //osin._c_last   = nullptr;
#endif

    return (osin);

}; // EOF: create_order_status
Beispiel #5
0
stock_level_input_t create_stock_level_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf > 0);

    // produce PAYMENT params according to tpcc spec v.5.4
    stock_level_input_t slin;

#ifndef USE_SAME_INPUT

    slin._wh_id = get_wh(sf, specificWH, tspread);
    slin._d_id      = URand(1, 10);
    slin._threshold = URand(10, 20);

#else
    // same input
    slin._wh_id     = 1;
    slin._d_id      = 2;
    slin._threshold = 15;
#endif

    return (slin);

}; // EOF: create_stock_level
Beispiel #6
0
int lrnproc(){
	
	/* 構造体のメモリ確保 */
	
	// 学習データ構造体
	int n=0;
	int r_cnt =0;  //  データ件数
	
	Lrndata *plrndata[INPUT_MAX];
	for(n=0; n < INPUT_MAX; ++n){
		plrndata[n] = (Lrndata *)malloc(sizeof(Lrndata));
	}
	
	// ニューロンの中間層及び出力層の重み構造体
	
	Whdata *pwhdata;
	Wodata *pwodata;
	pwhdata = (Whdata *)malloc(sizeof(Whdata));
	pwodata = (Wodata *)malloc(sizeof(Wodata));
	
	// 出力構造体
	Hd_output *phdo;
	Output *po;
	phdo = (Hd_output *)malloc(sizeof(Hd_output));
	po = (Output *)malloc(sizeof(Output));
	
	//  Filter構造体
	Filter *pflt;
	pflt = (Filter *)malloc(sizeof(Filter));
	
	// 全結合層への入力データ
	Input *pin;
	pin = (Input *)malloc(sizeof(Input));
	
	//  畳み込み出力
	Convout *pconv;
	pconv = (Convout *)malloc(sizeof(Convout));
	
	//  プーリング出力
	Poolout *ppool;
	ppool = (Poolout *)malloc(sizeof(Poolout));
	
	/* 構造体のメモリ確保完了 */
	
	
	// 学習データをセット
	r_cnt = setldata(plrndata);
	
	// データ件数を超えて確保したメモリを解放
	for(n=r_cnt; n < INPUT_MAX; ++n){
		free(plrndata[n]);
	}
	
	//  セットデータ確認
	getldata(r_cnt, plrndata);
	
	
	// 重みとしきい値の初期化
	init_wh(pwhdata);
	init_wo(pwodata);
	// debug_info
	get_wh(pwhdata);
	get_wo(pwodata);
	
	
	// Filterの初期化
	init_filter(pflt);
	get_filter(pflt);
	
	
	// sleep(5);
	
	
	double err = 100;   // 誤差の初期値
	double err1 = 100;  // 誤差1の初期値
	int count = 0;
	
	int i=0, j=0, k=0, a=0, b=0;
	
	/* 学習 */
	
	while(err1 > LIMIT1){
		err1 = 0.0;
		for(k=0; k < OUT_NUM; ++k){
			err = 0.0;
			for(i=0; i < r_cnt; ++i){  /*  学習データごとの繰り返し      */
				for(j=0; j < FILTERNO; ++j){   /*  フィルタごとの繰り返し      */
					//  畳み込みの計算
					conv(j, pflt, plrndata[i], pconv);
					//  プーリングの計算
					pool(pconv, ppool);
					//  プーリング出力を全結合層の入力へコピー
					for(a=0; a < POOLOUTSIZE; ++a){
						for(b=0; b < POOLSIZE; ++b){
							pin->input[j * POOLOUTSIZE * POOLOUTSIZE + POOLOUTSIZE * a + b] = ppool->poolout[a][b];
							pin->input[POOLOUTSIZE * POOLOUTSIZE * FILTERNO] = plrndata[i]->t;   //  教師データ
						}
					}
				}
				// 順方向の計算 
				forward(k, i, pin, pwhdata, pwodata, phdo, po);
				
				// 出力層重み調整
				olearn(k, i, pin, pwodata, phdo, po);
				
				// 中間層重み調整
				hlearn(k, i, pin, pwhdata, pwodata, phdo, po);
				
				// 誤差の積算
				// tは教師データ。乗算することで値を+とし積算する。
				err += (po->output[k] - plrndata[i]->t) * (po->output[k] - plrndata[i]->t);
			}
			printf("count = %d\t k = %d\t err = %lf\n", count, k, err);
			err1 += err;
		}
		printf("count = %d\t err1 = %lf\n", count, err1);
		++count;
		// fprintf(stderr, "%d\t err1 = %lf\n", count, err1);
	}
	/* 学習終了 */
	
	
	// ニューロン中間層及び出力層の重みとしきい値の最終結果確認
	get_wh(pwhdata);
	get_wo(pwodata);
	
	
	// 学習データに対する出力
	printf("*** Network output ***\n");
	printf("Num\t tercher\t output\t \n");
	for(i=0; i < r_cnt; ++i){
		printf("Num = %d\t ", i);
		for(j=0; j < FILTERNO; ++j){  //  フィルタごとの繰り返し
			// 畳み込みの計算
			conv(j, pflt, plrndata[i], pconv);
			// プーリングの計算
			pool(pconv, ppool);
			//  プーリング出力を全結合層の入力へコピー
			for(a=0; a < POOLOUTSIZE; ++a){
				for(b=0; b < POOLSIZE; ++b){
					pin->input[j * POOLOUTSIZE * POOLOUTSIZE + POOLOUTSIZE * a + b] = ppool->poolout[a][b];
					pin->input[POOLOUTSIZE * POOLOUTSIZE * FILTERNO] = plrndata[i]->t;   //  教師データ
				}
			}
		}
		printf("%d\t\t", plrndata[i]->t);
		for(j=0; j< OUT_NUM; ++j){
			// 学習後の結果出力
			printf("%lf\t ", forward(j, i, pin, pwhdata, pwodata, phdo, po) );
		}
		printf("\n");
	}
	
	
	// メモリ解放
	for(n=0; n < r_cnt; ++n){
		free(plrndata[n]);
	}
	free(pwhdata);
	free(pwodata);
	free(phdo);
	free(po);
	free(pflt);
	free(pin);
	
	return 0;
	
}
Beispiel #7
0
payment_input_t create_payment_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf>0);

    // produce PAYMENT params according to tpcc spec v.5.9
    payment_input_t pin;

#ifndef USE_SAME_INPUT

    pin._home_wh_id  = get_wh(sf, specificWH, tspread);
    pin._home_d_id = URand(1, 10);
    pin._h_amount = (long)URand(100, 500000)/(long)100.00;
    pin._h_date = time(nullptr);

#ifndef USE_ONLY_LOCAL_WHS
    pin._v_cust_wh_selection = URand(1, 100); // 85 - 15
    if (pin._v_cust_wh_selection <= 85) {
        // all local payment
        pin._remote_wh_id = pin._home_wh_id;
        pin._remote_d_id = pin._home_d_id;
    }
    else {
        // remote warehouse
        if (sf == 1) {
            pin._remote_wh_id = 1;
        }
        else {
            // pick a remote wh (different from the home_wh)
            do {
                pin._remote_wh_id = URand(1, sf);
            } while (pin._home_wh_id == pin._remote_wh_id);
        }
        pin._remote_d_id = URand(1, 10);
    }
#else
    pin._v_cust_wh_selection = 50;
    pin._remote_wh_id = pin._home_wh_id;
    pin._remote_d_id = pin._home_d_id;
#endif


#ifdef USE_SAFE_PATHS
    pin._v_cust_ident_selection = URand(61, 100); // 60 - 40
#else
    pin._v_cust_ident_selection = URand(1, 100); // 60 - 40
#endif

    if (pin._v_cust_ident_selection <= 60) {
        // Calls the function that returns the correct cust_last
        generate_cust_last(NURand(255,0,999), pin._c_last);
    }
    else {
        pin._c_id = NURand(1023, 1, 3000);
    }

#else
    // Same input
    pin._home_wh_id = 1;
    pin._home_d_id =  2;
    pin._v_cust_wh_selection = 80;
    pin._remote_wh_id = 1;
    pin._remote_d_id =  3;
    pin._v_cust_ident_selection = 50;
    pin._c_id =  1500;
    //pin._c_last = nullptr;
    pin._h_amount = 1000.00;
    pin._h_date = time(nullptr);
#endif

    return (pin);

}; // EOF: create_payment
Beispiel #8
0
new_order_input_t create_new_order_input(int sf, int specificWH, int tspread)
{
    // check scaling factor
    assert (sf>0);

    // produce NEW_ORDER params according to tpcc spec v.5.9
    new_order_input_t noin;

#ifndef USE_SAME_INPUT

    noin._wh_id = get_wh(sf, specificWH, tspread);
    noin._d_id   = URand(1, 10);
    noin._c_id   = NURand(1023, 1, 3000);
    noin._ol_cnt = URand(5, 15);
    noin._rbk    = URand(1, 100); // if rbk == 1 - ROLLBACK

    noin._tstamp = time(nullptr);

    // generate the items order
    for (int i=0; i<noin._ol_cnt; i++) {
        noin.items[i]._ol_i_id = NURand(8191, 1, 100000);
        noin.items[i]._ol_supply_wh_select = URand(1, 100); // 1 - 99
        noin.items[i]._ol_quantity = URand(1, 10);

#ifndef USE_ONLY_LOCAL_WHS
        if (noin.items[i]._ol_supply_wh_select == 1) {
            // remote new_order
            noin.items[i]._ol_supply_wh_id = URand(1, sf);
            if (noin.items[i]._ol_supply_wh_id != noin._wh_id)
                noin._all_local = 0; // if indeed remote WH, then update all_local flag
        }
        else {
            // home new_order
            noin.items[i]._ol_supply_wh_id = noin._wh_id;
        }
#else
        noin.items[i]._ol_supply_wh_id = noin._wh_id;
#endif
    }

#ifndef USE_NO_NORD_INPUTS_FOR_ROLLBACK
    if (noin._rbk == 1) {
        // generate an input that it will cause a rollback
        noin.items[noin._ol_cnt-1]._ol_i_id = -1;
        // TRACE( TRACE_TRX_FLOW, "Bad input...\n");
    }
#endif


#else
    // same input
    noin._wh_id  = 1;
    noin._d_id   = 2;
    noin._c_id   = 3;
    noin._ol_cnt = 10;
    noin._rbk    = 50;

    // generate the items order
    for (int i=0; i<noin._ol_cnt; i++) {
        noin.items[i]._ol_i_id = 1;
        noin.items[i]._ol_supply_wh_select = 50;
        noin.items[i]._ol_supply_wh_id = noin._wh_id; /* home new_order */
        noin.items[i]._ol_quantity = 5;
    }
#endif

    return (noin);

}; // EOF: create_new_order