Esempio n. 1
0
void hsyncnet::process(const double order, const solve_type solver, const bool collect_dynamic, hsyncnet_analyser & analyser) {
	unsigned int number_neighbors = 0;
	unsigned int current_number_clusters = std::numeric_limits<unsigned int>::max();

	double radius = 0.0;
	double current_time = 0.0;

	while(current_number_clusters > number_clusters) {
		create_connections(radius, false);

		sync_dynamic current_dynamic;
		simulate_dynamic(order, 0.1, solver, collect_dynamic, current_dynamic);

		sync_dynamic::const_iterator last_state_dynamic = current_dynamic.cend() - 1;
		analyser.push_back(*(last_state_dynamic));

		hsyncnet_cluster_data clusters;
		analyser.allocate_sync_ensembles(0.05, clusters);

		current_number_clusters = clusters.size();

		number_neighbors++;

		if (number_neighbors >= oscillator_locations->size()) {
			radius = radius * 0.1 + radius;
		}
		else {
			radius = average_neighbor_distance(oscillator_locations, number_neighbors);
		}
	}
}
Esempio n. 2
0
EntityEditorWindow::EntityEditorWindow(
    QWidget*                                parent,
    const string&                           window_title,
    const Project&                          project,
    auto_ptr<EntityEditor::IFormFactory>    form_factory,
    auto_ptr<EntityEditor::IEntityBrowser>  entity_browser,
    const Dictionary&                       values)
  : QWidget(parent)
  , m_ui(new Ui::EntityEditorWindow())
{
    m_ui->setupUi(this);

    setWindowTitle(QString::fromStdString(window_title));
    setWindowFlags(Qt::Tool);
    setAttribute(Qt::WA_DeleteOnClose);

    m_entity_editor.reset(
        new EntityEditor(
            m_ui->scrollarea_contents,
            project,
            form_factory,
            entity_browser,
            values));

    m_initial_values = m_entity_editor->get_values();

    create_connections();
}
Esempio n. 3
0
syncnet::syncnet(std::vector<std::vector<double> > * input_data, const double connectivity_radius, const bool enable_conn_weight, const initial_type initial_phases) :
sync_network(input_data->size(), 1, 0, connection_t::CONNECTION_NONE, initial_type::RANDOM_GAUSSIAN)
{
    equation<double> oscillator_equation = std::bind(&syncnet::phase_kuramoto_equation, this, _1, _2, _3, _4);
    set_equation(oscillator_equation);

    oscillator_locations = new std::vector<std::vector<double> >(*input_data);
    create_connections(connectivity_radius, enable_conn_weight);
}
Esempio n. 4
0
Main_GUI::Main_GUI(int range_min,
                   int range_max,
                   int limit,
                   bool gray,
                   bool gdi,
                   bool dw,
                   int increase,
                   const char* exceptions,
                   bool ignore,
                   bool wincomp,
                   bool pre,
                   bool components,
                   bool no,
                   int fallback,
                   bool symb)
