コード例 #1
0
MdiEditor::MdiEditor(QApplication* app,QWidget *parent)
: QMainWindow(parent)
{

	_app=app;
	readyLabel=NULL;
	new_pro=save_pro=mod_para=NULL;
	imageEditorL = new ImageEditor('L');
	imageEditorR = new ImageEditor('R');
	imageEditorM = new HalfwayImage('M');
	widgetA = new QWidget();
	imageEditorA = new RenderWidget();
	ctrbar=new CCtrBar();

	for(int i=0;i<MAX_LAYER;i++)
	{
		match_thread[i]=NULL;
		match_thread_GPU[i]=NULL;
		poison_thread[i]=NULL;
		qpath_thread[i]=NULL;
	}


	createDockWidget();
	createMenuBar();
	createStatusBar();
	gpu_flag=FALSE;
	gpu_cap=CudaInit();

	connect(imageEditorL,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorR,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorM,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(ctrbar,SIGNAL(sigUpdate()),this,SLOT(updateALL()));
	connect(imageEditorL,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorR,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorM,SIGNAL(sigModified()),this,SLOT(PtModified()));
	connect(imageEditorL,SIGNAL(sigLayerReorder(char, bool,float, float)),this,SLOT(ReorderLayer(char, bool,float, float)));
	connect(imageEditorR,SIGNAL(sigLayerReorder(char, bool,float, float)),this,SLOT(ReorderLayer(char, bool,float, float)));
	connect(ctrbar,SIGNAL(sigStatusChange(int)),imageEditorA,SLOT(StatusChange(int)));
	connect(ctrbar,SIGNAL(sigRangeChange(int)),imageEditorA,SLOT(RangeChange(int)));
	connect(imageEditorA,SIGNAL(sigRecordFinished()),ctrbar,SLOT(record_finished()));
	connect(imageEditorA,SIGNAL(sigRecordFinished()),this,SLOT(AutoQuit()));

	layer_num=0;
	layer_index=0;

	clear();
    setWindowTitle(tr("Pixel Morph"));
	showMaximized();

}
コード例 #2
0
ファイル: Population.cpp プロジェクト: jonjonsonjr/ramsey
int main(int argc, const char* argv[])
{
    CudaInit();

    while (1) {
        unsigned int seed = time(NULL);
        srand(seed); //init random seed

        MEMBER population[POPULATION_SIZE];

        for (int i = 0; i < POPULATION_SIZE; i++) {
            InitializeRandomMember(&population[i]);
        }

        SortInitialPopulation(population, 0, POPULATION_SIZE - 1);

        for (int i = 0; i < POPULATION_PADDING; i++) {
            MEMBER member;
            InitializeRandomMember(&member);
            InsertMember(population, member);
            //PrintPopulation(population);
        }

        /* breed children */
        int best = 999999;
        for (int i = 0; i < CROSSES; i++) {
            MEMBER parents[2];
            MEMBER child;

            parents[0] = population[rand() % POPULATION_SIZE];
            parents[1] = population[rand() % POPULATION_SIZE];

            BiasedCross(parents, &child);
            InsertMember(population, child);

            if (population[0].num_cliques < best) {
                best = population[0].num_cliques;
                std::cout << best << std::endl;
            }

            if (population[POPULATION_SIZE - 1].num_cliques == population[0].num_cliques) {
                for (int i = 5; i < POPULATION_SIZE; i++) {
                    free(population[i].chromosome);
                    InitializeRandomMember(&population[i]);
                }
            }
        }

        std::cout << "Best member: " << population[0].num_cliques << std::endl;

        std::ofstream outfile;

        outfile.open("results.txt", std::ios_base::app);

        outfile << std::endl;
        outfile << "Best member: " << population[0].num_cliques << std::endl;
        for (int j = 0; j < CHROMOSOME_LENGTH; j++) {
            outfile << (char) (population[0].chromosome[j] + 0x30);
        }

        outfile << std::endl;

        /* echo seed for posterity */
        outfile << "SEED: " << seed << std::endl;
        outfile.close();

        for (int i = 0; i < POPULATION_SIZE; i++) {
            free(population[i].chromosome);
        }
    }
}