NEURON interface to GAUL (Neymotin and Lytton)

Accession:102464
This interface allows the use of genetic algorithms for optimization and search in high-dimensional spaces from within the NEURON environment. It includes converted .c,.h files from GAUL wrapped in proper MOD file syntax as well as MOD code interfacing to the library. It also comes with hoc utilitiy functions to make it easier to use the GA.
Tool Information (Click on a link to find other Tools with that property)
Tool Type: Control Simulations;
Simulation Environment: NEURON;
\
neuron_gaul_2
gaul
readme.txt
compatibility.mod
ga_bitstring.mod
ga_chromo.mod
ga_climbing.mod
ga_compare.mod
ga_core.mod
ga_crossover.mod
ga_de.mod
ga_deterministiccrowding.mod
ga_gradient.mod
ga_hoc.mod
ga_intrinsics.mod
ga_io.mod
ga_mutate.mod
ga_optim.mod
ga_qsort.mod
ga_randomsearch.mod
ga_rank.mod
ga_replace.mod
ga_sa.mod
ga_seed.mod
ga_select.mod
ga_similarity.mod
ga_simplex.mod
ga_stats.mod
ga_systematicsearch.mod
ga_tabu.mod
ga_utility.mod
linkedlist.mod
log_util.mod
memory_chunks.mod
memory_util.mod
nn_util.mod
random_util.mod
avltree.mod
table_util.mod
timer_util.mod
vecst.mod
mosinit.hoc
ga_utils.hoc
init.hoc
declist.hoc
setup.hoc
decvec.hoc
ga_test.hoc
gaul.h
xtmp
                            
:$Id: ga_seed.mod,v 1.3 2007/01/30 15:17:19 samn Exp $
NEURON {
  SUFFIX nothing
}

VERBATIM

/**********************************************************************
  ga_seed.c
 **********************************************************************

  ga_seed - Genetic algorithm genome initialisation operators.
  Copyright   2000-2005, Stewart Adcock <stewart@linux-domain.com>
  All rights reserved.

  The latest version of this program should be available at:
  http://gaul.sourceforge.net/

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.  Alternatively, if your project
  is incompatible with the GPL, I will probably agree to requests
  for permission to use the terms of any other license.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY WHATSOEVER.

  A full copy of the GNU General Public License should be in the file
  "COPYING" provided with this distribution; if not, see:
  http://www.gnu.org/

 **********************************************************************

  Synopsis:     Routines for performing GA seeding operations.

		Seeding operations generate genetic data by some
		non-evolutionary means.  Typically, this is often
		just random generation.

 **********************************************************************/

#include "gaul/ga_core.h"

/**********************************************************************
  ga_seed_boolean_random()
  synopsis:	Seed genetic data for a single entity with a boolean
		chromosome by randomly setting each bit.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 15/05/01
 **********************************************************************/

boolean ga_seed_boolean_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((boolean *)adam->chromosome[chromo])[point] = random_boolean();
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_boolean_zero()
  synopsis:	Seed genetic data for a single entity with a boolean
		chromosome by setting each bit to zero.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 30 Jun 2003
 **********************************************************************/

boolean ga_seed_boolean_zero(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((boolean *)adam->chromosome[chromo])[point] = 0;
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_integer_random()
  synopsis:	Seed genetic data for a single entity with an integer
		chromosome by randomly setting each allele.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 15/05/01
 **********************************************************************/

boolean ga_seed_integer_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((int *)adam->chromosome[chromo])[point] =
        random_int_range(pop->allele_min_integer,pop->allele_max_integer);
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_integer_zero()
  synopsis:	Seed genetic data for a single entity with an integer
		chromosome by setting each allele to zero.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 15/05/01
 **********************************************************************/

boolean ga_seed_integer_zero(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((int *)adam->chromosome[chromo])[point] = 0;
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_char_random()
  synopsis:	Seed genetic data for a single entity with a character
		chromosome by randomly setting each allele.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 16/06/01
 **********************************************************************/

boolean ga_seed_char_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((char *)adam->chromosome[chromo])[point]
            = random_int(CHAR_MAX-CHAR_MIN)+CHAR_MIN;
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_double_random()
  synopsis:	Seed genetic data for a single entity with a double-
		precision floating-point chromosome by randomly
		setting each allele.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 16/06/01
 **********************************************************************/

boolean ga_seed_double_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

printf("start ga_seed_double_random\n");

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
if(pop->allele_min_double && pop->allele_max_double){
      ((double *)adam->chromosome[chromo])[point] =
        random_double_range(pop->allele_min_double[point],pop->allele_max_double[point]);
//        random_double_range(pop->allele_min_double[point],pop->allele_max_double[point]);
} else{
      ((double *)adam->chromosome[chromo])[point] =
        random_double_range(DBL_MIN,DBL_MAX);
}
      }
    }

printf("end ga_seed_double_random\n");

  return TRUE;
  }


/**********************************************************************
  ga_seed_double_random_unit_gaussian()
  synopsis:	Seed genetic data for a single entity with a double-
		precision floating-point chromosome by randomly
		setting each allele using a unit gaussian distribution.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 02 Jul 2003
 **********************************************************************/

boolean ga_seed_double_random_unit_gaussian(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((double *)adam->chromosome[chromo])[point] = random_unit_gaussian();
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_double_zero()
  synopsis:
  parameters:
  return:
  last updated: 16/06/01
 **********************************************************************/

boolean ga_seed_double_zero(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((double *)adam->chromosome[chromo])[point] = 0.0;
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_printable_random()
  synopsis:
  parameters:
  return: last updated: 16/06/01
 **********************************************************************/

boolean ga_seed_printable_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ((char *)adam->chromosome[chromo])[point]
            = random_int('~'-' ')+' ';
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_bitstring_random()
  synopsis:	Randomly seed bitstring chromosomes.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 30/06/01
 **********************************************************************/

boolean ga_seed_bitstring_random(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ga_bit_randomize(adam->chromosome[chromo],point);
      }
    }

  return TRUE;
  }


/**********************************************************************
  ga_seed_bitstring_zero()
  synopsis:	Seed bitstring chromosomes with zeros.
  parameters:	population *pop
		entity *adam
  return:	success
  last updated: 10 Aug 2004
 **********************************************************************/

boolean ga_seed_bitstring_zero(population *pop, entity *adam)
  {
  int		chromo;		/* Index of chromosome to seed */
  int		point;		/* Index of allele to seed */

/* Checks. */
  if (!pop) die("Null pointer to population structure passed.");
  if (!adam) die("Null pointer to entity structure passed.");

/* Seeding. */
  for (chromo=0; chromo<pop->num_chromosomes; chromo++)
    {
    for (point=0; point<pop->len_chromosomes; point++)
      {
      ga_bit_clear(adam->chromosome[chromo],point);
      }
    }

  return TRUE;
  }


ENDVERBATIM