예제 #1
0
openPlatypusSpace



/*!
	The constructor
*/
PlusDistObj::PlusDistObj(Conf const & theConf, B const NeedHint) :
		Function(theConf.SysHdl(), NeedHint)
{
	WatchError
	Warn(!(Energy::e().ModelId() != EnergyCls<MjEnergy>::ModelId ||
      Energy::e().ModelId() != EnergyCls<BarerraEnergy>::ModelId), eEnergyMismatch);

    Z modelCutoff=(Energy::e().ModelId() == EnergyCls<MjEnergy>::ModelId)?0:-1000;

	Dim tDimen = Space::Dimen();
	Hdl tSysHdl = theConf.SysHdl();
	Dim tSpan = Protein::p().Span();
	Dim tLength = Protein::p().Length();
	block1<Prm,nmm> tResult(tSpan * tLength / 2);

	for(Pos tPos1 = 0; tPos1 < tSpan; ++tPos1)
	{
		Typ tTyp1 = Protein::p().Type(tPos1);
		//if (tTyp1 != Energy::e().Type(2, 'H')) continue;
		for(Pos tPos2 = tPos1 + 2; tPos2 < tLength; ++tPos2)
		{
			Typ tTyp2 = Protein::p().Type(tPos2);
			//if (tTyp2 != Energy::e().Type(2, 'H')) continue;
            if(Energy::e().Level(tTyp1,tTyp2)<=modelCutoff) continue;

            Prm tDiff[tDimen], tSqrd[tDimen];
			for(Cmp tCmp = 0; tCmp < tDimen; ++tCmp)
			{
				Prm tVar1 = Prm(TermVar,tPos1 * tDimen + tCmp);
				Prm tVar2 = Prm(TermVar,tPos2 * tDimen + tCmp);
				tDiff[tCmp] = Prm(TermFunc,BsubXiFeVi::def(Xv, tSysHdl, tVar1, tVar2));
				tSqrd[tCmp] = Prm(TermFunc,UsqrXiFeVi::def(Xv, tSysHdl, tDiff[tCmp]));
			}
			tResult.insert(Prm(TermFunc,SumXiFeVi::def(Xv, tSysHdl, tSqrd, tDimen),ValueAsEvalMin));
		}
	}
	//mFuncHdl = SumXiFcMi::def(Xv, tSysHdl, tResult.items(), tResult.size());
	//mMetricRec = &SumXiFcMi::ref(tSysHdl, mFuncHdl).MetricRec();
	if (NeedHint)
	{
		mFuncHdl = SumXiEFcMiHn::def(Xv | EvalMin, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiEFcMiHn::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	else
	{
		mFuncHdl = SumXiFcMi::def(Xv, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiFcMi::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	CatchError
}
예제 #2
0
/*!
	The constructor
*/
ACoreDistObj::ACoreDistObj(Conf const & theConf, B const NeedHint) :
		Function(theConf.SysHdl(), NeedHint)
{
	WatchError
	//Alert(Energy::e().ModelId() != EnergyCls<HpEnergy>::ModelId, eEnergyMismatch);

	Dim tDimen = Space::Dimen();
	Hdl tSysHdl = theConf.SysHdl();
	Dim tSpan = Protein::p().Span();
	Dim tLength = Protein::p().Length();
	block1<Prm,nmm> tResult(tSpan * tLength / 2);


    block1<Prm,nmm> hCore(tDimen);

    for(Cmp tCmp = 0; tCmp < tDimen; ++tCmp)
    {
        block1<Prm,xmm> corePrms;
        for(Pos tPos = 0; tPos < tSpan; ++tPos)
        {
            Typ tTyp = Protein::p().Type(tPos);
            if (toHp[tTyp]==0) continue;
            corePrms.insertMem(Prm(TermVar,tPos * tDimen + tCmp));

        }
        // now sum all the points
        Prm SumComp = Prm(TermFunc,SumXiFeVi::def(Xv, tSysHdl, corePrms.items(), corePrms.itemCount()));
        Prm CompVal = Prm(TermFunc,UdivXiFeVi::def(Xv,tSysHdl, SumComp,UdivXiFeVi::bind(corePrms.itemCount())));
        hCore.insert(CompVal);
    }

    for(Pos tPos = 0; tPos < tSpan; ++tPos)
	{
		Typ tTyp = Protein::p().Type(tPos);
		if (toHp[tTyp]==0) continue;

        Prm tDiff[tDimen], tSqrd[tDimen];
        for(Cmp tCmp = 0; tCmp < tDimen; ++tCmp)
        {
            Prm tVar1 = Prm(TermVar,tPos * tDimen + tCmp);
            Prm tVar2 = Prm(hCore[tCmp]);
            tDiff[tCmp] = Prm(TermFunc,BsubXiFeVi::def(Xv, tSysHdl, tVar1, tVar2));
            tSqrd[tCmp] = Prm(TermFunc,UsqrXiFeVi::def(Xv, tSysHdl, tDiff[tCmp]));
        }
        tResult.insert(Prm(TermFunc,SumXiFeVi::def(Xv, tSysHdl, tSqrd, tDimen),ValueAsEvalMin));
	}
    //mFuncHdl = SumXiFcMi::def(Xv, tSysHdl, tResult.items(), tResult.size());
	//mMetricRec = &SumXiFcMi::ref(tSysHdl, mFuncHdl).MetricRec();
    if (NeedHint)
	{
		mFuncHdl = SumXiEFcMiHn::def(Xv | EvalMin, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiEFcMiHn::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	else
	{
		mFuncHdl = SumXiFcMi::def(Xv, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiFcMi::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	CatchError
}
예제 #3
0
openPlatypusSpace



/*!
	The constructor
*/
SideChainCns::SideChainCns(Conf const & theConf, B const NeedHint) :
		Function(theConf.SysHdl(), NeedHint)
{
	WatchError

	Dim tDimen = Space::Dimen();
	Hdl tSysHdl = theConf.SysHdl();
	Dim tSpan = Protein::p().Span();
	Dim tLength = Protein::p().Length();
	block1<Prm,nmm> tResult(tSpan * tLength / 2);

	Int tSqrNeighDist = Lattice::l().SqrNeighDist();
	for(Pos tPos1 = 0; tPos1 < tLength; ++tPos1)
	{
	    Pos  tPos2;
	    if(tPos1<tLength/2)
            tPos2 = tPos1 + 1;
        else
            tPos2 = tPos1 - tLength/2;
		Prm tDiff[tDimen], tSqrd[tDimen];
		for(Cmp tCmp = 0; tCmp < tDimen; ++tCmp)
		{
			Prm tVar1 = Prm(TermVar,tPos1 * tDimen + tCmp);
			Prm tVar2 = Prm(TermVar,tPos2 * tDimen + tCmp);
			tDiff[tCmp] = Prm(TermFunc,BsubXiFeVi::def(Xv, tSysHdl, tVar1, tVar2));
			tSqrd[tCmp] = Prm(TermFunc,UsqrXiFeVi::def(Xv, tSysHdl, tDiff[tCmp]));
		}
		Prm tDist = Prm(TermFunc,SumXiFeVi::def(Xv, tSysHdl, tSqrd, tDimen));
		tResult.insert(Prm(TermFunc,UequXiFcMi::def(Xv, tSysHdl, tDist, UequXiFcMi::bind(tSqrNeighDist)), MetricAsEvalMin));
	}
	cout << tResult.itemCount() <<endl;
	if (NeedHint)
	{
		mFuncHdl = SumXiEFcMiHn::def(Xm | EvalMin, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiEFcMiHn::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	else
	{
		mFuncHdl = SumXiFcMi::def(Xm, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiFcMi::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	CatchError
}
예제 #4
0
/*!
	@brief A function to solve magic square problem.
	@details This function solves magic square problem.
	@param ArgC The number of parameters.
	@param ArgV The parameters themselves.
*/
int MSquare(int ArgC, char * ArgV[])
{
	if (ArgC <= 2)
	{
		cerr << endl;
		cerr << "Magic Square Problem" << endl << endl;
		cerr << "Usage:" << endl;
		cerr << ArgV[0] << " " << ArgV[1] << " -n Dimension -i MaxIter [-t TabuLength -s RandSeed]" << endl << endl;
		cerr << "Output:" << endl;
		cerr << "BestViolation IterationCount RunTime MemoryUsage" << endl;
		cerr << "TabuLength SquareDimension [CellValuesRowMajorWise] RandomSeed" << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Dim Dimension = 0;
	Itn MaxIteration = 0;
	Dim TabuLength = 0;
	Rnd theRnd;

	for(Idx tIdx = 2; tIdx < castIdx(ArgC); ++tIdx)
	{
		if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'n')
			Dimension = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 't')
			TabuLength = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'i')
			MaxIteration = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 's')
			theRnd.seed(parseN(ArgV[tIdx+1]));
	}
	if(!Dimension || !MaxIteration)
	{
		cerr << endl;
		cerr << "Error in commandline parameter/value. Run only with parameter " << ArgV[1] << " to see usage." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Sys & tSys = Sys::refm(Sys::def());
	#if ExecDnwd
	tSys.setMultiCandExec();
	#endif

	EvalTi::def(tSys.SysHdl);

	Typ tTabuType = QcSv0Tabu::def(tSys.SysHdl, TabuLength);

	b1<Prm,kmm> tVars(Dimension * Dimension);
	b1<Prm,kmm> tSums(Dimension + Dimension + 2);

	for(Idx tIdx = 0; tIdx < Dimension * Dimension; ++tIdx)
		tVars[tIdx] = Prm(Tv, StatRangeVarVi::def(tSys.SysHdl, 1, Dimension * Dimension));

	b1<Prm,kmm> tSumVars(Dimension);
	for(Idx tIdx1 = 0; tIdx1 < Dimension; ++tIdx1)
	{
		for(Idx tIdx2 = 0; tIdx2 < Dimension; ++tIdx2)
			tSumVars[tIdx2] = tVars[tIdx1 * Dimension + tIdx2];
		tSums[tIdx1] = Prm(Tf, GndSumEquXiBiFcMi::def(Xv, tSys.SysHdl, tSumVars.items(), Dimension,
				GndSumEquXiBiFcMi::bind(Dimension * (1 + Dimension * Dimension)/2)));
	}
	for(Idx tIdx1 = 0; tIdx1 < Dimension; ++tIdx1)
	{
		for(Idx tIdx2 = 0; tIdx2 < Dimension; ++tIdx2)
			tSumVars[tIdx2] = tVars[tIdx2 * Dimension + tIdx1];
		tSums[Dimension + tIdx1] = Prm(Tf, GndSumEquXiBiFcMi::def(Xv, tSys.SysHdl, tSumVars.items(), Dimension,
				GndSumEquXiBiFcMi::bind(Dimension * (1 + Dimension * Dimension)/2)));
	}

	for(Idx tIdx = 0; tIdx < Dimension; ++tIdx)
		tSumVars[tIdx] = tVars[tIdx * Dimension + tIdx];
	tSums[Dimension + Dimension] = Prm(Tf, GndSumEquXiBiFcMi::def(Xv, tSys.SysHdl, tSumVars.items(), Dimension,
			GndSumEquXiBiFcMi::bind(Dimension * (1 + Dimension * Dimension)/2)));

	for(Idx tIdx = 0; tIdx < Dimension; ++tIdx)
		tSumVars[tIdx] = tVars[tIdx * Dimension + Dimension - 1 - tIdx];
	tSums[Dimension + Dimension + 1] = Prm(Tf, GndSumEquXiBiFcMi::def(Xv, tSys.SysHdl, tSumVars.items(), Dimension,
			GndSumEquXiBiFcMi::bind(Dimension * (1 + Dimension * Dimension)/2)));

	Prm TopSum = Prm(Tf, SumXiFcMi::def(Xm, tSys.SysHdl, tSums.items(), Dimension + Dimension + 2));

	Hdl const tSelcHdl =  SvTabuMinIdenSsZi::def( Zm, tSys.SysHdl, TopSum, tTabuType);

	b1<Hdl,kmm> VarHdls(Dimension * Dimension);
	b1<Wrp,kmm> InitValues(Dimension * Dimension);
	for(Idx tIdx = 0; tIdx < Dimension * Dimension; ++tIdx)
	{
		VarHdls[tIdx] = tIdx;
		InitValues[tIdx] = Wrp(castInt(tIdx + 1));
	}
	shuffle<Wrp>(theRnd, InitValues.items(), Dimension * Dimension);

	tSys.initialiseVarsWrap(VarHdls.items(), InitValues.items());

	#if CompLazyHalf
	Selc::refm(tSys.SysHdl, tSelcHdl).activate(true);
	#endif

	Refc(tTopSum, SumXiFcMi, tSys.SysHdl, TopSum.TermHdl);
	Int BestMetric = tTopSum.MetricRec().CurrData();
	while(tSys.ExecClk() < MaxIteration && BestMetric > 0)
	{
		Selc::selectExecuteSelc1(tSys.SysHdl, tSelcHdl, theRnd);
		#if CompLazyFull
		Term::performExecIncr(Func::ptrm(tSys.SysHdl, TopSum.TermHdl));
		#endif
		if (tTopSum.MetricRec().CurrData() < BestMetric)
			BestMetric = tTopSum.MetricRec().CurrData();
	}

	cout << BestMetric << " " << tSys.ExecClk() << " " << getTime() << " " << getMemory() << endl;
	cout << TabuLength << " " << Dimension;
	if (!BestMetric)
		for(Idx tIdx = 0; tIdx < Dimension * Dimension; ++tIdx)
			cout << " " << StatRangeVarVi::refc(tSys.SysHdl, tIdx).CurrValue();
	cout << " " << theRnd.Seed() << endl;
	return ExitOnSuccess;
}
예제 #5
0
파일: psp.cpp 프로젝트: swakkhar/kangaroo
/*!
	@brief A function to solve wireless mesh channel allocation problem.
	@details This function solves  wireless mesh channel allocation problem.
*/
int PSP(int ArgC, char * ArgV[])
{
	if (ArgC <= 2)
	{
		cerr << endl;
		cout << "Protein Structure Prediction Problem" << endl << endl;
		cerr << "Usage:" << endl;
		cerr << ArgV[0] << " -n ProteinLength -p ProteinHPString -f FitnessUseRatio -i MaxIter [-t TabuLength -s RandomSeed]" << endl << endl;
		cerr << "Output:" << endl;
		cerr << "BestEnergy IterationCount Run-Time MemoryUsage" << endl;
		cerr << "TabuLength" << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Dim ProteinSize = 0;				//	Size of the protein.
	Dim FitnessRatio = 0;				//	Fitness usage ratio.
	Dim MaxIteration = 0;				//	Maximum iteration for local search algorithm.
	Rnd theRnd;							//	Random number generator
	Dim TabuLength = 0;					//	Tabu length for constraint based local search.
	Dim ProteinIdx = 0;					//	Parameter index having the amino acid.

	for(Idx tIdx = 2; tIdx < castIdx(ArgC); ++tIdx)
	{
		if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'n')
			ProteinSize = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'f')
			FitnessRatio = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'i')
			MaxIteration = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 't')
			TabuLength = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'p')
			ProteinIdx = tIdx+1;
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 's')
			theRnd.seed(parseN(ArgV[tIdx+1]));
	}

	if(!MaxIteration || !ProteinIdx || !FitnessRatio)
	{
		cerr << endl;
		cerr << "Error in commandline parameter/value. Run only with parameter " << ArgV[1] << " to see usage." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	b1<Bll,kmm> AminoAcids(ProteinSize);//	Amino acid types of the amino acids.
	for(Idx tIdx = 0; tIdx < ProteinSize; ++tIdx)
		AminoAcids[tIdx] = (ArgV[ProteinIdx][tIdx] == 'H');

	Sys & tSys = Sys::refm(Sys::def());

	#if CompDnwd
		tSys.setMultiCandExec();
		#if SimulFixedFlexi
			#if SelcSimulFlexi
			tSys.setMultiFlexiSimul();
			#else
			tSys.setMultiFixedSimul();
			#endif
		#elif SimulFixedOnly
		tSys.setMultiFixedSimul();
		#elif SimulFlexiOnly
			tSys.setMultiFlexiSimul();
		#endif
	#endif
	EvalTi::def(tSys.SysHdl);
	EvalTi const & tEvalTbl = EvalTi::refc(tSys.SysHdl);
	QcSv2Tabu::def(tSys.SysHdl, TabuLength);

	b1<Prm,kmm> Xvars(ProteinSize);
	b1<Prm,kmm> Yvars(ProteinSize);
	b1<Prm,kmm> Zvars(ProteinSize);
	b1<EvalRecInt const *,kmm> XvarRecs(ProteinSize);
	b1<EvalRecInt const *,kmm> YvarRecs(ProteinSize);
	b1<EvalRecInt const *,kmm> ZvarRecs(ProteinSize);
	b1<StatRangeVarVi *,kmm> XvarPtrs(ProteinSize);
	b1<StatRangeVarVi *,kmm> YvarPtrs(ProteinSize);
	b1<StatRangeVarVi *,kmm> ZvarPtrs(ProteinSize);

	for (Idx tIdx = 0; tIdx < ProteinSize; ++tIdx)
	{
		Xvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize));
		Yvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize));
		Zvars[tIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, -2 * ProteinSize, 2 * ProteinSize));

		XvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Xvars[tIdx].TermHdl).ValueLoc());
		YvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Yvars[tIdx].TermHdl).ValueLoc());
		ZvarRecs[tIdx] = tEvalTbl.ptrcEvalRec(StatRangeVarVi::refc(tSys.SysHdl, Zvars[tIdx].TermHdl).ValueLoc());

		XvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Xvars[tIdx].TermHdl);
		YvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Yvars[tIdx].TermHdl);
		ZvarPtrs[tIdx] = StatRangeVarVi::ptrm(tSys.SysHdl, Zvars[tIdx].TermHdl);
	}

	b2<Prm> Dists(ProteinSize, ProteinSize);
	for (Idx tIdx1 = 0; tIdx1 < ProteinSize - 1; ++tIdx1)
		for (Idx tIdx2 = tIdx1 + 1; tIdx2 < ProteinSize; ++tIdx2)
		{
			b1<Prm,kmm> tDist(3);
			tDist[0] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Xvars[tIdx1], Xvars[tIdx2]))));
			tDist[1] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Yvars[tIdx1], Yvars[tIdx2]))));
			tDist[2] = Prm(Tf, UsqrXiFeVi::def(Xv, tSys.SysHdl, Prm(Tf, BsubXiFeVi::def(Xv, tSys.SysHdl, Zvars[tIdx1], Zvars[tIdx2]))));
			Dists.item(tIdx1,tIdx2) = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, tDist.items(), 3));
		}

	b1<Prm, xmm> Fhdists, Edists, Fhpdists;
	for (Idx tIdx1 = 0; tIdx1 < ProteinSize - 1; ++tIdx1)
	{
		for (Idx tIdx2 = tIdx1 + 1; tIdx2 < ProteinSize; ++tIdx2)
		{
			Fhpdists.insertMem(Dists.item(tIdx1, tIdx2));
			if (!AminoAcids[tIdx1] || !AminoAcids[tIdx2]) continue;
			Fhdists.insertMem(Dists.item(tIdx1, tIdx2));
			Edists.insertMem(Prm(Tf, UeqsXiFeVi::def(Xv, tSys.SysHdl, Dists.item(tIdx1,tIdx2), UeqsXiFeVi::bind(2))));
		}
	}

	Prm Etop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Edists.items(), Edists.itemCount()));
	Prm Fhtop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Fhdists.items(), Fhdists.itemCount()));
	Prm Fhptop = Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, Fhpdists.items(), Fhpdists.itemCount()));

