void operator()( boost::property_tree::ptree & s, object_type & obj ) {
        boost::property_tree::ptree tr;
        state_getter< typename object_type::trait_space_type > tr_logger;
        tr_logger( tr, obj.m_trait_space );

        boost::property_tree::ptree fr;
        state_getter< typename object_type::free_space_type > free_logger;
        free_logger( fr, obj.m_free_space );

        boost::property_tree::ptree fx, alls;
        state_getter< typename object_type::allele_type > all_logger;
        all_logger( fx, obj.m_fixed );
        all_logger( alls, obj.m_allele_space );

        boost::property_tree::ptree c_pop;
        state_getter< typename object_type::sequence_space_type > pop_logger;
        pop_logger( c_pop, *(obj.m_pop.back()) );

        boost::property_tree::ptree ft;
        clotho::utility::add_value_array( ft, obj.m_fits.back()->begin(), obj.m_fits.back()->end() );
        c_pop.put_child( "fitness", ft );

        s.put_child( "free_space", fr );
        s.put_child( "allele_space", alls );
        s.put_child( "trait_space", tr );
        s.put_child( "fixed_alleles", fx );

        s.put_child( "child", c_pop );
    }
    void operator()( boost::property_tree::ptree & s, object_type & obj ) {
        boost::property_tree::ptree tr;
        state_getter< typename object_type::trait_space_type > tr_logger;
        tr_logger( tr, obj.m_trait_space );

        boost::property_tree::ptree ph;
        state_getter< typename object_type::phenotype_eval_type > pheno_logger;
        pheno_logger( ph, obj.m_pheno );

        boost::property_tree::ptree fr;
        state_getter< typename object_type::free_space_type > free_logger;
        free_logger( fr, obj.m_free_space );

        boost::property_tree::ptree fx, alls;
        state_getter< typename object_type::allele_type > all_logger;
        all_logger( fx, obj.m_fixed );
        all_logger( alls, obj.m_allele_space );

//        boost::property_tree::ptree c_pop;
//        state_getter< typename object_type::sequence_space_type > pop_logger;
//        pop_logger( c_pop, *(obj.m_child) );

        s.put_child( "phenotypes", ph );
        s.put_child( "free_space", fr );
        s.put_child( "allele_space", alls );
        s.put_child( "trait_space", tr );
        s.put_child( "fixed_alleles", fx );

//        s.put_child( "child", c_pop );
    }
Exemple #3
0
    void operator()( boost::property_tree::ptree & s, object_type & obj ) {

        boost::property_tree::ptree al;
        state_getter< typename object_type::allele_type > a_log;
        a_log( al, obj.getAlleleSpace() );

        boost::property_tree::ptree ft;
        clotho::utility::add_value_array( ft, obj.fitness_begin(), obj.fitness_end() );

        s.put_child( "alleles" , al );
        s.put_child( "fitness", ft );
    }
Exemple #4
0
    void get_state( boost::property_tree::ptree & state ) {
        boost::property_tree::ptree a, s, f, p;

        alleles.get_state( a );
        sequences.get_state( s );

        get_device_object_state( f, free_space );
        get_device_object_state( p, pheno_space );

        state.put_child( "alleles", a );
        state.put_child( "sequences", s );
        state.put_child( "free_space", f );
        state.put_child( "phenotypes", p );
    }
    void recordResults( boost::property_tree::ptree & log ) {

        typedef ac::accumulator_set< size_type, ac::stats< ac::tag::min, ac::tag::mean, ac::tag::max, ac::tag::variance, ac::tag::median, ac::tag::count > > accumulator_t;

        accumulator_t   col_accum, row_accum;

        boost::property_tree::ptree dist, lfreq;

        // maximum frequency for an allele is bounded by the number of sequences (rows) in the population
        std::vector< size_type > freq( m_indices.size(), 0 );

        // evaluate allele (column) statistics
        size_type i = 0;
        while( i < m_column_margin_size ) {
            size_type v = m_column_margin[i++];
            clotho::utility::add_value_array( dist, v );
            col_accum( v );
            freq[v]++;
        }


        clotho::utility::add_value_array(lfreq, freq.begin(), freq.end() );

        log.put_child( "distribution", dist );
        log.put_child( "frequency_distribution", lfreq );

        log.put( "stats.sequences_per_allele.min", ac::min( col_accum ) );
        log.put( "stats.sequences_per_allele.max", ac::max( col_accum ) );
        log.put( "stats.sequences_per_allele.mean", ac::mean( col_accum ) );
        log.put( "stats.sequences_per_allele.median", ac::median( col_accum ) );
        log.put( "stats.sequences_per_allele.variance", ac::variance( col_accum ) );
        log.put( "stats.sequences_per_allele.total", ac::count(col_accum) );

        // evaluate sequence (row) statistics
        i = 0;
        while( i < m_row_margin_size ) {
            if( m_indices.test(i) ) {
                row_accum( m_row_margin[ i ] );
            }
            ++i;
        }

        log.put( "stats.alleles_per_sequence.min", ac::min( row_accum ) );
        log.put( "stats.alleles_per_sequence.max", ac::max( row_accum ) );
        log.put( "stats.alleles_per_sequence.mean", ac::mean( row_accum ) );
        log.put( "stats.alleles_per_sequence.median", ac::median( row_accum ) );
        log.put( "stats.alleles_per_sequence.variance", ac::variance( row_accum ) );
        log.put( "stats.alleles_per_sequence.total", ac::count(row_accum) );
    }
