Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
	int my_rank;
	double mpi_start_time, mpi_end_time;
	deme *subpop = (deme*) malloc(sizeof(deme));

	MPI_Init(&argc, &argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
	init_population(subpop, argc, argv);
	mpi_start_time = MPI_Wtime();

	while (!subpop->complete) {
		migration(subpop);
		reproduction(subpop);
		crossover(subpop);
		mutation(subpop);
		fitness(subpop);
		subpop->old_pop = subpop->new_pop;
		subpop->cur_gen++;
		check_complete(subpop);
		sync_complete(subpop);
		report_all(subpop);
	}
	
	mpi_end_time = MPI_Wtime();
	report_fittest(subpop);
	MPI_Finalize();
	printf("[%i] Elapsed time: %f\n", my_rank, mpi_end_time - mpi_start_time);
	return 1;
}
Ejemplo n.º 2
0
static void
gis_network_page_constructed (GObject *object)
{
  GisNetworkPage *page = GIS_NETWORK_PAGE (object);
  GisNetworkPagePrivate *priv = gis_network_page_get_instance_private (page);
  const GPtrArray *devices;
  NMDevice *device;
  guint i;
  gboolean visible = FALSE;

  G_OBJECT_CLASS (gis_network_page_parent_class)->constructed (object);

  priv->icons = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

  priv->nm_client = nm_client_new ();

  g_object_bind_property (priv->nm_client, "wireless-enabled",
                          priv->turn_on_switch, "active",
                          G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

  devices = nm_client_get_devices (priv->nm_client);
  if (devices) {
    for (i = 0; i < devices->len; i++) {
      device = g_ptr_array_index (devices, i);

      if (!nm_device_get_managed (device))
        continue;

      if (nm_device_get_device_type (device) == NM_DEVICE_TYPE_WIFI) {
        /* FIXME deal with multiple, dynamic devices */
        priv->nm_device = g_object_ref (device);
        break;
      }
    }
  }

  if (priv->nm_device == NULL) {
    g_debug ("No network device found, hiding network page");
    goto out;
  }

  if (nm_device_get_state (priv->nm_device) == NM_DEVICE_STATE_ACTIVATED) {
    g_debug ("Activated network device found, hiding network page");
    goto out;
  }

  visible = TRUE;
  priv->nm_settings = nm_remote_settings_new (NULL);

  g_signal_connect (priv->nm_device, "notify::state",
                    G_CALLBACK (device_state_changed), page);
  g_signal_connect (priv->nm_client, "notify::active-connections",
                    G_CALLBACK (active_connections_changed), page);

  gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->network_list), GTK_SELECTION_NONE);
  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->network_list), update_header_func, NULL, NULL);
  gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->network_list), ap_sort, NULL, NULL);
  g_signal_connect (priv->network_list, "row-activated",
                    G_CALLBACK (row_activated), page);

  refresh_wireless_list (page);
  sync_complete (page);

  gis_page_set_skippable (GIS_PAGE (page), TRUE);

 out:
  gtk_widget_set_visible (GTK_WIDGET (page), visible);
}
Ejemplo n.º 3
0
static void
device_state_changed (GObject *object, GParamSpec *param, GisNetworkPage *page)
{
  sync_complete (page);
}