Esempio n. 1
0
void
timbre::add_tracks(
        musly_track** tracks,
        musly_trackid* trackids,
        int length,
        bool generate_ids) {
    int num_new;
    if (generate_ids) {
        idpool.generate_ids(trackids, length);
        num_new = length;
    }
    else {
        num_new = idpool.add_ids(trackids, length);
    }

    Eigen::VectorXf sim(mp.get_normtracks()->size());
    mp.append_normfacts(num_new);
    int pos = idpool.get_size() - length;
    for (int i = 0; i < length; i++) {
        similarity_raw(tracks[i], mp.get_normtracks()->data(),
                mp.get_normtracks()->size(), sim.data());

        mp.set_normfacts(pos + i, sim);
    }
}
Esempio n. 2
0
int main (int argc, char* argv[]) {
	// Initialize options
	int i;
	get_ops(NULL);
	for (i=1; i<argc; ++i) {
		get_ops(argv[i]);
	}

	// Seed RNG
	if (ops.seedFlag) {
		srand(ops.seed);
	} else {
		srand(time(NULL));
	}

	// Read in nuclei
	if (get_nuclei(ops.nuclei_filename)==false) {
		exit(EXIT_FAILURE);
	}

	// Read in reactions
	if (get_reactions(ops.reaclib_filename)==false) {
		exit(EXIT_FAILURE);
	}

	sim();

	free(nuclei);
	free(abun);
	free(reactions);
	return 0;
}
Esempio n. 3
0
int main(int argc, char **argv)
{
    PseudoRandomSeed();
  
    dInitODE();

//create simulator and set robot position at (0, -8)  
    Simulator sim(0, -8);    

//create motion planner
    MotionPlanner mp(&sim);    

//create graphics
    Graphics graphics(&mp);
    
//create obstacles and terrain
    CreateWorld1(&sim);
    
//if argument specified, set as maximum motion planning time
    if(argc > 1)
	graphics.SetMotionPlannerMaxTime(atof(argv[1]));    

//print help messages
    graphics.HandleEventOnHelp();

//enter event loop
    graphics.MainLoop();
    
    return 0;    
}
Esempio n. 4
0
int main(void)
{
	Rossler<double> ross(0.398,2.0,4.0);
	RungeKutta4<double> integrator(1e-2);
//	Euler<double> integrator(1e-2);
	Simulation<double> sim(ross,integrator);

	double ti = 0.0;
	double tf = 200.0;
	long npts = 10000;

	std::ofstream datfile("out.dat", std::ios::out | std::ios::trunc);

	ross.x(0) = 0.0;
	ross.x(1) = 0.0;
	ross.x(2) = 0.0;

	if (datfile)
	{
		//sim.run(std::cout, ti, tf);
		//sim.run(datfile, npts);
		sim.run(datfile, ti, tf);
		
		datfile.close();
	}
	else
	{
		std::cerr << "Erreur à l'ouverture du fichier !" << std::endl;
	}
	
	return 0;

}
Esempio n. 5
0
TEST(TestASMu3D, TransferGaussPtVars)
{
  SIM3D sim(1);
  sim.opt.discretization = ASM::LRSpline;
  sim.createDefaultModel();
  ASMu3D* pch = static_cast<ASMu3D*>(sim.getPatch(1));
  size_t id[3];
  const double* xi = GaussQuadrature::getCoord(3);
  RealArray oldAr(3*3*3), newAr;
  for (size_t idx = 0; idx < 3; ++idx) {
    SIM3D simNew(1);
    simNew.opt.discretization = ASM::LRSpline;
    simNew.createDefaultModel();
    ASMu3D* pchNew = static_cast<ASMu3D*>(simNew.getPatch(1));
    pchNew->uniformRefine(idx, 1);

    for (id[2] = 0; id[2] < 3; ++id[2])
      for (id[1] = 0; id[1] < 3; ++id[1])
        for (id[0] = 0; id[0] < 3; ++id[0])
          oldAr[id[0]+(id[1]+id[2]*3)*3] = (1.0 + xi[id[idx]]) / 2.0;

    pchNew->transferGaussPtVars(pch->getVolume(), oldAr, newAr, 3);
    size_t k = 0;
    for (size_t iEl = 0; iEl < 2; ++iEl)
      for (id[2] = 0; id[2] < 3; ++id[2])
        for (id[1] = 0; id[1] < 3; ++id[1])
          for (id[0] = 0; id[0] < 3; ++id[0], ++k)
            EXPECT_FLOAT_EQ(newAr[k], 0.5*iEl + 0.5*(xi[id[idx]] + 1.0) / 2.0);
  }
}
Esempio n. 6
0
TEST(TestInitialConditions, Parse)
{
  SIM2D sim({4}, false);
  EXPECT_TRUE(sim.read("src/SIM/Test/refdata/input.xinp"));

  // Recognize both comp and component attributes and correct priority
  // Boundary conditions
  for (int i = 1; i < 5; i++)
    ASSERT_FLOAT_EQ((float)i,(*sim.getSclFunc(i))(Vec3()));
  // Initial conditions
  ASSERT_TRUE(sim.getICs().begin() != sim.getICs().end());
  const std::vector<SIMdependency::ICInfo>& bar = sim.getICs().begin()->second;
  for (std::vector<SIMdependency::ICInfo>::const_iterator info = bar.begin();
       info != bar.end(); info++)
    switch (info->component) {
      case 1:
        ASSERT_EQ(info->function, "1");
        break;
      case 2:
        ASSERT_EQ(info->function, "2");
        break;
      case 3:
        ASSERT_EQ(info->function, "3");
        break;
      case 4:
        ASSERT_EQ(info->function, "4");
        break;
      default:
        ASSERT_TRUE(false);
      }
}
Esempio n. 7
0
TEST_P(TestASMu3D, BoundaryNodes)
{
  if (GetParam() == 0 || GetParam() > 6)
    return;

  SIM3D sim(1);
  sim.opt.discretization = ASM::LRSpline;
  ASSERT_TRUE(sim.read("src/ASM/LR/Test/refdata/boundary_nodes_3d.xinp"));
  ASSERT_TRUE(sim.createFEMmodel());

  std::stringstream str;
  str << "Face" << GetParam();
  int bcode = sim.getUniquePropertyCode(str.str(),0);
  std::vector<int> vec;
  sim.getBoundaryNodes(bcode,vec);
  ASSERT_EQ(vec.size(), 16U);
  auto it = vec.begin();
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j)
      if (GetParam() == 1)
        EXPECT_EQ(*it++, 1+4*(4*i+j));
      else if (GetParam() == 2)
        EXPECT_EQ(*it++, 2+4*(4*i+j));
      else if (GetParam() == 3)
        EXPECT_EQ(*it++, 16*i+j+1);
      else if (GetParam() == 4)
        EXPECT_EQ(*it++, 5+16*i+j);
      else if (GetParam() == 5)
        EXPECT_EQ(*it++, 4*i+j+1);
      else if (GetParam() == 6)
        EXPECT_EQ(*it++, 17+4*i+j);
}
Esempio n. 8
0
TEST(TestASMu3D, TransferGaussPtVarsN)
{
  SIM3D sim(1), sim2(1);
  sim.opt.discretization = sim2.opt.discretization = ASM::LRSpline;
  sim.createDefaultModel();
  sim2.createDefaultModel();
  ASMu3D* pch = static_cast<ASMu3D*>(sim.getPatch(1));
  ASMu3D* pchNew = static_cast<ASMu3D*>(sim2.getPatch(1));
  pchNew->uniformRefine(0, 1);
  RealArray oldAr(3*3*3), newAr;
  std::iota(oldAr.begin(), oldAr.end(), 1);

  pchNew->transferGaussPtVarsN(pch->getVolume(), oldAr, newAr, 3);
  static RealArray refAr = {{ 1.0,  1.0,  2.0,
                              4.0,  4.0,  5.0,
                              7.0,  7.0,  8.0,
                             10.0, 10.0, 11.0,
                             13.0, 13.0, 14.0,
                             16.0, 16.0, 17.0,
                             19.0, 19.0, 20.0,
                             22.0, 22.0, 23.0,
                             25.0, 25.0, 26.0,
                              2.0,  3.0,  3.0,
                              5.0,  6.0,  6.0,
                              8.0,  9.0,  9.0,
                             11.0, 12.0, 12.0,
                             14.0, 15.0, 15.0,
                             17.0, 18.0, 18.0,
                             20.0, 21.0, 21.0,
                             23.0, 24.0, 24.0,
                             26.0, 27.0, 27.0}};
  EXPECT_EQ(refAr.size(), newAr.size());
  for (size_t i = 0; i < refAr.size(); ++i)
    EXPECT_FLOAT_EQ(refAr[i], newAr[i]);
}
Esempio n. 9
0
TEST(TestDomainDecomposition, Setup)
{
  SIM2D sim(1);
  sim.read("src/ASM/Test/refdata/DomainDecomposition_2D_1P.xinp");
  sim.preprocess();

  DomainDecomposition dd;
  // TODO: Remove after integration
  dd.setup(sim.getProcessAdm(), sim);
  const SAM* sam = sim.getSAM();

  ASSERT_EQ(dd.getMinEq(), 1);
  ASSERT_EQ(dd.getMaxEq(), sam->getNoEquations());
  ASSERT_EQ(dd.getMinNode(), 1);
  ASSERT_EQ(dd.getMaxNode(), sam->getNoNodes());
  ASSERT_EQ(dd.getMinDOF(), 1);
  ASSERT_EQ(dd.getMaxDOF(), sam->getNoDOFs());
  for (int i = 1; i <= sam->getNoEquations(); ++i)
    ASSERT_EQ(dd.getGlobalEq(i), i);
  ASSERT_EQ(dd.getGlobalEq(sam->getNoEquations()+1), 0);

  // disabled until integration in the SIM class is added
//  ASSERT_EQ(dd.getPatchOwner(1), 0);
//  ASSERT_EQ(dd.getPatchOwner(2), -1);

  ASSERT_TRUE(dd.getMLGEQ().empty());
  ASSERT_TRUE(dd.getMLGN().empty());
}
int main(int argc,char *argv[]) {
    if(argc != 5) {
            printf("Wrong Number of Arguments\n");
            exit(0);
    }

    //double alpha1 = argv[1]-0.0;
    double alpha1, alpha2, beta1, beta2, gamma1, gamma2, phi1, phi2;
    alpha1 = alpha2 = atof( argv[1] );
    beta1 = 0.35;
    beta2 = atof( argv[2] );
    gamma1 = gamma2 = 1.0/5.0;
    phi1 = phi2 = atof( argv[4]);
    int intro_time;
    intro_time = atoi( argv[3] );

    int num_reps = 5;

    Network net = Network("gillespie toy", Network::Undirected);
    net.populate(10000);
    net.connect_all_nodes();
    Gillespie_TwoStrain_Network_Sim sim(&net, alpha1, alpha2, gamma1, gamma2, beta1, beta2, phi1, phi2, intro_time);
    for(int i =1; i <= num_reps; i++){
        cout << "Simulation number: " << i << endl;
        sim.reset();
        sim.rand_infect(5, 1);
        sim.run_simulation(10000.0);
    }
    return 0;
}
Esempio n. 11
0
TEST(Simplifier, JumpConstFold) {
  BCMarker dummy = BCMarker::Dummy();
  IRUnit unit(test_context);
  Simplifier sim(unit);

  // Folding JmpZero and JmpNZero.
  {
    auto tester = [&] (SSATmp* val, Opcode op) {
      auto jmp = unit.gen(op, dummy, unit.defBlock(), val);
      return sim.simplify(jmp, false);
    };

    auto resultFalseZero  = tester(unit.cns(false),  JmpZero);
    auto resultFalseNZero = tester(unit.cns(false), JmpNZero);
    auto resultTrueZero   = tester(unit.cns(true),   JmpZero);
    auto resultTrueNZero  = tester(unit.cns(true),  JmpNZero);

    EXPECT_SINGLE_OP(resultFalseNZero, Nop);
    EXPECT_SINGLE_OP(resultTrueZero, Nop);

    EXPECT_SINGLE_OP(resultFalseZero, Jmp);
    EXPECT_SINGLE_OP(resultTrueNZero, Jmp);
  }

  // Folding query jumps.
  {
    auto jmpeqTaken = unit.gen(JmpEq, dummy, unit.cns(10), unit.cns(10));
    auto result = sim.simplify(jmpeqTaken, false);
    EXPECT_SINGLE_OP(result, Jmp);

    auto jmpeqNTaken = unit.gen(JmpEq, dummy, unit.cns(10), unit.cns(400));
    result = sim.simplify(jmpeqNTaken, false);
    EXPECT_SINGLE_OP(result, Nop);
  }
}
Esempio n. 12
0
/**
 * @brief Add a new simulation instance
 * @param name unique internal name for this instance
 * @param lattice file name
 */
