Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/backend/optimizer/geqo/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 2 kB image not shown  

Quelle  geqo_ox1.c

  Sprache: C
 

/*------------------------------------------------------------------------
*
* geqo_ox1.c
*
*  order crossover [OX] routines;
*  OX1 operator according to Davis
*  (Proc Int'l Joint Conf on AI)
*
* src/backend/optimizer/geqo/geqo_ox1.c
*
*-------------------------------------------------------------------------
*/


/* contributed by:
   =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
   *  Martin Utesch     * Institute of Automatic Control    *
   =        = University of Mining and Technology =
   *  utesch@aut.tu-freiberg.de  * Freiberg, Germany       *
   =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
 */


/* the ox algorithm is adopted from Genitor : */
/*************************************************************/
/*  */
/* Copyright (c) 1990  */
/* Darrell L. Whitley  */
/* Computer Science Department  */
/* Colorado State University  */
/*  */
/* Permission is hereby granted to copy all or any part of  */
/* this program for free distribution.   The author's name  */
/* and this copyright notice must be included in any copy.  */
/*  */
/*************************************************************/

#include "postgres.h"
#include "optimizer/geqo.h"

#if defined(OX1)

#include "optimizer/geqo_random.h"
#include "optimizer/geqo_recombination.h"

/* ox1
 *
 *  position crossover
 */

void
ox1(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene,
 City * city_table)
{
 int   left,
    right,
    k,
    p,
    temp;

 /* initialize city table */
 for (k = 1; k <= num_gene; k++)
  city_table[k].used = 0;

 /* select portion to copy from tour1 */
 left = geqo_randint(root, num_gene - 10);
 right = geqo_randint(root, num_gene - 10);

 if (left > right)
 {
  temp = left;
  left = right;
  right = temp;
 }

 /* copy portion from tour1 to offspring */
 for (k = left; k <= right; k++)
 {
  offspring[k] = tour1[k];
  city_table[(int) tour1[k]].used = 1;
 }

 k = (right + 1) % num_gene; /* index into offspring */
 p = k;      /* index into tour2 */

 /* copy stuff from tour2 to offspring */
 while (k != left)
 {
  if (!city_table[(int) tour2[p]].used)
  {
   offspring[k] = tour2[p];
   k = (k + 1) % num_gene;
   city_table[(int) tour2[p]].used = 1;
  }
  p = (p + 1) % num_gene; /* increment tour2-index */
 }
}

#endif       /* defined(OX1) */

Messung V0.5 in Prozent
C=95 H=93 G=93

¤ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet am  2026-08-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.