コード例 #1
0
// Constructor with estimate and time.
HomogeneousPointParameterBlock::HomogeneousPointParameterBlock(
    const Eigen::Vector3d& point, uint64_t id, bool initialized) {
  setEstimate(Eigen::Vector4d(point[0], point[1], point[2], 1.0));
  setId(id);
  setInitialized(initialized);
  setFixed(false);
}
コード例 #2
0
ファイル: Collectable.cpp プロジェクト: wooffull/CollectEmUp
Collectable::Collectable( vec3 position, vec3 scale )
{
    ModelImporter modelImporter;
    setModel( modelImporter.loadModel( "Models/bolt.obj", "Models/Textures/nut_texture2.jpg" ) );

    setPosition( position );
    setScale( scale );
    setFixed( true );

    setGameObjType( "Collectable" );
}
コード例 #3
0
void AnchoredRectangleHandlerBootstrap::fixImmutableFeaturePoses(
    const Eigen::VectorXd &pose, double percentageThreshold,
    double minZDistance) {
  map<double, unsigned int> candidates;

  for (auto& feature : _objects) {
    auto& map = feature.second.zHistory;
    voteFixedPoseCandidates(candidates, map, minZDistance);
  }

  for (auto& candidate : candidates) {
    double percentage = static_cast<double>(candidate.second)
        / static_cast<double>(_objects.size());

    if (percentage >= percentageThreshold) {
      auto pose_ptr = _filter->getNearestPoseByTimestamp(candidate.first);
      pose_ptr->setEstimate(pose);
      pose_ptr->setFixed(true);
    }
  }

}
コード例 #4
0
//
//   Assign facets
//        assign common facets
//        assign additional facet
//
void AbstractNumericFacetValidator::assignFacet(MemoryManager* const manager)
{

    RefHashTableOf<KVStringPair>* facets = getFacets();

    if (!facets)     // no facets defined
        return;

    XMLCh* key;

    RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager);

    while (e.hasMoreElements())
    {
        KVStringPair pair = e.nextElement();
        key = pair.getKey();
        XMLCh* value = pair.getValue();

        if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
        {
            setPattern(value);
            if (getPattern())
                setFacetsDefined(DatatypeValidator::FACET_PATTERN);
            // do not construct regex until needed
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXINCLUSIVE))
        {
            try
            {
                setMaxInclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxIncl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MAXINCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXEXCLUSIVE))
        {
            try
            {
                setMaxExclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MaxExcl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MAXEXCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MININCLUSIVE))
        {
            try
            {
                setMinInclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinIncl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MININCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MINEXCLUSIVE))
        {
            try
            {
                setMinExclusive(value);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_MinExcl, value, manager);
            }
            setFacetsDefined(DatatypeValidator::FACET_MINEXCLUSIVE);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgATT_FIXED))
        {
            unsigned int val;
            bool         retStatus;
            try
            {
                retStatus = XMLString::textToBin(value, val, fMemoryManager);
            }
            catch (RuntimeException&)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            if (!retStatus)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            setFixed(val);
            //no setFacetsDefined here

        }
        else
        {
            assignAdditionalFacet(key, value, manager);
        }

    }//while

}// end of assigneFacet()
コード例 #5
0
// Default constructor (assumes not fixed).
HomogeneousPointParameterBlock::HomogeneousPointParameterBlock()
    : base_t::ParameterBlockSized(),
      initialized_(false) {
  setFixed(false);
}
コード例 #6
0
//
//   Assign facets
//        assign common facets
//        assign additional facet
//
void AbstractStringValidator::assignFacet(MemoryManager* const manager)
{

    RefHashTableOf<KVStringPair>* facets = getFacets();

    if (!facets)
        return;

    XMLCh* key;
    RefHashTableOfEnumerator<KVStringPair> e(facets, false, manager);

    while (e.hasMoreElements())
    {
        KVStringPair pair = e.nextElement();
        key = pair.getKey();
        XMLCh* value = pair.getValue();

        if (XMLString::equals(key, SchemaSymbols::fgELT_LENGTH))
        {
            int val;
            try
            {
                val = XMLString::parseInt(value, manager);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_Len, value, manager);
            }

            if ( val < 0 )
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_Len, value, manager);

            setLength(val);
            setFacetsDefined(DatatypeValidator::FACET_LENGTH);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MINLENGTH))
        {
            int val;
            try
            {
                val = XMLString::parseInt(value, manager);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_minLen, value, manager);
            }

            if ( val < 0 )
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_minLen, value, manager);

            setMinLength(val);
            setFacetsDefined(DatatypeValidator::FACET_MINLENGTH);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_MAXLENGTH))
        {
            int val;
            try
            {
                val = XMLString::parseInt(value, manager);
            }
            catch (NumberFormatException&)
            {
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_Invalid_maxLen, value, manager);
            }

            if ( val < 0 )
                ThrowXMLwithMemMgr1(InvalidDatatypeFacetException, XMLExcepts::FACET_NonNeg_maxLen, value, manager);

            setMaxLength(val);
            setFacetsDefined(DatatypeValidator::FACET_MAXLENGTH);
        }
        else if (XMLString::equals(key, SchemaSymbols::fgELT_PATTERN))
        {
            setPattern(value);
            if (getPattern())
                setFacetsDefined(DatatypeValidator::FACET_PATTERN);
            // do not construct regex until needed
        }
        else if (XMLString::equals(key, SchemaSymbols::fgATT_FIXED))
        {
            unsigned int val;
            bool         retStatus;
            try
            {
                retStatus = XMLString::textToBin(value, val, fMemoryManager);
            }
            catch (RuntimeException&)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            if (!retStatus)
            {
                ThrowXMLwithMemMgr(InvalidDatatypeFacetException, XMLExcepts::FACET_internalError_fixed, manager);
            }

            setFixed(val);
            //no setFacetsDefined here
        }
        //
        // else if (XMLString::equals(key, SchemaSymbols::fgELT_SPECIAL_TOKEN))
        // TODO
        //
        // Note: whitespace is taken care of by TraverseSchema.
        //
        else
        {
            assignAdditionalFacet(key, value, manager);
        }
    }//while
}//end of assigneFacet()
コード例 #7
0
double compareSteadyStates(GAindividual p, double ** table, int rows, int inputs, int outputs, int corr, double ** res)
{
	int i, j, m, k, g, cols, n, *best;
	double * ss, * iv, closest, temp, sumOfSq, corrcoef, *mXY, *mX, *mY, *mX2, *mY2, oldMaxT = SS_FUNC_MAX_TIME;
	double * ss2;
	double a,b,c;
	ReactionNetwork * r = (ReactionNetwork*)(p);

	SS_FUNC_MAX_TIME = 100.0;

	cols = inputs + outputs;

	n = getNumSpecies(r);

	if (n < cols) return 0.0; // not enough species

	for (i=0; i < inputs; ++i)
	{
		setFixed(r,i,1);
	}

	sumOfSq = 0.0;
	corrcoef = 0.0;
	iv = (double*) malloc( n * sizeof(double) );
	for (i=0; i < n; ++i)
		iv[i] = r->initialValues[i];

	best = (int*) malloc ( outputs * sizeof(int) );
	mX = (double*)malloc( outputs * sizeof(double) );
	mY = (double*)malloc( outputs * sizeof(double) );
	mXY = (double*)malloc( outputs * sizeof(double) );
	mX2 = (double*)malloc( outputs * sizeof(double) );
	mY2 = (double*)malloc( outputs * sizeof(double) );

	for (i=0; i < outputs; ++i)
	{
		best[i] = -1;
		mXY[i] = mX[i] = mY[i] = mX2[i] = mY2[i] = 0;
	}

	ss2 = (double*)malloc(rows*sizeof(double));

	for (m=0; m < rows; ++m)
	{
		for (i=0; i < inputs; ++i)
			r->initialValues[i] = table[m][i];

		for (i=inputs; i < n; ++i)
			r->initialValues[i] = 0.0;

		ss = networkSteadyState(r);

		if (ss) //error in simulation?
		{
			if (res)
			{
				for (i=0; i < inputs; ++i)
					res[m][i] = ss[i];
			}
			for (i=0; i < outputs; ++i) //for each target output
			{
				if (best[i] < 0)
				{
					closest = -1.0;
					for (j=inputs; j < n; ++j) //find best match
					{
						g = 0;
						for (k=0; k < outputs; ++k)
							if (best[k] == j)
							{
								g = 1;
								break;
							}
						if (g) continue;
						temp = (ss[j] - table[m][inputs+i]);
						if ((closest < 0.0) || ((temp*temp) < closest))
						{
							closest = temp*temp;
							best[i] = j;
						}
					}
				}

				j = i+inputs;

				if (res)
				{
					res[m][inputs+i] = ss[j];

				}
				ss2[m] = ss[j];

				temp = (ss[j] - table[m][inputs+i]);
				closest = temp*temp;

				sumOfSq += closest;
				mX[i] += ss[j];
				mY[i] += table[m][inputs+i];
				mXY[i] += table[m][inputs+i] * ss[j];
				mX2[i] += ss[j]*ss[j];
				mY2[i] += table[m][inputs+i]*table[m][inputs+i];

				if (closest < 0.0)
				{
					sumOfSq = -1.0;
					break;
				}
			}

			free(ss);
		}
		else
		{
			sumOfSq = -1.0;
			break;
		}
	}

	corrcoef = 0.0;
	for (i=0; i < outputs; ++i)
	{
		mX[i] /= rows;
		mY[i] /= rows;
		mXY[i] /= rows;
		mX2[i] /= rows;
		mY2[i] /= rows;

		if ( (mX2[i] - mX[i]*mX[i]) <= 0.0 || (mY2[i] - mY[i]*mY[i]) <= 0.0 )
		{
			sumOfSq = -1.0;
			break;
		}

		a = mXY[i] - mX[i]*mY[i];
		b = mX2[i] - mX[i]*mX[i];
		c = mY2[i] - mY[i]*mY[i];

		if (a > 1.0 && b > 1.0 && c > 1.0)
		{
			temp =  a/( sqrt(b)*sqrt(c));   //correlation formula
			corrcoef = temp*temp; //between 0 and 1
		}
		else
		{
			corrcoef = 0.0;
			sumOfSq = 0.0;
		}

		if (corrcoef > 0.9)
		{
			temp = temp + 0.0;
		}
	}

	free(ss2);

	for (i=0; i < n; ++i)
		r->initialValues[i] = iv[i];

	free(iv);
	free(mX);
	free(mY);
	free(mXY);
	free(mX2);
	free(mY2);

	//restore the fixed
	for (i=0; i < inputs; ++i)
	{
		setFixed(r,i,0);
	}

	SS_FUNC_MAX_TIME = oldMaxT;

	if (sumOfSq <= 0.0) return 0.0;

	if (corr) return corrcoef;
	return (1.0 / (1.0 + sumOfSq));
}