Пример #1
0
 void operator()() {
   /* Figure out the number of threads */
   unsigned int size;
   pfunc::get_num_threads (taskmgr, size);
   
   /* Prepare all the tasks for launch */
   TaskType sub_tasks[size];
   std::vector<applicator> funcs;
   for (unsigned int rank=0; rank<size; ++rank) {
     SpaceType subspace = PartitionerType::create 
         (space.begin(), space.end(), rank, size);
     funcs.push_back (applicator(func.split(), subspace));
   }
   
   /* Launch the tasks */
   for (unsigned int rank=0; rank<size; ++rank) {
     pfunc::spawn (taskmgr, sub_tasks[rank], funcs[rank]);
   }
   
   /* wait for them */
   pfunc::wait_all (taskmgr, sub_tasks, sub_tasks+size);
   
   /* aggregate the results */
   for (unsigned int rank=0; rank<size; ++rank) {
     func.join(funcs[rank].func);
   }
 } 
Пример #2
0
/**
 * Use to free ID references within runtime data (stored outside of DNA)
 *
 * \param new_id may be NULL to unlink \a old_id.
 */
void ED_spacedata_id_remap(struct ScrArea *sa, struct SpaceLink *sl, ID *old_id, ID *new_id)
{
	SpaceType *st = BKE_spacetype_from_id(sl->spacetype);

	if (st && st->id_remap) {
		st->id_remap(sa, sl, old_id, new_id);
	}
}
Пример #3
0
/* lb1 should be empty */
void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
{
	SpaceLink *sl;
	
	BLI_listbase_clear(lb1);  /* to be sure */
	
	for (sl = lb2->first; sl; sl = sl->next) {
		SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
		
		if (st && st->duplicate) {
			SpaceLink *slnew = st->duplicate(sl);
			
			BLI_addtail(lb1, slnew);
			
			region_copylist(st, &slnew->regionbase, &sl->regionbase);
		}
	}
}
Пример #4
0
void BKE_spacedata_freelist(ListBase *lb)
{
	SpaceLink *sl;
	ARegion *ar;
	
	for (sl = lb->first; sl; sl = sl->next) {
		SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
		
		/* free regions for pushed spaces */
		for (ar = sl->regionbase.first; ar; ar = ar->next)
			BKE_area_region_free(st, ar);

		BLI_freelistN(&sl->regionbase);
		
		if (st && st->free) 
			st->free(sl);
	}
	
	BLI_freelistN(lb);
}
Пример #5
0
	// @return	a next solution if available and an empty vector if not
	vector<VarType> next() {
		vector<VarType> result;

		// Initialize the search in the first call
		if (dfs == nullptr) 
			dfs = new DFS<SpaceType>(space);

		// Obtain the new space
		delete space;
		space = dfs->next();

		// C to C++ representation
		if (space == NULL) 
			space = nullptr;
		
		// Get the result if there's any
		if (space != nullptr)
			result = space->getSolution();
	
		return result;
	}
Пример #6
0
 bool SpaceLoad_Impl::setSpaceType(const SpaceType& spaceType)
 {
   return setPointer(this->spaceIndex(), spaceType.handle());
 }
