예제 #1
0
void LinearConstraint::checkRemoved(MIP &mip, Cost &cost, vector<int> &rmv) {


	pair<Cost, bool> result;
	vector<int> cDomain, cDomain2;
	//bool deleted = false;
	bool flag = false;
	for (int i=0;i<arity_;i++) {
		cDomain.clear();
		getDomainFromMIP(mip, i, cDomain); // getDomain
		sort(cDomain.begin(), cDomain.end());
		
		
		EnumeratedVariable* y = (EnumeratedVariable*)getVar(i);
		for (EnumeratedVariable::iterator v = y->begin(); v != y->end();++v) {
		
			vector<int>::iterator it = find(cDomain.begin(), cDomain.end(), *v);
			if (it == cDomain.end()) {
				cout << "non exist a value ?" << endl;
				for (vector<int>::iterator v=cDomain.begin();v != cDomain.end();v++) {
					cout << *v << " ";
				} cout << endl;
				for (EnumeratedVariable::iterator v = y->begin(); v != y->end();++v) {
					cout << *v << " ";
				} cout << endl;
				exit(0);
			}
			cDomain.erase(it);
			//deleted = true;
		}
		
		
		if (!cDomain.empty()) {
			cDomain2.clear();
			rmv.push_back(i);
			for (vector<int>::iterator v=cDomain.begin();v != cDomain.end();v++) {
				int var1 = mapvar[i][*v];
				if (mip.sol(var1) == 1){ // checking if this value is being used
					flag = true;
				}
				mip.colUpperBound(var1, 0); // removeDomain
			}
			//deleted = true;
		}
	}
	if (flag){
		cost = solveMIP(); // solve
	}
}
예제 #2
0
bool CLPLpsolve::solve(CLPSolveParameters params)
{

	switch (params.m_problemType) {
	case lpT:
		return solve(
			params.m_logFile,
			params.m_problemFile,
			params.m_solutionFile,
			params.m_initialSolverType,
			params.m_reSolverType,
			params.m_doLpPresolveInInitialSolve,
			params.m_doLpPresolveInReSolve,
			params.m_scaling,
			params.m_timeLimit,
			params.m_numberOfThread,
			params.m_nCPX_PARAM_BARCOLNZ,
			params.m_nCPX_PARAM_BARITLIM,
			params.m_nCPX_PARAM_BARALG,
			params.m_nCPX_PARAM_BARSTATALG,
			params.m_nCPX_PARAM_DEPIND,
			params.m_nCPX_PARAM_BARORDER,
			params.m_writeStatistics
			);

	case mipT:
		return solveMIP(
			params.m_mipSolverStrategy,
			params.m_logFile,
			params.m_problemFile,
			params.m_solutionFile,
			params.m_initialSolverType,
			params.m_reSolverType,
			params.m_doLpPresolveInInitialSolve,
			params.m_doLpPresolveInReSolve,
			params.m_scaling,
			params.m_mipIntegerTolerance,
			params.m_mipMaxNumNodes,
			params.m_mipMaxNumSolutions,
			params.m_mipAllowableGap,
			params.m_timeLimit
			);
	}
	return false;

}
예제 #3
0
void LinearConstraint::changeAfterExtend(vector<int> &supports, vector<map<Value, Cost> > &deltas){	

	bucost = cost;
	if (buObj == NULL){
		buObj = new int[count];
	}
	for (int i = 0; i < count; i++){
		buObj[i] = mip.objCoeff(i); // retrieve unary cost
	}
	for (unsigned int i=0;i<supports.size();i++) {
		for (map<Value, Cost>::iterator v = deltas[i].begin();v != deltas[i].end();v++)
			v->second *= -1;
		augmentStructure(mip, cost, supports[i], deltas[i]);
		for (map<Value, Cost>::iterator v = deltas[i].begin();v != deltas[i].end();v++)
			v->second *= -1;
	}
	cost = solveMIP(mip); // solve
	
}