: hinting_range_min(range_min),
  hinting_range_max(range_max),
  hinting_limit(limit),
  gray_strong_stem_width(gray),
  gdi_cleartype_strong_stem_width(gdi),
  dw_cleartype_strong_stem_width(dw),
  increase_x_height(increase),
  x_height_snapping_exceptions_string(exceptions),
  ignore_restrictions(ignore),
  windows_compatibility(wincomp),
  pre_hinting(pre),
  hint_with_components(components),
  no_info(no),
  latin_fallback(fallback),
  symbol(symb)
{
  x_height_snapping_exceptions = NULL;

  create_layout();
  create_connections();
  create_actions();
  create_menus();
  create_status_bar();

  set_defaults();
  read_settings();

  setUnifiedTitleAndToolBarOnMac(true);

  // XXX register translations somewhere and loop over them
  if (QLocale::system().name() == "en_US")
    locale = new QLocale;
  else
    locale = new QLocale(QLocale::C);
}
Esempio n. 5
0
bool net::tcp_server::create()
{
	if (!selector::create()) {
		return false;
	}

	if ((_M_connections = (tcp_connection**) malloc(_M_fdset.size() * sizeof(tcp_connection*))) == NULL) {
		return false;
	}

	if (!create_connections()) {
		return false;
	}

	return true;
}
Esempio n. 6
0
void hsyncnet::process(const double order, const solve_type solver, const bool collect_dynamic, hsyncnet_analyser & analyser) {
    std::size_t number_neighbors = m_initial_neighbors;
    std::size_t current_number_clusters = m_oscillators.size();

    if (current_number_clusters <= m_number_clusters) {
        return;   /* Nothing to process, amount of objects is less than required amount of clusters. */
    }

    double radius = average_neighbor_distance(oscillator_locations, number_neighbors);
    
    std::size_t increase_step = (std::size_t) round(oscillator_locations->size() * m_increase_persent);
    if (increase_step < 1) {
        increase_step = DEFAULT_INCREASE_STEP;
    }

    sync_dynamic current_dynamic;
    do {
        create_connections(radius, false);

        simulate_dynamic(order, 0.1, solver, collect_dynamic, current_dynamic);

        if (collect_dynamic) {
            if (analyser.empty()) {
                store_state(*(current_dynamic.begin()), analyser);
            }

            store_state(*(current_dynamic.end() - 1), analyser);
        }
        else {
            m_time += DEFAULT_TIME_STEP;
        }

        hsyncnet_cluster_data clusters;
        current_dynamic.allocate_sync_ensembles(0.05, clusters);

        current_number_clusters = clusters.size();

        number_neighbors += increase_step;
        radius = calculate_radius(radius, number_neighbors);
    }
    while(current_number_clusters > m_number_clusters);

    if (!collect_dynamic) {
        store_state(*(current_dynamic.end() - 1), analyser);
    }
}
Esempio n. 7
0
int CR_thread_start( unsigned int n )
{
    nspawns = n;

    if ( m_state_get() == M_RESTART ) {
        ASSERT_MSG( restart_version >= 0, "Internal error" );
    }

#ifndef CR_FTB
    // This must be called before mpispawn are started
    // Do not move this to CR_Loop()
    if (USE_LINEAR_SSH) {
        if (!show_on) {
            int rv = create_connections();
            if ( rv != 0 ) {
                return -1;
            }
        }
    }
#endif

    struct timeval starting;
    gettimeofday(&starting, NULL);
    starting_time = last_ckpt = starting.tv_sec;

    // Check and set CR state
    CR_state_lock();
    ASSERT_MSG( cr_state == CR_INIT || cr_state == CR_STOPPED, "Internal Error\n");
    CR_state_transition_nolock( CR_INIT );
    CR_state_unlock();

    if (pthread_create(&cr_tid, NULL, CR_Loop, NULL) < 0) {
        PRINT_ERROR_ERRNO("pthread_create() failed", errno);
        cr_tid = 0;
        return -1;
    }

    return 0;
}
Esempio n. 8
0
som::som(std::vector<std::vector<double> > * input_data, const unsigned int num_rows, const unsigned int num_cols, const unsigned int num_epochs, const som_conn_type type_conn, const som_parameters * parameters) {
	previous_weights = NULL;
	neighbors = NULL;

	data = input_data;
	rows = num_rows;
	cols = num_cols;
	size = cols * rows;
	epouchs = num_epochs;
	conn_type = type_conn;

	if (parameters != nullptr) {
		params.init_type = parameters->init_type;
		params.init_learn_rate = parameters->init_learn_rate;
		params.adaptation_threshold = parameters->adaptation_threshold;
		params.init_radius = parameters->init_radius;
	}

	/* location */
	location = new std::vector<std::vector<double> * >(size, NULL);
	for (unsigned int i = 0; i < rows; i++) {
		for (unsigned int j = 0; j < cols; j++) {
			std::vector<double> * neuron_location = new std::vector<double>(2, 0);
			(*neuron_location)[0] = i;
			(*neuron_location)[1] = j;

			(*location)[i * cols + j] = neuron_location;
		}
	}

	/* awards */
	awards = new std::vector<unsigned int>(size, 0);

	/* distances */
	sqrt_distances = new std::vector<std::vector<double> * >(size, NULL);
	for (unsigned int i = 0; i < size; i++) {
		std::vector<double> * column_distances = new std::vector<double>(size, 0);
		(*sqrt_distances)[i] = column_distances;
	}

	for (unsigned int i = 0; i < size; i++) {
		for (unsigned int j = i; j < size; j++) {
			double distance = euclidean_distance_sqrt((*location)[i], (*location)[j]);
			(*(*sqrt_distances)[i])[j] = distance;
			(*(*sqrt_distances)[j])[i] = distance;
		}
	}

	/* captured objects */
	capture_objects = new std::vector<std::vector<unsigned int> * >(size, NULL);
	for (unsigned int i = 0; i < size; i++) {
		(*capture_objects)[i] = new std::vector<unsigned int>();
	}

	/* connections */
	if (type_conn != som_conn_type::SOM_FUNC_NEIGHBOR) {
		create_connections(type_conn);
	}

	/* weights */
	create_initial_weights(params.init_type);
}