void flamePrepare(const char *name, const char *lattice)
{
    if(!name) return;
    try {
        Guard G(SimGlobal.lock);

        if(SimGlobal.sims.find(name)!=SimGlobal.sims.end())
            throw std::runtime_error("Sim name already in use");

        std::auto_ptr<Config> conf;
        {
            GLPSParser parser;
            conf.reset(parser.parse_file(lattice));
        }

        std::auto_ptr<Sim> sim(new Sim(name));

        sim->machine.reset(new Machine(*conf));

        SimGlobal.sims[name] = sim.get();

        sim.release();

    }catch(std::exception& e){
        fprintf(stderr, "Error: %s\n", e.what());
    }
}
Esempio n. 13
0
void FpuStackAllocator::pop_always(LIR_Op* op, LIR_Opr opr) {
  assert(op->fpu_pop_count() == 0, "fpu_pop_count alredy set");
  assert(tos_offset(opr) == 0, "can only pop stack top");

  op->set_fpu_pop_count(1);
  sim()->pop();
}
Esempio n. 14
0
int main() {
    
    // Construct Network
    Network net("name", Network::Undirected);
    net.populate(10000);
    net.erdos_renyi(5);

    cout << "days_ahead" << "," << "transmissibility1" << "," << "transmissibility2" << "," << "strain1" << "," << "strain2" << endl;

    for (int days_ahead = 0; days_ahead < 20; days_ahead ++){
        for (double transmissibility1 = 0.2; transmissibility1 <=  0.5; transmissibility1 += 0.05){
            for (double transmissibility2 = 0.2; transmissibility2 <= 0.5; transmissibility2 += 0.05){
                int i = 0;
                while ( i < 100){
                    // Choose and run simulation
                    Two_Strain_Percolation_Sim sim(&net);
                    sim.set_transmissibility1(transmissibility1);
                    sim.set_transmissibility2(transmissibility2);
                    sim.rand_infect(5, 0);
                    sim.run_headstart_simulation(days_ahead, 5);

                    if(sim.epidemic_size1() > 50){
                        cout << days_ahead << "," << transmissibility1 << "," << transmissibility2 << "," << sim.epidemic_size1() << "," << sim.epidemic_size2() << endl; 
                        i++;
                    }
                    
                    sim.reset();
                }
            }
        }
    }

    return 0;
}
Else::PhysicsSimulatorPtr
Else::PhysicsSimulatorFactory::create( void )
{
    PhysicsSimulatorPtr sim( new PhysicsSimulator() );
    sim->setTimeStep( myTimeStep );
    return sim;
}
Esempio n. 16
0
void process_enable_simulator(LLMessageSystem *msg, void **user_data)
{
    // enable the appropriate circuit for this simulator and
    // add its values into the gSimulator structure
    U64		handle;
    U32		ip_u32;
    U16		port;

    msg->getU64Fast(_PREHASH_SimulatorInfo, _PREHASH_Handle, handle);
    msg->getIPAddrFast(_PREHASH_SimulatorInfo, _PREHASH_IP, ip_u32);
    msg->getIPPortFast(_PREHASH_SimulatorInfo, _PREHASH_Port, port);

    // which simulator should we modify?
    LLHost sim(ip_u32, port);

    // Viewer trusts the simulator.
    msg->enableCircuit(sim, TRUE);
    LLWorld::getInstance()->addRegion(handle, sim);

    // give the simulator a message it can use to get ip and port
    llinfos << "simulator_enable() Enabling " << sim << " with code " << msg->getOurCircuitCode() << llendl;
    msg->newMessageFast(_PREHASH_UseCircuitCode);
    msg->nextBlockFast(_PREHASH_CircuitCode);
    msg->addU32Fast(_PREHASH_Code, msg->getOurCircuitCode());
    msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
    msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
    msg->sendReliable(sim);
}
Esempio n. 17
0
int main() {
    // Construct Network
    Network net("name", false);
    net.populate(10000);

    // Let's connect the network using an arbitrary degree distribution
    // Out of 10 nodes, none will have degrees 0 or 1, 1 will have degree 2
    // 3 with degree 3, 2 with degree 4, 1 with degree 5, and 3 with degree 3
    vector<double> degree_dist;
    double tmp_array[] = {0, 0, 1, 3, 2, 1, 3};
    degree_dist.assign(tmp_array,tmp_array+7); // 5 == the length of tmp_array

    // Now make those probabilities that sum to 1
    degree_dist = normalize_dist(degree_dist, sum(degree_dist));

    // Finally, connect up the network using that user-defined degree distribution
    // Note that poisson, exponential, and scale-free random network generators are built-in
    net.rand_connect_user(degree_dist);

    // Simulation parameters
    int infectious_period = 10; // 10 days, hours,  whatever 
    double T = 0.05; // per timestep, per outbound edge probability of transmission

    for (int i = 0; i < 10; i++){
        // Choose and run simulation
        ChainBinomial_Sim sim(&net, infectious_period, T);
        sim.rand_infect(1);
        sim.run_simulation();
        cout << sim.epidemic_size() << endl;
        sim.reset();
    }
    return 0;
}
Esempio n. 18
0
__interrupt void TIM4_Updata_IRQHandler(void)
{
    sim();//关总中断

    
    TIM4->SR1 &=~BIT(0);//清标志位
    rim();//开总中断
}
Esempio n. 19
0
void test_sim(void){

  uint8_t instr[] = {0XAB};
  
  TEST_ASSERT_EQUAL_INT8(1, sim(instr));
  TEST_ASSERT_EQUAL_INT8(1, I0);
  TEST_ASSERT_EQUAL_INT8(1, I1);
}
Esempio n. 20
0
int main()
{
	int m=1;
	int l=1;

	double dt=0.01;

	pendulum1d_cost::N(0,0)=0.3;
	pendulum1d_cost::N(1,1)=0.3;

	pendulum1d_cost::Q=0.1;

	pendulum1d::Cost cost=pendulum1d_cost::cost;
	pendulum1d::DCost dcost=pendulum1d_cost::dcost;

	pendulum1d::Cost costN=pendulum1d_cost::costN;
	pendulum1d::DCost dcostN=pendulum1d_cost::dcostN;

	SAC<pendulum1d>::Functions func(cost, dcost, costN, dcostN);

	SAC<pendulum1d>::Params params;

	params.alpha=-20;
	params.beta=0.6;
	
	params.Tc=0.64;
	params.Tp=2.5;
	params.Ts=0.02;
	params.Tcal=0.01;
	params.kmax=6;

	pendulum1d::System sys(m,l);

	pendulum1d::State state0(-2,7);

	std::list<pendulum1d::Params> list_pars(1000, pendulum1d::State(0, 0));
	std::list<Eigen::Matrix<double,1,1> > list_u;

	Sim<pendulum1d>::State_Sim sim(sys,dt);
	sim.init(state0);

	SAC<pendulum1d> sac(sys,dt);
	
	for(double t=0; t<30; t+=params.Ts)
	{
		sac.init(sim.get_state(), params, func, list_pars.begin(), list_pars.end(), &list_u);
		sac.sac_ctrl(list_u);

		sim.update(list_u.front());
		list_u.pop_front();

		sim.update(list_u.front());
		list_u.pop_front();
	}

	sim.save("/media/fantaosha/Documents/JHU/Summer 2015/results/result3.mat");
	return 0;
}
Esempio n. 21
0
int
main(int argc, char* argv[])
{
	namespace po = boost::program_options;

	try {

		po::options_description desc = commonOptions();
		desc.add_options()
			("neurons,n", po::value<unsigned>()->default_value(1000), "number of neurons")
			("synapses,m", po::value<unsigned>()->default_value(1000), "number of synapses per neuron")
			("dmax,d", po::value<unsigned>()->default_value(1), "maximum excitatory delay,  where delays are uniform in range [1, dmax]")
		;

		po::variables_map vm = processOptions(argc, argv, desc);

		unsigned ncount = vm["neurons"].as<unsigned>();
		unsigned scount = vm["synapses"].as<unsigned>();
		unsigned dmax = vm["dmax"].as<unsigned>();
		unsigned duration = vm["duration"].as<unsigned>();
		unsigned stdp = vm["stdp-period"].as<unsigned>();
		unsigned verbose = vm["verbose"].as<unsigned>();
		bool runBenchmark = vm.count("benchmark") != 0;

		std::ofstream file;
		std::string filename;

		if(vm.count("output-file")) {
			filename = vm["output-file"].as<std::string>();
			file.open(filename.c_str()); // closes on destructor
		}

		std::ostream& out = filename.empty() ? std::cout : file;

		LOG(verbose, "Constructing network");
		boost::scoped_ptr<nemo::Network> net(nemo::random::construct(ncount, scount, dmax, stdp != 0));
		LOG(verbose, "Creating configuration");
		nemo::Configuration conf = configuration(vm);
		LOG(verbose, "Simulation will run on %s", conf.backendDescription());
		LOG(verbose, "Creating simulation");
		boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(*net, conf));
		LOG(verbose, "Running simulation");
		if(runBenchmark) {
			benchmark(sim.get(), ncount, scount, vm);
		} else {
			simulate(sim.get(), duration, stdp, out);
		}
		LOG(verbose, "Simulation complete");
		return 0;
	} catch(std::exception& e) {
		std::cerr << e.what() << std::endl;
		return -1;
	} catch(...) {
		std::cerr << "random: An unknown error occurred\n";
		return -1;
	}

}
Esempio n. 22
0
void FpuStackAllocator::pop_if_last_use(LIR_Op* op, LIR_Opr opr) {
  assert(op->fpu_pop_count() == 0, "fpu_pop_count alredy set");
  assert(tos_offset(opr) == 0, "can only pop stack top");

  if (opr->is_last_use()) {
    op->set_fpu_pop_count(1);
    sim()->pop();
  }
}
Esempio n. 23
0
File: gen.c Progetto: noodles-v6/ACM
int main()
{
   int i;

   for(i=2;i<151;i++) {
      sim(i);
      printf("%d: %d %d\n",i,res1,res2);
   }
}
Esempio n. 24
0
bool edf_misses_deadline(unsigned int num_procs,
                         TaskSet &ts,
                         unsigned long end_of_simulation)
{
    DeadlineMissSearch sim(num_procs);

    run_periodic_simulation(sim, ts, end_of_simulation);
    return sim.deadline_was_missed();
}
Esempio n. 25
0
void tsim_module::init( tsim_object* parent, const string& name )
{
    tsim_object::init( parent, name );

    // register with simulator
    tsim_simulator* s = sim();
    assert( s != NULL );
    if (s) s->add_module( *this );
}
Esempio n. 26
0
TEST(TestMultiPatchModelGenerator3D, Subdivisions)
{
  SIMMultiPatchModelGen<SIM3D> sim(1);
  ASSERT_TRUE(sim.read("refdata/modelgen3d_subdivision.xinp"));

  // check FEM topology
  const SIM3D::PatchVec& model = sim.getFEModel();
  int renum = 0, ngnod = 0;
  std::map<int,int> g2l;
  for (auto& it : model)
    renum += it->renumberNodes(g2l, ngnod);
  std::vector<std::vector<int>> mlgn = {
      {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
       28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,
       52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,
       76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
       100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,
       118,119,120,121,122,123,124,125},
      {4,5,126,127,9,10,128,129,14,15,130,131,19,20,132,133,24,25,134,135,29,30,
       136,137,34,35,138,139,39,40,140,141,44,45,142,143,49,50,144,145,54,55,
       146,147,59,60,148,149,64,65,150,151,69,70,152,153,74,75,154,155,79,80,
       156,157,84,85,158,159,89,90,160,161,94,95,162,163,99,100,164,165,104,105,
       166,167,109,110,168,169,114,115,170,171,119,120,172,173,124,125,174,175},
      {16,17,18,19,20,21,22,23,24,25,176,177,178,179,180,181,182,183,184,185,41,
       42,43,44,45,46,47,48,49,50,186,187,188,189,190,191,192,193,194,195,66,67,
       68,69,70,71,72,73,74,75,196,197,198,199,200,201,202,203,204,205,91,92,93,
       94,95,96,97,98,99,100,206,207,208,209,210,211,212,213,214,215,116,117,
       118,119,120,121,122,123,124,125,216,217,218,219,220,221,222,223,224,225},
      {19,20,132,133,24,25,134,135,179,180,226,227,184,185,228,229,44,45,142,
       143,49,50,144,145,189,190,230,231,194,195,232,233,69,70,152,153,74,75,
       154,155,199,200,234,235,204,205,236,237,94,95,162,163,99,100,164,165,209,
       210,238,239,214,215,240,241,119,120,172,173,124,125,174,175,219,220,242,
       243,224,225,244,245},
      {76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
       100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,
       118,119,120,121,122,123,124,125,246,247,248,249,250,251,252,253,254,255,
       256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,
       274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,
       292,293,294,295},
      {79,80,156,157,84,85,158,159,89,90,160,161,94,95,162,163,99,100,164,165,
       104,105,166,167,109,110,168,169,114,115,170,171,119,120,172,173,124,125,
       174,175,249,250,296,297,254,255,298,299,259,260,300,301,264,265,302,303,
       269,270,304,305,274,275,306,307,279,280,308,309,284,285,310,311,289,290,
       312,313,294,295,314,315},
      {91,92,93,94,95,96,97,98,99,100,206,207,208,209,210,211,212,213,214,215,
       116,117,118,119,120,121,122,123,124,125,216,217,218,219,220,221,222,223,
       224,225,261,262,263,264,265,266,267,268,269,270,316,317,318,319,320,321,
       322,323,324,325,286,287,288,289,290,291,292,293,294,295,326,327,328,329,
       330,331,332,333,334,335},
      {94,95,162,163,99,100,164,165,209,210,238,239,214,215,240,241,119,120,
       172,173,124,125,174,175,219,220,242,243,224,225,244,245,264,265,302,303,
       269,270,304,305,319,320,336,337,324,325,338,339,289,290,312,313,294,295,
       314,315,329,330,340,341,334,335,342,343}};
  for (int i=0; i<8; i++)
    check_vector_int_equals(mlgn[i], model[i]->getMyNodeNums());
}
Esempio n. 27
0
/**
  * @brief this function checks if a NDEF message is available
	* @par Parameters None
  * @retval none
  */