Пример #7
0
ompl::control::Control*
RHCICreate::generateFeedbackControl(const ompl::base::State *state, const size_t& _t)
{

  using namespace arma;

  //if no more controls left, regenerate controls
  if(openLoopControls_.size() == 0) {

    std::vector<ompl::control::Control*> openLoopControls;

    this->motionModel_->generateOpenLoopControls(state , this->goal_, openLoopControls) ;

    openLoopControls_ = std::deque<ompl::control::Control*>(openLoopControls.begin(), openLoopControls.end());

    //if motion model cannot generate valid open loop controls from start to goal, return an empty vector signifying invalid control
    if(openLoopControls_.size() == 0) {
      return this->motionModel_->getZeroControl();
    }

    //if we generate more controls than the length of controlQueueSize (user-defined), we truncate the rest
    if(openLoopControls_.size() > controlQueueSize_)
      openLoopControls_.resize(controlQueueSize_);
    }

    // if there are controls left, apply and remove them one-by-one
    ompl::control::Control* control;

    control = openLoopControls_.front();

    openLoopControls_.pop_front();

    colvec diff =  (this->goal_)->as<StateType>()->getArmaData() - state->as<StateType>()->getArmaData();

    double distance  = norm(diff.subvec(0,1), 2);

    SpaceType *space;
    space =  new SpaceType();

    ompl::base::State *relativeState = space->allocState();

    space->getRelativeState(state, goal_, relativeState);

    colvec relativeCfg =  relativeState->as<StateType>()->getArmaData();

    //cout<<"RHCICreate controller,                        goal_: "<<endl<<this->goal_.GetArmaData()<<endl;
    //cout<<"RHCICreate controller, relativeCfg bearing (degrees): "<<relativeCfg[2]*180/PI<<endl;
    //cout<<"RHCICreate controller, relativeCfg distance (cm )   : "<<distance*100<<endl;
    //if( distance < 0.20 && !this->m_reachedFlag)  this->m_reachedFlag = true;

    if(distance < turnOnlyDistance_){

      ompl::control::Control* newcontrol  = this->motionModel_->getZeroControl();
      //cout<<"Applying Only Turn Control !"<<endl;
      if (abs(relativeCfg[2]) > 1e-6)
      {
        //cout<<"control val:  "<<0.2 * relativeCfg[2]/abs(relativeCfg[2])<<endl;
        //SO std::cin.get();
        newcontrol->as<ompl::control::RealVectorControlSpace::ControlType>()->values[1] = 0.2 * relativeCfg[2]/abs(relativeCfg[2]);
      }

      return newcontrol;
    }

    return control;
}
boost::optional<IdfObject> ForwardTranslator::translateSpaceType( SpaceType & modelObject )
{
  std::vector<Space> spaces = modelObject.spaces();

  // check if this is a dummy space type meant to prevent inheriting building space type
  std::vector<ModelObject> children = modelObject.children();
  if (children.empty()){
    LOG(Info, "SpaceType " << modelObject.name().get() << " has no children, it will not be translated");
    return boost::none;
  }

  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneList, 
                                                       modelObject);

  std::set<std::string> zoneNames;
  for (const Space& space : spaces){
    boost::optional<ThermalZone> thermalZone = space.thermalZone();
    if (thermalZone){
      zoneNames.insert(thermalZone->name().get());
    }
  }

  idfObject.clearExtensibleGroups();
  for (const std::string& zoneName : zoneNames){
    idfObject.pushExtensibleGroup(std::vector<std::string>(1, zoneName));
  }

  // translate internal mass
  InternalMassVector internalMasses = modelObject.internalMass();
  std::sort(internalMasses.begin(), internalMasses.end(), WorkspaceObjectNameLess());
  for (InternalMass& internalMass : internalMasses){
    translateAndMapModelObject(internalMass);
  }

  // translate lights
  LightsVector lights = modelObject.lights();
  std::sort(lights.begin(), lights.end(), WorkspaceObjectNameLess());
  for (Lights& light : lights){
    translateAndMapModelObject(light);
  }

  // translate luminaires
  LuminaireVector luminaires = modelObject.luminaires();
  std::sort(luminaires.begin(), luminaires.end(), WorkspaceObjectNameLess());
  for (Luminaire& luminaire : luminaires){
    translateAndMapModelObject(luminaire);
  }

  // translate people
  PeopleVector people = modelObject.people();
  std::sort(people.begin(), people.end(), WorkspaceObjectNameLess());
  for (People& person : people){
    translateAndMapModelObject(person);
  }

  // translate electric equipment
  ElectricEquipmentVector electricEquipment = modelObject.electricEquipment();
  std::sort(electricEquipment.begin(), electricEquipment.end(), WorkspaceObjectNameLess());
  for (ElectricEquipment& equipment : electricEquipment){
    translateAndMapModelObject(equipment);
  }

  // translate gas equipment
  GasEquipmentVector gasEquipment = modelObject.gasEquipment();
  std::sort(gasEquipment.begin(), gasEquipment.end(), WorkspaceObjectNameLess());
  for (GasEquipment& equipment : gasEquipment){
    translateAndMapModelObject(equipment);
  }

  // translate hot water equipment
  HotWaterEquipmentVector hotWaterEquipment = modelObject.hotWaterEquipment();
  std::sort(hotWaterEquipment.begin(), hotWaterEquipment.end(), WorkspaceObjectNameLess());
  for (HotWaterEquipment& equipment : hotWaterEquipment){
    translateAndMapModelObject(equipment);
  }

  // translate steam equipment
  SteamEquipmentVector steamEquipment = modelObject.steamEquipment();
  std::sort(steamEquipment.begin(), steamEquipment.end(), WorkspaceObjectNameLess());
  for (SteamEquipment& equipment : steamEquipment){
    translateAndMapModelObject(equipment);
  }

  // translate other equipment
  OtherEquipmentVector otherEquipment = modelObject.otherEquipment();
  std::sort(otherEquipment.begin(), otherEquipment.end(), WorkspaceObjectNameLess());
  for (OtherEquipment& equipment : otherEquipment){
    translateAndMapModelObject(equipment);
  }

  // translate SpaceInfiltration_DesignFlowRate
  SpaceInfiltrationDesignFlowRateVector spaceInfiltrationDesignFlowRates = modelObject.spaceInfiltrationDesignFlowRates();
  std::sort(spaceInfiltrationDesignFlowRates.begin(), spaceInfiltrationDesignFlowRates.end(), WorkspaceObjectNameLess());
  for (SpaceInfiltrationDesignFlowRate& spaceInfiltrationDesignFlowRate : spaceInfiltrationDesignFlowRates){
    translateAndMapModelObject(spaceInfiltrationDesignFlowRate);
  }

  // translate SpaceInfiltration_EffectiveLeakageArea
  SpaceInfiltrationEffectiveLeakageAreaVector spaceInfiltrationEffectiveLeakageAreas = modelObject.spaceInfiltrationEffectiveLeakageAreas();
  std::sort(spaceInfiltrationEffectiveLeakageAreas.begin(), spaceInfiltrationEffectiveLeakageAreas.end(), WorkspaceObjectNameLess());
  for (SpaceInfiltrationEffectiveLeakageArea& spaceInfiltrationEffectiveLeakageArea : spaceInfiltrationEffectiveLeakageAreas){
    translateAndMapModelObject(spaceInfiltrationEffectiveLeakageArea);
  }

  return idfObject;
}
Пример #9
0
 bool Building_Impl::setSpaceType(const SpaceType& spaceType)
 {
   return setPointer(OS_BuildingFields::SpaceTypeName, spaceType.handle());
 }