当前位置: 首页>>代码示例>>C++>>正文


C++ Solver::Init方法代码示例

本文整理汇总了C++中Solver::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Solver::Init方法的具体用法?C++ Solver::Init怎么用?C++ Solver::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Solver的用法示例。


在下文中一共展示了Solver::Init方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char ** argv)
{
	glutInit(&argc, argv);

	if (argc != 1 && argc != 6) {
		fprintf(stderr, "usage : %s N dt diff visc force source\n", argv[0]);
		fprintf(stderr, "where:\n"); \
			fprintf(stderr, "\t N      : grid resolution\n");
		fprintf(stderr, "\t dt     : time step\n");
		fprintf(stderr, "\t diff   : diffusion rate of the density\n");
		fprintf(stderr, "\t visc   : viscosity of the fluid\n");
		fprintf(stderr, "\t force  : scales the mouse movement that generate a force\n");
		fprintf(stderr, "\t source : amount of density that will be deposited\n");
		exit(1);
	}

	if (argc == 1) {
		N = 64;
		dt = 0.1f;
		diff = 0.0001f;
		visc = 0.0f;
		force = 5.0f;
		source = 100.0f;
		fprintf(stderr, "Using defaults : N=%d dt=%g diff=%g visc=%g force = %g source=%g\n",
			N, dt, diff, visc, force, source);
	}
	else {
		N = atoi(argv[1]);
		dt = atof(argv[2]);
		diff = atof(argv[3]);
		visc = atof(argv[4]);
		force = atof(argv[5]);
		source = atof(argv[6]);
	}

	printf("\n\nHow to use this demo:\n\n");
	printf("\t Add densities with the right mouse button\n");
	printf("\t Add velocities with the left mouse button and dragging the mouse\n");
	printf("\t Toggle density/velocity display with the 'v' key\n");
	printf("\t Toggle retro mode by pressing the 'p' key\n");
	printf("\t Clear the simulation by pressing the 'c' key\n");
	printf("\t Quit by pressing the 'q' key\n");

	dvel = false;
	pixel = false;
	
	solver.Init(N, dt, diff, visc);

	if (!solver.AllocateData()) exit(1);

	win_x = 512;
	win_y = 512;
	OpenGlutWindow();

	glutMainLoop();

	exit(0);
}
开发者ID:hugo19941994,项目名称:practica-fluidos,代码行数:58,代码来源:main.cpp

示例2: simpleInitTest

	bool simpleInitTest(ofstream& fout, Solver& solver, const Array& a,
			const Array& b, const Matrix& bin) {
		PrintABbin(fout, a, b, bin);
		fout << "-------------------------" << endl;
		solver.Init(a.size(), b.size(), bin);
		fout << "solver.Init(a.size(),b.size(),bin);" << endl;
		solver.PrintTestData(fout);
		fout << "-------------------------" << endl;
		return simpleNoPrintABbinTest(fout, solver, a.begin(), b.begin());
	}
开发者ID:Yin-Shane-Xia,项目名称:opengm,代码行数:10,代码来源:test_transportsolver.cpp

示例3: main

int main(int argc, char** argv)
{
	Solver *pSolver = new Solver();

	int nResultInit = pSolver->Init(argc, argv);
	switch( nResultInit ) {
		case EX_SUCCESS : {
			break;
		}
		case EX_FAILURE : {
			delete pSolver;
			return EX_SUCCESS;
			break;
		}
		default : {
			break;
		}
	}

	int nResultLoop = pSolver->Loop();
	switch( nResultLoop ) {
		case EX_SUCCESS : {
			break;
		}
		case EX_FAILURE : {
			delete pSolver;
			return EX_SUCCESS;
			break;
		}
		default : {
			break;
		}
	}

	int nResultPost = pSolver->Post();
	switch( nResultPost ) {
		case EX_SUCCESS : {
			break;
		}
		case EX_FAILURE : {
			delete pSolver;
			return EX_SUCCESS;
			break;
		}
		default : {
			break;
		}
	}

	delete pSolver;

  return EX_SUCCESS;
}
开发者ID:avr-aics-riken,项目名称:BCMTools,代码行数:53,代码来源:main.cpp

示例4: main

