Ejemplo n.º 1
0
void ChronoDrawTree::DrawTimeScale(ostream& os, double xscale, double yscale)	{

	// x = 0: root
	// sizeX = age of root
	double rootmaxage = GetMaxTime();
	// double rootmaxage = GetMaxTime(GetRoot());
	// cerr << sizeX << '\t' << xscale * rootage << '\n';
	// int ntics = (int) (rootage / 10);

	double step = 10;

	double y = -0.04 * sizeY;
	double dy= 0.006 * sizeY;
	os << "\\path [draw] (" << sizeX - xscale * (rootmaxage+step)  << "," << y << ") -- (" << sizeX << "," << y << ");\n";
	int tic = 0;
	for (double age=0; age<rootmaxage+step; age += step)	{
		double x = sizeX - xscale * age;
	// for (int tic=0; tic<ntics; tic++)	{
		// double x = sizeX * (1 - ((double) tic) / ntics);
		os << "\\path [draw] (" << x << "," << y + dy << ") -- +(0," << -2 *dy << ");\n";

		if (! (tic % 5))	{
			os << "\\path (" << x << "," << -8 *dy << ") node[below,font=\\fontsize{" << groupfontsize << "}{" << groupfontsize << "}\\selectfont] {" << tic * 10 << "};\n";
		}
		tic ++;
	}
	os << "\\path (" << sizeX + 0.4 << "," << -8 *dy << ") node[below,font=\\fontsize{" << groupfontsize << "}{" << groupfontsize << "}\\selectfont] {Myr};\n";

	// KT
	// double rootage = GetDepth();
	// double rootage = GetDepth(GetRoot());
	// os << "\\path[draw,dashed,thin] (" << sizeX * (rootage - 65.0) / rootage << "," << y << ")-- +(0," << sizeY - y << ");\n";
	// os << "\\path (" << sizeX * (rootage - 65.0) / rootage << "," <<  - 8*dy << ") node[below,font=\\fontsize{" << groupfontsize << "}{" << groupfontsize << "}\\selectfont] {\\bf KPg};\n";
}
Ejemplo n.º 2
0
void clTrajectoryPositioner::Update( float dt )
{
	/// Update time counter if required
	if ( FUpdateTime ) { FLocalTime += FSpeedFactor * dt; }

	if ( !FTrajectory ) { return; }

	float MaxT = GetMaxTime();
	float MinT = GetMinTime();

	if ( FTrajectory->FLoop )
	{
		while ( FLocalTime > MaxT )
		{
			FLocalTime -= ( MaxT - MinT );
		}

		while ( FLocalTime < MinT )
		{
			FLocalTime += ( MaxT - MinT );
		}
	}
	else
	{
		FLocalTime = Math::Clamp( FLocalTime, MinT, MaxT );
	}

	LVector3 Pos = FTrajectory->GetPositionForTime( FLocalTime );

	LQuaternion Q = FTrackTarget ?
	                LQuaternion( Math::LookAt( Pos, FStaticTarget, FUpVector ).ExtractMatrix3() ) :
	                FTrajectory->GetOrientationForTime( FLocalTime );

	FCurrentTransform = ComposeCameraTransformation( Pos, LMatrix4( Q.ToMatrix3() ) );
}
void CSamplingInfEngine::Continue( int dt )
{
    PNL_CHECK_LEFT_BORDER( dt, 0);
    
    int startTime = GetMaxTime();
    PNL_CHECK_LEFT_BORDER( startTime, 0);
    
    int endTime = startTime + dt;
    SetMaxTime(endTime);
    Sampling( startTime, endTime );
}
void CGibbsSamplingInfEngine::
EnterEvidence( const CEvidence *pEvidenceIn, int maximize, int sumOnMixtureNode )
{
  if( !m_queryes.size() )
  {
    PNL_THROW( CAlgorithmicException, "Possible queryes must be defined");
  }
  
  PNL_CHECK_IS_NULL_POINTER(pEvidenceIn);
  m_pEvidence = pEvidenceIn;
  m_bMaximize = maximize;
  
  DestroyCurrentEvidences();
  DestroyQueryFactors();
  
  
  if(GetModel()->GetModelType() == mtBNet)
  {
    static_cast< const CBNet* >(GetModel())->
      GenerateSamples( GetCurrentEvidences(), GetNumStreams(), pEvidenceIn );
  }
  else
  {
    static_cast< const CMNet* >(GetModel())->
      GenerateSamples( GetCurrentEvidences(), GetNumStreams(), pEvidenceIn );
    
  }
  
  CreateQueryFactors();
  
  boolVector sampleIsNeed;
  if( m_bUsingDSep )
  {
    ConsDSep( m_queryes, &sampleIsNeed, m_pEvidence );
  }
  else
  {
    FindCurrentNdsForSampling( &sampleIsNeed );
  }
  SetSamplingNdsFlags(sampleIsNeed);
  
  Sampling( 0, GetMaxTime() );
}
Ejemplo n.º 5
0
void COpenLock::ResetLockInfo()
{
	Open_lockCfg* lockCfg = OpenLockData.get(GetLockId());
	if(!lockCfg) return;

	int randRange = abs(lockCfg->random_min)+lockCfg->random_max;
	srand (time(NULL));
	m_openDegreeMin = rand()%randRange + 1;
	if(m_openDegreeMin>lockCfg->random_max)
	{
		m_openDegreeMin = lockCfg->random_max - m_openDegreeMin;
	}
	m_openDegreeMax = m_openDegreeMin + lockCfg->section;
	m_openDegreeMiddle = (m_openDegreeMin+m_openDegreeMax)/2;

	SetMaxTime(lockCfg->max_time);
	SetLeftTime(lockCfg->max_time);
	unschedule(SEL_SCHEDULE(&COpenLock::ScheduleLeftTime));
	schedule(SEL_SCHEDULE(&COpenLock::ScheduleLeftTime),1.0f,GetMaxTime()+1,0.0f);
}
Ejemplo n.º 6
0
void ChronoDrawTree::DrawTimeInterval(const Link* link, ostream& os, double x, double y, double xscale, double yscale)	{
	if (! link->Out()->isLeaf())	{
		if ((! onlygroups) || (groupname[link->Out()->GetNode()] != ""))	{
			if (link->isRoot())	{
				// cerr << GetDepth(GetRoot()) << '\t' << GetMinTime(GetRoot()) << '\t' << GetMaxTime(GetRoot()) << '\n';
			}
			double tmin = xscale * (GetDepth() - GetMinTime(link->Out()));
			double tmax = xscale * (GetDepth() - GetMaxTime(link->Out()));
			/*
			double tmin = xscale * (GetDepth(GetRoot()) - GetMinTime(link->Out()));
			double tmax = xscale * (GetDepth(GetRoot()) - GetMaxTime(link->Out()));
			*/
			double offset = 0.5 * barwidth;
			/*
			int color = 0;
			if (onlygroups)	{
				color = groupcolor[link->Out()->GetNode()];
			}
			*/
			int color = groupcolor[link->Out()->GetNode()];
			if (color == 0)	{
				os << "\\path [fill=blue,opacity=0.5,anchor=center] (" << texapprox(tmin) << ',' << texapprox(y-offset) << ") rectangle (" << texapprox(tmax) << ',' << texapprox(y+offset)  << ");\n";
			}
			else if (color == 1)	{
				offset *= 1.5;
				os << "\\path [fill=blue,opacity=0.6,anchor=center] (" << texapprox(tmin) << ',' << texapprox(y-offset) << ") rectangle (" << texapprox(tmax) << ',' << texapprox(y+offset)  << ");\n";
			}
			else if (color == 2)	{
				offset *= 1.5;
				os << "\\path [fill=orange,opacity=0.6,anchor=center] (" << texapprox(tmin) << ',' << texapprox(y-offset) << ") rectangle (" << texapprox(tmax) << ',' << texapprox(y+offset)  << ");\n";
			}
			else if (color == 3)	{
				offset *= 1.5;
				os << "\\path [fill=red,opacity=0.6,anchor=center] (" << texapprox(tmin) << ',' << texapprox(y-offset) << ") rectangle (" << texapprox(tmax) << ',' << texapprox(y+offset)  << ");\n";
			}
		}
	}
}
FText FBPProfilerStat::GetMaxTimeText() const
{
	return FText::AsNumber(GetMaxTime(), &SBlueprintProfilerView::GetNumberFormat());
}
Ejemplo n.º 8
0
double MIDASTimer::GetTimeToExpire () { //may be negative!
	if (GetMaxTime() == 0) return INFINITE_TIME;
	else return (GetMaxTime() - GetTime());
}
Ejemplo n.º 9
0
bool MIDASTimer::IsTimeExpired () {
	if (GetMaxTime() == 0) return false;
	bool time_expired = (GetTime() >= GetMaxTime());
	return time_expired;
}
void CGibbsSamplingInfEngine::
MarginalNodes( const int *queryIn, int querySz, int notExpandJPD )
{
  delete m_pQueryJPD;
  m_pQueryJPD = NULL;
  
  delete m_pPotMPE;
  m_pPotMPE = NULL;
  
  delete m_pEvidenceMPE;
  m_pEvidenceMPE = NULL;
  
  const CFactor *pFactor;
  CPotential *pPot =  NULL;
  int *begin1;
  int *end1;
  int *begin2;
  int *end2;
  
  intVector domainVec;
  intVector queryVec;
  intVector obsQueryVec;
  queryVec.reserve(querySz);
  obsQueryVec.reserve(querySz);
  int i;
  for( i = 0; i < querySz; i++ )
  {
    m_pEvidence->IsNodeObserved(queryIn[i]) ? 
      obsQueryVec.push_back(queryIn[i]):
    queryVec.push_back(queryIn[i]);
  }
  
  
  CPotential *tmpPot = NULL;
  
  if( queryVec.size() )
  {
    for( i = 0; i < m_queryFactors.size(); i++)     
    {
      
      domainVec.clear();
      pFactor = m_queryFactors[i];
      pFactor->GetDomain(&domainVec);
      begin1 = &domainVec.front();
      end1 = &domainVec.back() + 1;
      std::sort(begin1, end1);
      
      begin2 = &queryVec.front();
      end2 = &queryVec.back() + 1;
      std::sort(begin2, end2);
      
      if( std::includes(begin1, end1, begin2, end2) )
      {
        pPot = pFactor->ConvertStatisticToPot( (GetMaxTime()-GetBurnIn()-1)*GetNumStreams() );
        tmpPot = pPot->Marginalize( queryVec );
        delete pPot;
        break;
      }
      		   
    }
    if( !tmpPot )
    {
      PNL_THROW(CInvalidOperation, "Invalid query");
    }
  }
  delete m_pQueryJPD; 
  
  if( obsQueryVec.size() )
  {
    
    EDistributionType paramDistrType = 
      pnlDetermineDistributionType( GetModel()->GetModelDomain(), querySz, queryIn, m_pEvidence);
    
    
    CPotential *pQueryPot;
    switch( paramDistrType )
    {
    case dtTabular:
      {
        pQueryPot = CTabularPotential::CreateUnitFunctionDistribution(
          queryIn, querySz, m_pGraphicalModel->GetModelDomain() );
        break;
      }
      
    case dtGaussian:
      {
        pQueryPot = CGaussianPotential::CreateUnitFunctionDistribution(
          queryIn, querySz, m_pGraphicalModel->GetModelDomain()  );
        break;
      }
    case dtScalar:
      {
        pQueryPot = CScalarPotential::Create(
          queryIn, querySz, m_pGraphicalModel->GetModelDomain()  );
        break;
      }
    case dtCondGaussian:
      {
        PNL_THROW( CNotImplemented, "conditional gaussian factors" )
          break;
      }
    default:
      {
        PNL_THROW( CInconsistentType, "distribution type" )
      }
    }
    
    if( tmpPot)
    {
      (*pQueryPot) *= (*tmpPot);
      delete tmpPot;
    }
    
    if( m_bMaximize )
    {
      m_pPotMPE   = static_cast<CPotential*>
        ( pQueryPot->ExpandObservedNodes( m_pEvidence, 0) );
      
      m_pEvidenceMPE = m_pPotMPE->GetMPE();
    }
    else
    {
      m_pQueryJPD = static_cast<CPotential*>( pQueryPot->ExpandObservedNodes( m_pEvidence, 0) );
    }
    
    delete pQueryPot;
  }
Ejemplo n.º 11
0
void clTrajectoryPositioner::AddControlUI()
{
	FUpdateCheck = Env->GUI->AddPropertyCheck ( vec2( 0.02f, 0.85f ), vec2( 0.1f, 0.05f ), "Update time", this, "UpdateTime" );
	FTrackCheck = Env->GUI->AddPropertyCheck ( vec2( 0.3f, 0.85f ), vec2( 0.1f, 0.05f ), "Track target", this, "TrackTarget" );
	FSpeedSlider = Env->GUI->AddPropertySlider ( vec2( 0.02f, 0.90f ), vec2( 0.3f, 0.05f ), -128.0f, 128.0f, "Speed", this, "SpeedFactor" );
	FTimeSlider = Env->GUI->AddPropertySlider ( vec2( 0.02f, 0.95f ), vec2( 0.3f, 0.05f ), GetMinTime(), GetMaxTime(), "Time", this, "LocalTime" );
}