Exemple #6
0
	bool upgrade_json (unsigned version_a, boost::property_tree::ptree & tree_a)
	{
		auto result (false);
		switch (version_a)
		{
			case 1:
			{
				rai::account account;
				account.decode_account (tree_a.get<std::string> ("account"));
				tree_a.erase ("account");
				tree_a.put ("account", account.to_account ());
				tree_a.erase ("version");
				tree_a.put ("version", "2");
				result = true;
			}
			case 2:
			{
				boost::property_tree::ptree rpc_l;
				rpc.serialize_json (rpc_l);
				tree_a.put ("rpc_enable", "false");
				tree_a.put_child ("rpc", rpc_l);
				tree_a.erase ("version");
				tree_a.put ("version", "3");
				result = true;
			}
			case 3:
			{
				auto opencl_enable_l (tree_a.get_optional<bool> ("opencl_enable"));
				if (!opencl_enable_l)
				{
					tree_a.put ("opencl_enable", "false");
				}
				auto opencl_l (tree_a.get_child_optional ("opencl"));
				if (!opencl_l)
				{
					boost::property_tree::ptree opencl_l;
					opencl.serialize_json (opencl_l);
					tree_a.put_child ("opencl", opencl_l);
				}
				tree_a.put ("version", "4");
				result = true;
			}
			case 4:
				break;
			default:
				throw std::runtime_error ("Unknown qt_wallet_config version");
		}
		return result;
	}