static void User_DisplayMessageActiveHaltMode ( uint8_t PayloadLength )
{

	
		//Switch the clock to LSE and disable HSI
		#ifdef USE_LSE
			CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
			CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSE);	
			CLK_SYSCLKSourceSwitchCmd(ENABLE);
			while (((CLK->SWCR)& 0x01)==0x01);
			CLK_HSICmd(DISABLE);
			CLK->ECKCR &= ~0x01; 
		#else
			CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
			CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);
			CLK_SYSCLKSourceSwitchCmd(ENABLE);
			while (((CLK->SWCR)& 0x01)==0x01);
			CLK_HSICmd(DISABLE);
			CLK->ECKCR &= ~0x01; 
		#endif	
		
		// disable interupt				
		sim();
		// To copy function DISPLAYRAM in RAM section DISPLAY
		#ifdef _COSMIC_
			if (!(_fctcpy('D')))
				while(1);
		#endif
				
			Display_Ram (); // Call in RAM
			
		//	state_machine = STATE_VREF;
						
		#ifdef USE_HSI
			//Switch the clock to HSI
			CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_16);
			CLK_HSICmd(ENABLE);
			while (((CLK->ICKCR)& 0x02)!=0x02);			
			CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
			CLK_SYSCLKSourceSwitchCmd(ENABLE);
			while (((CLK->SWCR)& 0x01)==0x01);
		#else
			CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_2);
			// Select 2MHz HSE as system clock source 
			CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSE);
			// wait until the target clock source is ready 
			while (((CLK->SWCR)& 0x01)==0x01);
			// wait until the target clock source is ready 
			CLK_SYSCLKSourceSwitchCmd(ENABLE);
		#endif
							
		// enable interupt				
		rim();
		

}
Esempio n. 28
0
Stats edf_observe_tardiness(unsigned int num_procs,
                            TaskSet &ts,
                            unsigned long end_of_simulation)
{
    Tardiness sim(num_procs);

    run_periodic_simulation(sim, ts, end_of_simulation);

    return sim.stats;
}
Esempio n. 29
0
TEST(Simplifier, JumpFuse) {
  BCMarker dummy = BCMarker::Dummy();
  IRUnit unit(test_context);
  Simplifier sim(unit);

  {
    // JmpZero(Eq(X, true)) --> JmpEq(X, false)
    auto taken = unit.defBlock();
    auto lhs = unit.cns(true);
    auto rhs = unit.gen(Conjure, dummy, Type::Bool);
    auto eq  = unit.gen(Eq, dummy, lhs, rhs->dst());
    auto jmp = unit.gen(JmpZero, dummy, taken, eq->dst());
    auto result = sim.simplify(jmp, false);

    EXPECT_EQ(nullptr, result.dst);
    EXPECT_EQ(2, result.instrs.size());

    // This is a dead Eq instruction; an artifact of weirdness in the
    // implementation. Should go away.
    EXPECT_FALSE(result.instrs[0]->isControlFlow());

    EXPECT_MATCH(result.instrs[1], JmpEq, taken, rhs->dst(), unit.cns(false));
  }

  {
    // JmpNZero(Neq(X:Int, Y:Int)) --> JmpNeqInt(X, Y)
    auto taken = unit.defBlock();
    auto x = unit.gen(Conjure, dummy, Type::Int);
    auto y = unit.gen(Conjure, dummy, Type::Int);

    auto neq = unit.gen(Neq, dummy, x->dst(), y->dst());
    auto jmp = unit.gen(JmpNZero, dummy, taken, neq->dst());
    auto result = sim.simplify(jmp, false);

    EXPECT_EQ(nullptr, result.dst);
    EXPECT_EQ(2, result.instrs.size());
    EXPECT_FALSE(result.instrs[0]->isControlFlow());  // dead Neq
    EXPECT_MATCH(result.instrs[1], JmpNeqInt, taken, x->dst(), y->dst());
  }

  {
    // JmpNZero(Neq(X:Cls, Y:Cls)) --> JmpNeq(X, Y)
    auto taken = unit.defBlock();
    auto x = unit.gen(Conjure, dummy, Type::Bool);
    auto y = unit.gen(Conjure, dummy, Type::Bool);

    auto neq = unit.gen(Neq, dummy, x->dst(), y->dst());
    auto jmp = unit.gen(JmpNZero, dummy, taken, neq->dst());
    auto result = sim.simplify(jmp, false);

    EXPECT_EQ(nullptr, result.dst);
    EXPECT_EQ(1, result.instrs.size());
    EXPECT_MATCH(result.instrs[0], JmpNeq, taken, x->dst(), y->dst());
  }
}
Esempio n. 30
0
TEST_P(TestASMu2D, ConstrainEdge)
{
  SIM2D sim(1);
  ASMu2D* pch = getPatch(sim);
  ASSERT_TRUE(pch != nullptr);
  pch->constrainEdge(GetParam().edgeIdx, false, 1, 1, 1);
  std::vector<int> glbNodes;
  pch->getBoundaryNodes(GetParam().edge, glbNodes, 1, 1, 0);
  for (int& it : glbNodes)
    ASSERT_TRUE(pch->findMPC(it, 1) != nullptr);
}