int main(int argc, char* argv[]) {
  google::InitGoogleLogging(argv[0]);

  const int kNumberArguments = 6;
  if (argc < kNumberArguments) {
    LOG(ERROR) << "Usage: " << argv[0] << " "
               << "INSTANCE_FILE SOLVER RANDOM_SEED "
               << "ALGORITHM MAX_TIME [UPPER_BOUND] [SOLVER_LOG_LEVEL]";
    return argc;
  }

	string instance_file(argv[1]);
  string formulacao(argv[2]);
	int random_seed = atoi(argv[3]);
	string algorithm(argv[4]);
  int max_time = atoi(argv[5]);
  int upper_bound = (argc >= 7 ? atoi(argv[6]) : 0);
  if (argc >= 8)
    Globals::SetSolverLog(atoi(argv[7]));

  if (instance_file.find(".mps") != string::npos) {
    ReadAndSolveMpsFile(instance_file);
    return 0;
  }

  Globals::rg()->RandomInit(random_seed);
  VLOG(1) << "Loading instance file: " << instance_file;
  ProblemDataLoader loader(instance_file.c_str(), upper_bound, Globals::instance());
  loader.load();

  // Solver options
  SolverOptions options;
  options.set_max_time(max_time);
  options.set_relative_time_for_first_solution(Globals::instance()->n() *
                                               Globals::instance()->m());
  if (upper_bound > 0)
    options.set_cut_off_value(upper_bound);
  options.set_use_stabilization(true);

	// Solver and input options
  Solver* solver;
  SolverFactory* solver_factory;
  if (formulacao == "GeracaoColunas") {
    solver = new SolverGeracaoColunas(Globals::instance());
    solver_factory = new SolverGeracaoColunasFactory();
  } else if (formulacao == "FormulacaoPadrao") {
    solver = new SolverFormulacaoPadrao(Globals::instance());
    solver_factory = new SolverFormulacaoPadraoFactory();
  } else {
    LOG(FATAL) << "Inexistent formulation specified: " << formulacao;
    return 2;
  }

  // to keep the time
  Stopwatch^ sw = gcnew Stopwatch();

	// input options and final status
	SolverStatus status;
  //PopulateStatus status;

	if (algorithm == "CPLEX") {
		sw->Start();
		solver->Init(options);
    //solver->Populate(options, &status);
		solver->Solve(options, &status);
		sw->Stop();
	} else if (algorithm == "CPLEX-UB") {
    options.set_cut_off_value(upper_bound);
		sw->Start();
		solver->Init(options);
		solver->Solve(options, &status);
		sw->Stop();
	} else if (algorithm == "VNSBra") {
    //options.set_time_for_first_solution(60);
		sw->Start();
    LocalSearch::VNSBra(solver_factory, options.max_time() * 1000,
                        300 * 1000, 5, &status);
		sw->Stop();
	} else if (algorithm == "Memetic") {
		sw->Start();
		LocalSearch::MIPMemetic(&status);
		sw->Stop();
  } else if (algorithm == "PathRelink") {
    sw->Start();
    LocalSearch::PathRelink(solver_factory, options.max_time() * 1000,
                            120 * 1000, 1, &status);
    sw->Stop();
  } else if (algorithm == "PostProcessing") {
    sw->Start();
    LocalSearch::PostProcessing(solver_factory, options.max_time() * 1000,
                                120 * 1000, 1, &status);
    sw->Stop();
  } else {
    LOG(FATAL) << "Inexistent algorithm specified: " << algorithm;
    return 3;
  }

  status.time = sw->ElapsedMilliseconds / 1000.0;
	LOG(INFO) << status.ToString();
	return 0;
//.........这里部分代码省略.........
开发者ID:danielamaral,项目名称:GAP,代码行数:101,代码来源:GAP.cpp

示例5: initTest

		bool initTest(Solver& solver, const Array& a,
				const Array& b, const Matrix& bin, double answer, double precision=1e-10) {
			solver.Init(a.size(), b.size(), bin);
			return solveTest(solver,a,b,answer,precision);
		}
开发者ID:Yin-Shane-Xia,项目名称:opengm,代码行数:5,代码来源:test_transportsolver.cpp


注:本文中的Solver::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。