Exemple #7
0
bool rai_daemon::daemon_config::upgrade_json (unsigned version_a, boost::property_tree::ptree & tree_a)
{
	auto result (false);
	switch (version_a)
	{
	case 1:
	{
		auto opencl_enable_l (tree_a.get_optional <bool> ("opencl_enable"));
		if (!opencl_enable_l)
		{
			tree_a.put ("opencl_enable", "false");
		}
		auto opencl_l (tree_a.get_child_optional ("opencl"));
		if (!opencl_l)
		{
			boost::property_tree::ptree opencl_l;
			opencl.serialize_json (opencl_l);
			tree_a.put_child ("opencl", opencl_l);
		}
		tree_a.put ("version", "2");
		result = true;
	}
	case 2:
		break;
	default:
		throw std::runtime_error ("Unknown daemon_config version");
	}
	return result;
}
void merge( boost::property_tree::ptree& pt, const boost::property_tree::ptree& updates )
{
   BOOST_FOREACH( auto& update, updates )
   {
	   printf("boost foreach\n");
      pt.put_child( update.first, update.second );
   }
Exemple #9
0
 void operator()( boost::property_tree::ptree & s, object_type & obj ) {
     boost::property_tree::ptree fr;
     clotho::utility::add_value_array( fr, obj.free_begin(), obj.free_end() );
     
     s.put_child( "free", fr );
     s.add( "free_size", obj.free_size() );
     s.add( "variable_count", obj.variable_count() );
 }
    void init( size_t aN, boost::property_tree::ptree & config ) {
        size_t pN = 0;
        if( m_pop_growth ) {
            pN = m_pop_growth->operator()( pN, m_generation );
        }

        boost::property_tree::ptree lconfig;

        lconfig = config.get_child( "generations", lconfig);

        unsigned int intermed = lconfig.get< unsigned int>( "intermediates", 0 );

        lconfig.put("intermediates", intermed );
        config.put_child( "generations", lconfig );

        for( unsigned int i = 0; i < intermed + 2; ++i ) {
            sequence_space_type * ss = new sequence_space_type();
            m_pop.push_back( ss );

            fitness_type * f = new fitness_type( config );

            assert( f->isEmpty() );

            m_fits.push_back( f );

            mutation_pool_type * p = new mutation_pool_type();
            m_mut_pools.push_back( p );

            mutation_distribution_type * d = new mutation_distribution_type();
            m_mut_dists.push_back( d );
        }


        if( m_thread_count.m_tc > 0 ) {
            m_worker_rng = new random_engine_type * [ m_thread_count.m_tc ];
            m_worker_off_gens = new offspring_generator_type * [ m_thread_count.m_tc ];

            for( int offset = 0; offset < m_thread_count.m_tc; ++offset ) {
                m_worker_rng[ offset ] = new random_engine_type( (*m_rand)());
                m_worker_off_gens[ offset ] = new offspring_generator_type( m_worker_rng[ offset ], &m_allele_space, &m_trait_space, config );
            }
        }

#ifdef USE_ROW_VECTOR
        m_pop1.getSequenceSpace().fill_empty();
        m_pop1.getSequenceSpace().finalize();
#endif // USE_ROW_VECTOR
        ++m_generation;
    }
    void buildTimeVectorLog( boost::property_tree::ptree & log, time_map & times ) {
        for( typename time_map::iterator it = times.begin(); it != times.end(); it++ ) {
            boost::property_tree::ptree starts, stops;

            for( typename time_vector::iterator iter = it->second.begin(); iter != it->second.end(); ++iter ) {
                clotho::utility::add_value_array( starts, iter->first );
                clotho::utility::add_value_array( stops, iter->second );
            }

            boost::property_tree::ptree tmp;
            tmp.put_child( "start", starts );
            tmp.put_child( "stop", stops );

            log.put_child( it->first, tmp );
        }
    }
    quadratic_fitness_parameter( boost::property_tree::ptree & config ) :
        m_scale( 1.0 ) {
        boost::property_tree::ptree fblock;
        fblock = config.get_child( FITNESS_BLOCK_K, fblock );
        
        boost::property_tree::ptree pblock;
        pblock = fblock.get_child( PARAM_K, pblock );

        m_scale = pblock.get< RealType >( SCALE_K, m_scale );
        
        pblock.put( SCALE_K, m_scale );

        fblock.put( NAME_K, QUAD_NAME );
        fblock.put_child( PARAM_K, pblock );

        config.put_child( FITNESS_BLOCK_K, fblock );
    }
    void record( boost::property_tree::ptree & xo, boost::property_tree::ptree & mt, boost::property_tree::ptree & ph, boost::property_tree::ptree & fx ) {

        boost::property_tree::ptree xo_begins, xo_ends;
        buildTimeLog( xo_begins, xo_ends, m_crossover_times );
        xo.put_child( "start", xo_begins);
        xo.put_child( "stop", xo_ends);

        boost::property_tree::ptree mt_begins, mt_ends;
        buildTimeLog( mt_begins, mt_ends, m_mutate_times );
        mt.put_child( "start", mt_begins);
        mt.put_child( "stop", mt_ends);

        boost::property_tree::ptree ph_begins, ph_ends;
        buildTimeLog( ph_begins, ph_ends, m_phenotype_times );
        ph.put_child( "start", ph_begins);
        ph.put_child( "stop", ph_ends);

        boost::property_tree::ptree fx_begins, fx_ends;
        buildTimeLog( fx_begins, fx_ends, m_fixed_times );
        fx.put_child( "start", fx_begins);
        fx.put_child( "stop", fx_ends);
    }
void NetworkManagerHandler::wifiScan(boost::property_tree::ptree &responsePt)
{
    std::vector<WirelessManager::ScanResult> scanResult = qpcrApp.wirelessManager()->scanResult();
    boost::property_tree::ptree array;

    for (const WirelessManager::ScanResult &result: scanResult)
    {
        boost::property_tree::ptree ptree;
        ptree.put("ssid", result.ssid);
        ptree.put("quality", result.quality);
        ptree.put("siganl_level", result.siganlLevel);

        switch (result.encryption)
        {
        case WirelessManager::ScanResult::WepEncryption:
            ptree.put("encryption", "wep");
            break;

        case WirelessManager::ScanResult::Wpa1Ecryption:
            ptree.put("encryption", "wpa1");
            break;

        case WirelessManager::ScanResult::Wpa2PSKEcryption:
            ptree.put("encryption", "wpa2 psk");
            break;

        case WirelessManager::ScanResult::Wpa28021xEcryption:
            ptree.put("encryption", "wpa2 802.1x");
            break;

        default:
            ptree.put("encryption", "none");
            break;
        }

        array.push_back(std::make_pair("", ptree));
    }

    responsePt.put_child("scan_result", array);
}
    void parse_configuration( boost::property_tree::ptree & config ) {
        boost::property_tree::ptree lconfig;

        if( config.get_child_optional( "mutation" ) != boost::none ) {
            lconfig = config.get_child( "mutation" );
        }

        if( lconfig.get_child_optional( "mutation_per_sequence" ) == boost::none ) {
            lconfig.put("mutation_per_sequence", m_mutation_rate );
        } else {
            m_mutation_rate = lconfig.get< real_type >( "mutation_per_sequence", m_mutation_rate );
        }

        if( lconfig.get_child_optional( "rng.seed" ) != boost::none ) {
            m_seed = lconfig.get< seed_type >( "rng.seed", m_seed );
        }

        if( m_seed == 0 ) {
            m_seed = clotho::utility::clock_type::now().time_since_epoch().count();
            lconfig.put("rng.seed", m_seed );
        }

        config.put_child( "mutation", lconfig );
    }
Exemple #16
0
 void to_ptree(const details::global_kernel_state_t &state, ::boost::property_tree::ptree &ptree, int level)
 {
   {
     ::boost::property_tree::ptree init;
     state.initialization_parameters_ref().to_ptree(init);
     ptree.put_child("initialization", init);
   }
   {
     ::boost::property_tree::ptree last_collect;
     last_collect.put("clear_mark_time", ::std::to_string(state.clear_mark_time_span().count()));
     last_collect.put("mark_time", ::std::to_string(state.mark_time_span().count()));
     last_collect.put("sweep_time", ::std::to_string(state.sweep_time_span().count()));
     last_collect.put("notify_time", ::std::to_string(state.notify_time_span().count()));
     last_collect.put("total_time", ::std::to_string(state.total_collect_time_span().count()));
     ptree.put_child("last_collect", last_collect);
   }
   {
     ::boost::property_tree::ptree slab_allocator;
     state._internal_slab_allocator().to_ptree(slab_allocator, level);
     ptree.put_child("slab_allocator", slab_allocator);
   }
   {
     ::boost::property_tree::ptree cgc_allocator;
     state._internal_allocator().to_ptree(cgc_allocator, level);
     ptree.put_child("cgc_allocator", cgc_allocator);
   }
   {
     ::boost::property_tree::ptree gc_allocator;
     state.gc_allocator().to_ptree(gc_allocator, level);
     ptree.put_child("gc_allocator", gc_allocator);
   }
   {
     ::boost::property_tree::ptree packed_allocator;
     state._bitmap_allocator().to_ptree(packed_allocator, level);
     ptree.put_child("packed_allocator", packed_allocator);
   }
 }
    void getPerformanceResults( boost::property_tree::ptree & log ) {

        for( int i = 0; i < m_thread_count.m_tc; ++i ) {
            std::ostringstream oss;
            oss << "W_" << (i + 1);

            boost::property_tree::ptree mut, xo, ph, fx, ft;
            m_worker_off_gens[ i ]->record( xo, mut, ph, fx, ft );
            
            log.put_child( "performance.mutate." + oss.str(), mut );
            log.put_child( "performance.crossover." + oss.str(), xo );
            log.put_child( "performance.fixed." + oss.str(), fx );
            log.put_child( "performance.phenotype." + oss.str(), ph );
            log.put_child( "performance.fitness." + oss.str(), ft );
        }

        boost::property_tree::ptree mut, xo, ph, fx, ft;
        m_main_off_gen.record( xo, mut, ph, fx, ft );
        
        log.put_child( "performance.mutate.main", mut );
        log.put_child( "performance.crossover.main", xo );
        log.put_child( "performance.fixed.main", fx );
        log.put_child( "performance.phenotype.main", ph );
        log.put_child( "performance.fitness.main", ft );

        log.put_child( "memory.free_count", free_sizes );
        log.put_child( "memory.variable_count", var_sizes );
        log.put_child( "memory.fixed_count", fixed_sizes );
    }