//	random valid initialisation

	hsetd<Point,nmmh> AllDiff(ProteinSize);
	b1<Point,kmm> Points(ProteinSize);
	b1<Idx, kmm> AllDiffIdx(ProteinSize);

	Point tp = {0,0,0};
	Idx ti = 0;
	Points[ti] = tp;
	AllDiffIdx[ti] = AllDiff.insertItr(tp);

	while(ti < ProteinSize - 1)
	{
		Idx vn = uniform(theRnd, 12);
		tp.x = Points[ti].x + vx[vn];
		tp.y = Points[ti].y + vy[vn];
		tp.z = Points[ti].z + vz[vn];
		Cnt tc = 0;
		while (tc < 12 && AllDiff.findBll(tp))
		{
			++tc;
			Idx vni = uniform(theRnd, 12);
			tp.x = Points[ti].x + vx[vni];
			tp.y = Points[ti].y + vy[vni];
			tp.z = Points[ti].z + vz[vni];
		}
		if (tc < 12)
		{
			Points[++ti] = tp;
			AllDiffIdx[ti] = AllDiff.insertItr(tp);
		}
		else
			AllDiff.removeWithItr(AllDiffIdx[--ti]);
	}

	{
		b1<Hdl,kmm> VarHdls(3*ProteinSize);
		b1<Wrp,kmm> ValWrps(3*ProteinSize);
		for(Idx tIdx = 0; tIdx < ProteinSize; ++tIdx)
		{
			VarHdls[tIdx * 3 + 0] = Xvars[tIdx].TermHdl;
			VarHdls[tIdx * 3 + 1] = Yvars[tIdx].TermHdl;
			VarHdls[tIdx * 3 + 2] = Zvars[tIdx].TermHdl;

			ValWrps[tIdx * 3 + 0] = Wrp(Points[tIdx].x);
			ValWrps[tIdx * 3 + 1] = Wrp(Points[tIdx].y);
			ValWrps[tIdx * 3 + 2] = Wrp(Points[tIdx].z);
		}
		tSys.initialiseVarsWrap(VarHdls.items(), ValWrps.items());
	}

	Refm(tEtop, SumXiFeVi, tSys.SysHdl, Etop.TermHdl);
	Refm(tFhtop, SumXiFeVi, tSys.SysHdl, Fhtop.TermHdl);
	Refm(tFhptop, SumXiFeVi, tSys.SysHdl, Fhptop.TermHdl);

	#if CompLazyHalf
	tEtop.require(true);
	#endif

	QcSv2Tabu const & tQcSv2Tabu = QcSv2Tabu::refc(tSys.SysHdl);

	Int BestEnergy = tEtop.ValueRec().CurrData();
	while(tSys.ExecClk() < MaxIteration)
	{
		Int MinFitness = MaxInt;
		Idx MinPointIdx = InvIdx;
		Point tMinPointValue;
		for(Idx tIdx1 = 0; tIdx1 < ProteinSize; ++tIdx1)
		{
			if (tQcSv2Tabu.state(Xvars[tIdx1].TermHdl) ||
					tQcSv2Tabu.state(Yvars[tIdx1].TermHdl) ||
					tQcSv2Tabu.state(Zvars[tIdx1].TermHdl))
				continue;
			Idx kl = tIdx1 == 0 ? tIdx1 + 1: tIdx1 - 1;
			Idx kr = tIdx1 == (ProteinSize - 1)  ? tIdx1 - 1: tIdx1 + 1;

			Hdl AsgnVars[3] = { Xvars[tIdx1].TermHdl, Yvars[tIdx1].TermHdl, Zvars[tIdx1].TermHdl };
			#if SimulFixedFlexi
				#if SelcSimulFlexi
				tSys.setSimulFlexiVars(AsgnVars, 3);
				#else
				tSys.setSimulFixedVars(AsgnVars, 3);
				#endif
			#elif SimulFixedOnly
			tSys.setSimulFixedVars(AsgnVars, 3);
			#elif SimulFlexiOnly
			tSys.setSimulFlexiVars(AsgnVars, 3);
			#endif

			for(Idx tIdx2 = 0; tIdx2 < 12; ++tIdx2)
			{
				Point tPoint = { castInt(XvarRecs[kl]->CurrData() + vx[tIdx2]),
									castInt(YvarRecs[kl]->CurrData() + vy[tIdx2]),
									castInt(ZvarRecs[kl]->CurrData() + vz[tIdx2]) };

				if (AllDiff.findBll(tPoint)) continue;
				if (!checkNeighbour(tPoint.x,tPoint.y,tPoint.z,XvarRecs[kr]->CurrData(),
					YvarRecs[kr]->CurrData(),ZvarRecs[kr]->CurrData())) continue;

				tSys.setSimulMode(DiffAsgn);
				XvarPtrs[tIdx1]->simulIncrValue(tPoint.x);
				YvarPtrs[tIdx1]->simulIncrValue(tPoint.y);
				ZvarPtrs[tIdx1]->simulIncrValue(tPoint.z);
				tSys.setSimulMode(DiffProp);
				#if SimulUpwd
				tSys.propagateSimulIncr();
				#endif
				if (tSys.ExecClk() % FitnessRatio != 0)
				{
					#if SimulDnwd
					Term::performSimulIncr(tFhtop);
					#endif
					if (MinFitness > tFhtop.ValueRec().CurrData())
					{
						MinFitness = tFhtop.ValueRec().CurrData();
						MinPointIdx = tIdx1;
						tMinPointValue = tPoint;
					}
				}
				else
				{
					#if SimulDnwd
					Term::performSimulIncr(tFhptop);
					#endif
					if (MinFitness > tFhptop.ValueRec().CurrData())
					{
						MinFitness = tFhptop.ValueRec().CurrData();
						MinPointIdx = tIdx1;
						tMinPointValue = tPoint;
					}
				}
			}
		}
		if (MinPointIdx != InvIdx)
		{
			Hdl AsgnVars[3] = { Xvars[MinPointIdx].TermHdl, Yvars[MinPointIdx].TermHdl, Zvars[MinPointIdx].TermHdl };
			Wrp AsgnVals[3] = { Wrp(tMinPointValue.x), Wrp(tMinPointValue.y), Wrp(tMinPointValue.z) };
			tSys.execIncrDiffVarsWrap(AsgnVars, AsgnVals, 3);
		}
	}

	cout << BestEnergy << " " << tSys.ExecClk() << " " << getTime() << " " << getMemory() << endl;
	cout << TabuLength;
	cout << " " << theRnd.Seed() << endl;

	return ExitOnSuccess;
}
예제 #6
0
파일: wmca.cpp 프로젝트: swakkhar/kangaroo
/*!
	@brief A function to solve wireless mesh channel allocation problem.
	@details This function solves  wireless mesh channel allocation problem.
*/
int WMCA(int ArgC, char * ArgV[])
{
	if (ArgC <= 2)
	{
		cerr << endl;
		cout << "Wireless Mesh Channel Allocation Problem" << endl << endl;
		cerr << "Usage:" << endl;
		cerr << ArgV[0] << " -n Radios -k Channels -i MaxIter [-t TabuLength -s RandomSeed]" << endl << endl;
		cerr << "Input:" << endl;
		cerr << "NodeCount LinkCount ConflictCount" << endl << endl;
		cerr << "First in each line, ZeroBasedIndex LinkStartNode LinkEndNode" << endl;
		cerr << "Next in each line, ZeroBasedIndex ConflictLink1 ConflictLink2" << endl << endl;
		cerr << "Output:" << endl;
		cerr << "BestViolation IterationCount Run-Time MemoryUsage" << endl;
		cerr << "TabuLength Interfaces Channels NodeCount LinkCount ConflictCount [BestInterference]" << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Dim RadioPerNode = 0;				//	Number of radio per node in the network.
	Dim ChannelPerRadio = 0;			//	Number of channels per radio at each node.
	Rnd theRnd;							//	Random number generator

	Dim TabuLength = 0;					//	Tabu length for constraint based local search.
	Dim MaxIteration = 0;				//	Maximum iteration for local search algorithm.

	Dim NodeCount = 0;					//	Number of nodes in the network.
	Dim LinkCount = 0;					//	Number of links between nodes in the network
	Dim ConflictCount = 0;				//	Number of link pairs that conflict with each other.

	for(Idx tIdx = 2; tIdx < castIdx(ArgC); ++tIdx)
	{
		if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'n')
			RadioPerNode = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'k')
			ChannelPerRadio = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'i')
			MaxIteration = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 't')
			TabuLength = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 's')
			theRnd.seed(parseN(ArgV[tIdx+1]));
	}

	if(!RadioPerNode || !ChannelPerRadio || !MaxIteration)
	{
		cerr << endl;
		cerr << "Error in commandline parameter/value. Run only with parameter " << ArgV[1] << " to see usage." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	std::ifstream fin(ArgV[2]);

	fin >> NodeCount;
	fin >> LinkCount;
	fin >> ConflictCount;

	if(!NodeCount || !LinkCount || !ConflictCount)
	{
		cerr << endl;
		cerr << "Error in input file." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	b1<t2<Idx,Idx>,xmm> Links;		//	The links each comprising a pair of nodes.
	b1<t2<Idx,Idx>,xmm > Conflicts;	//	The conflicts each comprising a pair of links.
	rl<b1<Idx,xmm>,xmm > NodeLinks;	//	The links incidients on a node in the network.

 	for(Idx tIdx = 0; tIdx < NodeCount; ++tIdx)
		NodeLinks.insertMem();

//	cout << NodeCount << " " << LinkCount << " " << ConflictCount << endl;

	for (Idx tIdx = 0; tIdx < LinkCount; ++tIdx)
	{
		Idx LinkIdx, FirstNode, SecondNode;
		fin >> LinkIdx >> FirstNode >> SecondNode;

		Warn(tIdx != LinkIdx, eIndexMismatch);
		Warn(FirstNode >= NodeCount, eInvalidIndex);
		Warn(SecondNode >= NodeCount, eInvalidIndex);

		Links.insertMem(t2<Idx,Idx>(FirstNode, SecondNode));
		NodeLinks[FirstNode].insertMem(LinkIdx);
		NodeLinks[SecondNode].insertMem(LinkIdx);
//		cout << LinkIdx << " " << FirstNode << " " << SecondNode << endl;
	}
	for (Idx tIdx = 0; tIdx < ConflictCount; ++tIdx)
	{
		Idx ConflictIdx, FirstLink, SecondLink;
		fin >> ConflictIdx >> FirstLink >> SecondLink;
		Warn(tIdx != ConflictIdx, eIndexMismatch);
		Warn(FirstLink >= LinkCount, eInvalidIndex);
		Warn(SecondLink >= LinkCount, eInvalidIndex);
		Conflicts.insertMem(t2<Idx,Idx>(FirstLink, SecondLink));
//		cout << ConflictIdx << " " << FirstLink << " " << SecondLink << endl;
	}

	Sys & tSys = Sys::refm(Sys::def());

	EvalTi::def(tSys.SysHdl);
	HintTi::def(tSys.SysHdl);
	QcSv2Tabu::def(tSys.SysHdl, TabuLength);

	b1<Prm,kmm> 		LinkVars(LinkCount);		//	Variable representing links.
	for (Idx LinkIdx = 0; LinkIdx < LinkCount; ++LinkIdx)
		LinkVars[LinkIdx] = Prm(Tv,StatRangeVarVi::def(tSys.SysHdl, 0, ChannelPerRadio - 1));

	b1<Prm,kmm> tNodeAtmosts(NodeCount);
	for(Idx NodeIdx = 0; NodeIdx < NodeCount; ++NodeIdx)
	{
		b1<Prm,kmm> tChannelTicks(ChannelPerRadio);
		for(Idx ChannIdx = 0; ChannIdx < ChannelPerRadio; ++ChannIdx)
		{
			b1<Prm,kmm> tInciLinkVars(NodeLinks[NodeIdx].itemCount());
			for(Idx LinkIdx = 0; LinkIdx < NodeLinks[NodeIdx].itemCount(); ++LinkIdx)
				tInciLinkVars[LinkIdx] = Prm(Tf, UeqsXiFeVi::def(Xv, tSys.SysHdl,
					LinkVars[NodeLinks[NodeIdx][LinkIdx]], UeqsXiFeVi::bind(ChannIdx)));
			tChannelTicks[ChannIdx] = Prm(Tf, OrsXiFeVi::def(Xv, tSys.SysHdl,
									tInciLinkVars.items(), tInciLinkVars.itemCount()));
		}
		tNodeAtmosts[NodeIdx] = Prm(Tf, UleuXiFcMi::def(Xv, tSys.SysHdl,
					Prm(Tf, SumXiFeVi::def(Xv, tSys.SysHdl, tChannelTicks.items(), ChannelPerRadio)),
					UleuXiFcMi::bind(RadioPerNode)), MasM | MasEn);
	}

	Prm SatisfyTop = Prm(Tf,SumXiEFcMiHn::def(Xm|En, tSys.SysHdl, tNodeAtmosts.items(), tNodeAtmosts.itemCount()), MasM|HnAsHn|RoHn);

	b1<Prm,kmm>			ConflictTests(ConflictCount);	// 	Result for each given conflicting pair of links.
	for(Idx ConflIdx = 0; ConflIdx < ConflictCount; ++ConflIdx)
	{
		Idx FirstLink = Conflicts[ConflIdx].First;
		Idx SecondLink = Conflicts[ConflIdx].Second;

		ConflictTests[ConflIdx] = Prm(Tf, BeqsXiFcMi::def(Xv, tSys.SysHdl, LinkVars[FirstLink], LinkVars[SecondLink]), MasM|MasEn);
	}
	Prm MinimiseTop = Prm(Tf, SumXiEFcMiHn::def(Xm|En, tSys.SysHdl, ConflictTests.items(), ConflictTests.itemCount()), MasM|HnAsHn);

	Prm Tops[2] = {SatisfyTop, MinimiseTop};

	Prm CombinedTop = Prm(Tf, SumXiFcMi::def(Xm, tSys.SysHdl, Tops, 2));
//	Prm CombinedTop = Prm(Tf, SumXiHFcMiHn::def(Xm|Hn, tSys.SysHdl, Tops, 2), MasM|HnAsHn|RoHn);

	Prm SatisfyHeap = Prm(Tf, Sv2TabuMaxHeapHiFrHi::def(tSys.SysHdl, SatisfyTop));
	Hdl SatisfyVarSelc = RankedHintVar1Sp::def(tSys.SysHdl, SatisfyHeap);
	Hdl SatisfyValSelc = MinVal1StatRangeSdViZi::def(Zm, tSys.SysHdl, SatisfyTop);

	Prm MinimiseHeap = Prm(Tf, Sv2TabuMaxHeapHiFrHi::def(tSys.SysHdl, MinimiseTop));
	Hdl MinimiseVarSelc = RankedHintVar1Sp::def(tSys.SysHdl, MinimiseHeap);
	Hdl CombinedValSelc = MinVal1StatRangeSdViZi::def(Zm, tSys.SysHdl, CombinedTop);

	tSys.initialiseVarsStatRand(theRnd);

	Refm(tSatisfyTop, SumXiEFcMiHn, tSys.SysHdl, SatisfyTop.TermHdl);
	Refm(tMinimiseTop, SumXiEFcMiHn, tSys.SysHdl, MinimiseTop.TermHdl);
//	Refm(tCombinedTop, SumXiFcMi, tSys.SysHdl, CombinedTop.TermHdl);

	#if CompLazyHalf
	tSatisfyTop.require(true);
	#endif

	Int BestSat = tSatisfyTop.MetricRec().CurrData();
	Int BestOpt = (BestSat) ? MaxInt : tMinimiseTop.MetricRec().CurrData();

	while(tSys.ExecClk() < MaxIteration && BestOpt > 0)
	{
		#if CompLazyFull
		Term::performExecIncr(tSatisfyTop);
		#endif
		if (tSatisfyTop.MetricRec().CurrData() == 0)
		{
			#if CompLazy
			Term::performExecIncr(tMinimiseTop);
			#endif
			if (BestOpt > tMinimiseTop.MetricRec().CurrData())
				BestOpt = tMinimiseTop.MetricRec().CurrData();
			Selc::selectExecuteSelc2(tSys.SysHdl, MinimiseVarSelc, CombinedValSelc, theRnd);
		}
		else
		{
			Selc::selectExecuteSelc2(tSys.SysHdl, SatisfyVarSelc, SatisfyValSelc, theRnd);
		}
		if (tSatisfyTop.MetricRec().CurrData() < BestSat)
			BestSat = tSatisfyTop.MetricRec().CurrData();
	}

	cout << BestSat << " " << tSys.ExecClk() << " " << getTime() << " " << getMemory() << endl;
	cout << TabuLength << " " << RadioPerNode << " " << ChannelPerRadio << " " << NodeCount << " " << LinkCount << " " << ConflictCount;
	if (!BestSat)
		cout << " " << BestOpt;
	cout << " " << theRnd.Seed() << endl;

	return ExitOnSuccess;
}
예제 #7
0
openPlatypusSpace



/*!
	The constructor
*/
ContactOrderObj::ContactOrderObj(Conf const & theConf, B const NeedHint) :
		Function(theConf.SysHdl(), NeedHint)
{
	WatchError


	Warn(!(Energy::e().ModelId() != EnergyCls<HpEnergy>::ModelId ||
      Energy::e().ModelId() != EnergyCls<MjEnergy>::ModelId ||
      Energy::e().ModelId() != EnergyCls<BarerraEnergy>::ModelId), eEnergyMismatch);

	Dim tDimen = Space::Dimen();
	Hdl tSysHdl = theConf.SysHdl();
	Dim tSpan = Protein::p().Span();
	Dim tLength = Protein::p().Length();
	block1<Prm,nmm> tResult(tSpan * tLength / 2);

	Int tSqrNeighDist = Lattice::l().SqrNeighDist();
	for(Pos tPos1 = 0; tPos1 < tSpan; ++tPos1)
	{
		//Typ tTyp1 = Protein::p().Type(tPos1);

		for(Pos tPos2 = tPos1 + 2; tPos2 < tLength; ++tPos2)
		{
			//Typ tTyp2 = Protein::p().Type(tPos2);

			//Eng tEng = Energy::e().Level(tTyp1, tTyp2);
            Pos tEng=tPos2-tPos1;
            //if(!tEng) continue;

            Prm tDiff[tDimen], tSqrd[tDimen];
			for(Cmp tCmp = 0; tCmp < tDimen; ++tCmp)
			{
				Prm tVar1 = Prm(TermVar,tPos1 * tDimen + tCmp);
				Prm tVar2 = Prm(TermVar,tPos2 * tDimen + tCmp);
				tDiff[tCmp] = Prm(TermFunc,BsubXiFeVi::def(Xv, tSysHdl, tVar1, tVar2));
				tSqrd[tCmp] = Prm(TermFunc,UsqrXiFeVi::def(Xv, tSysHdl, tDiff[tCmp]));
			}
			Prm tDist = Prm(TermFunc,SumXiFeVi::def(Xv, tSysHdl, tSqrd, tDimen));
			Prm tEqu = Prm(TermFunc,UequXiFcMi::def(Xv, tSysHdl, tDist, UequXiFcMi::bind(tSqrNeighDist)));
			tResult.insert(Prm(TermFunc,UifXiKiFcMi::def(Xm, tSysHdl, tEqu,
                                       UifXiKiFcMi::bind(castInt(0), tEng)),MetricAsEvalMin));
		}
	}
	if(NeedHint)
	{
        mFuncHdl = SumXiEFcMiHn::def(Xm | EvalMin, tSysHdl, tResult.items(), tResult.itemCount());
		mMetricRec = &SumXiEFcMiHn::refc(tSysHdl, mFuncHdl).MetricRec();
	}
	else
	{
        mFuncHdl = SumXiFcMi::def(Xm, tSysHdl, tResult.items(), tResult.itemCount());
        mMetricRec = &SumXiFcMi::refc(tSysHdl, mFuncHdl).MetricRec();
	}

	CatchError
}
예제 #8
0
파일: ekf.cpp 프로젝트: NBXApp/ekfslam
void EkfSlam::correct(Mat yi, Mat v, int i)
{
	if(!yi.rows)
		return;

	double x = mState.at<double>(0); // robot x
	double y = mState.at<double>(1); // robot y
	double theta = mState.at<double>(2); //robot theta

	Mat Li = (Mat_<double>(2,1) <<
		mState.at<double>(2*i+3),
		mState.at<double>(2*i+4)
	);

	//////////////////////////////////////////////////////////////
	// setup handy data for kalman correction

	Mat Hr = dh_dxb(mState(Rect(0,0,1,3)), Li);
	Mat Hl = dh_dLi(mState(Rect(0,0,1,3)), Li);

	Mat Hr_t = Hr.t();
	Mat Hl_t = Hl.t();

	Mat H;
	H.push_back(Hr_t);
	H.push_back(Hl_t);
	H = H.t();

	Mat s2 = s.clone();
	s2.at<double>(0) *= s2.at<double>(0);
	s2.at<double>(1) *= s2.at<double>(1);

	Mat R = Mat::diag(s2);

	/////////////////////////////////////////////////////////////
	// Kalman Correction
	Mat zbar = yi-h(mState(Rect(0,0,1,3)), Li);

	if(zbar.at<double>(1) > M_PI)
		zbar.at<double>(1) -= 2*M_PI;
	if(zbar.at<double>(1) < -M_PI)
		zbar.at<double>(1) += 2*M_PI;
	///////////////////////////////////////
	Mat Prl = Prm(Rect(2*i,0,2,3)).clone();
	Mat Plr = Pmr(Rect(0,2*i,3,2)).clone();
	Mat Pll = Pmm(Rect(2*i,2*i,2,2)).clone();

	Mat Pl;
	Mat pTemp1, pTemp2;
	Pl = Prr.t();
	pTemp1 = Prl.t();
	Pl.push_back(pTemp1);
	Pl = Pl.t();

	pTemp1 = Plr.t();
	pTemp2 = Pll.t();
	pTemp1.push_back(pTemp2);
	pTemp1 = pTemp1.t();
	Pl.push_back(pTemp1);
	///////////////////////////////////////
	Mat Z = H*Pl*H.t()+R;

	Mat t = zbar.t()*Z.inv()*zbar;

	// update map cov
	// In large maps with small uncertainties you may want to limit
	// the updates to within a certain range of uncertainty with an
	// if statement around this next block of code.
//	if(t.at<double>(0) < 9) {
		Mat P = Prr.t();
		P.push_back(Plr);
		P = P.t();
		Mat t2 = Prm.clone();
		Mat Plm = Pmm(Rect(0,2*i,Pmm.cols,2)).clone();
		t2.push_back(Plm);
		t2 = t2.t();
		P.push_back(t2);

		Mat K = P*H.t()*Z.inv();
		mState += K*zbar;
		Mat Pmod = K*Z*K.t();
		Prr -= Pmod(Rect(0,0,3,3));
		Prm -= Pmod(Rect(3,0,Pmod.cols-3,3));
		//Pmr = Prm.t();
		Pmr -= Pmod(Rect(0,3,3,Pmod.rows-3));
		Pmm -= Pmod(Rect(3,3,Pmod.cols-3,Pmod.rows-3));
//	}
}
예제 #9
0
/*!
	@fn int GColor(int ArgC, char * ArgV[])
*/
int GColor(int ArgC, char * ArgV[])
{
	if (ArgC <= 2)
	{
		cerr << endl << endl;
		cerr << "Graph Coloring Problem" << endl << endl;
		cerr << "Usage:" << endl;
		cerr << ArgV[0] << " " << ArgV[1] << " -i MaxIter [-t TabuLength -s RandomSeed]" << endl << endl;
		cerr << "Input:" << endl;
		cerr << "NumColor EdgeProbability NumVertex, NumEdge EdgeVertexPairs" << endl << endl;
		cerr << "Output:" << endl;
		cerr << "BestViolation Iteration Time" << endl;
		cerr << "MemoryUsedByTheProgram" << endl;
		cerr << "TabuLength NumColor EdgeProbability NumVertex, NumEdge EdgeVertexPairs"
					"[VertexColors] RandomSeed" << endl;
		cerr << endl << endl;
		return ExitOnFailure;
	}

	Dim T = 0;	//	Tabu size
	Itn I = 0;	//	Max iteration
	Rnd theRnd;

	for(Idx tIdx = 2; tIdx < castIdx(ArgC); ++tIdx)
	{
		if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 't')
			T = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 'i')
			I = parseN(ArgV[tIdx+1]);
		else if (ArgV[tIdx][0] == '-' && ArgV[tIdx][1] == 's')
			theRnd.seed(parseN(ArgV[tIdx+1]));
	}

	if(!I)
	{
		cerr << endl;
		cerr << "Error in commandline parameter/value. Run only with parameter " << ArgV[1] << " to see usage." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Dim L; cin >> L;				// 	Num color
	Flt P; cin >> P;				// 	Edge probability
	Dim V; cin >> V;				//	Num vertex
	Dim E; cin >> E;				//	Num edges
	b1<Int, kmm> Start(E), End(E);	//	Edges

	for(Idx tIdx = 0; tIdx < E; ++tIdx)
	{
		Int tInt;
		cin >> tInt;
		Start[tIdx] = tInt - 1;		//	zero based numbering
		cin >> tInt;
		End[tIdx] = tInt - 1;		//	zero based numbering
	}

	if (!L || eq<Flt>::iof(P,0) || !V || !E)
	{
		cerr << endl;
		cerr << "Error in input values." << endl;
		cerr << endl;
		return ExitOnFailure;
	}

	Sys & tSys = Sys::refm(Sys::def());

	EvalTi::def(tSys.SysHdl);
	HintTi::def(tSys.SysHdl);

	QcSv2Tabu::def(tSys.SysHdl, T);


	b1<Prm, kmm> tColors(V), tNotEquals(E);

	for(Idx tIdx = 0; tIdx < V; ++tIdx)
		tColors[tIdx] = Prm(Tv, StatRangeVarVi::def(tSys.SysHdl , 1, L));

	for(Idx tIdx = 0; tIdx < E; ++tIdx)
 		tNotEquals[tIdx] = Prm(Tf, BneuXiFcMi::def(Xv, tSys.SysHdl, tColors[Start[tIdx]], tColors[End[tIdx]]), MasM | MasEn);

	Prm TopSum = Prm(Tf, SumXiEFcMiHn::def(Xm | En, tSys.SysHdl, tNotEquals.items(), tNotEquals.itemCount()));

	Prm HintHeap = Prm(Tf, Sv2TabuMaxHeapHiFrHi::def(tSys.SysHdl, TopSum));

	Hdl const VarSelcHdl = RankedHintVar1Sp::def( tSys.SysHdl, HintHeap);
	Hdl const ValSelcHdl = MinVal1StatRangeSdViZi::def( Zm, tSys.SysHdl, TopSum);
	MinVal1StatRangeSdViZi::refm(tSys.SysHdl, ValSelcHdl).includeCurrValue(false);

	Refc(tTopSum, SumXiEFcMiHn, tSys.SysHdl, TopSum.TermHdl);

	tSys.initialiseVarsStatRand(theRnd);

	#if CompLazyHalf
	Selc::refm(tSys.SysHdl, VarSelcHdl).activate(true);
	Selc::refm(tSys.SysHdl, ValSelcHdl).activate(true);
	#endif

	Int BestMetric = tTopSum.MetricRec().CurrData();
	while(tSys.ExecClk() < I && BestMetric > 0)
	{
		Selc::selectExecuteSelc2(tSys.SysHdl, VarSelcHdl, ValSelcHdl, theRnd);
		#if CompLazyFull
		Term::performExecIncr(Func::ptrm(tSys.SysHdl, TopSum.TermHdl));
		#endif
		if (tTopSum.MetricRec().CurrData() < BestMetric)
			BestMetric = tTopSum.MetricRec().CurrData();
	}

	cout << BestMetric << " " << tSys.ExecClk() << " " << getTime() << " " << getMemory() << endl;
	cout << T << " " << L << " " << P << " " << V << " "<< E;
	for(Idx tIdx = 0; tIdx < E; ++tIdx)
		cout << " " << Start[tIdx] + 1 << " " << End[tIdx] + 1;

	if (!BestMetric)
	{
		for(Idx tIdx = 0; tIdx < V; ++tIdx)
			cout << " " << StatRangeVarVi::refc(tSys.SysHdl, tColors[tIdx].TermHdl).CurrValue();
	}
	cout << " " << theRnd.Seed() << endl;
	return ExitOnSuccess;
}