#include #include #include "optimizer/geqo_copy.h" #include "optimizer/geqo_pool.h" #include "optimizer/geqo_recombination.h"">

PostgreSQL Source Code: src/backend/optimizer/geqo/geqo_pool.c File Reference (original) (raw)

#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include <[float.h](float%5F8h%5Fsource.html)>
#include <limits.h>
#include <math.h>
#include "[optimizer/geqo_copy.h](geqo%5F%5Fcopy%5F8h%5Fsource.html)"
#include "[optimizer/geqo_pool.h](geqo%5F%5Fpool%5F8h%5Fsource.html)"
#include "[optimizer/geqo_recombination.h](geqo%5F%5Frecombination%5F8h%5Fsource.html)"

Go to the source code of this file.

Functions
static int compare (const void *arg1, const void *arg2)
Pool * alloc_pool (PlannerInfo *root, int pool_size, int string_length)
void free_pool (PlannerInfo *root, Pool *pool)
void random_init_pool (PlannerInfo *root, Pool *pool)
void sort_pool (PlannerInfo *root, Pool *pool)
Chromosome * alloc_chromo (PlannerInfo *root, int string_length)
void free_chromo (PlannerInfo *root, Chromosome *chromo)
void spread_chromo (PlannerInfo *root, Chromosome *chromo, Pool *pool)

alloc_chromo()

alloc_pool()

compare()

static int compare ( const void * arg1, const void * arg2 ) static

Definition at line 145 of file geqo_pool.c.

146{

149

150 if (chromo1->worth == chromo2->worth)

151 return 0;

152 else if (chromo1->worth > chromo2->worth)

153 return 1;

154 else

155 return -1;

156}

References Chromosome::worth.

Referenced by _bt_compare_array_elements(), _bt_load(), ApplyInt32SortComparator(), ApplySortAbbrevFullComparator(), ApplySortComparator(), ApplyUnsignedSortComparator(), binaryheap_allocate(), compare_scalars(), comparetup_cluster(), comparetup_cluster_tiebreak(), comparetup_datum(), comparetup_datum_tiebreak(), comparetup_heap(), comparetup_heap_tiebreak(), comparetup_index_btree(), comparetup_index_btree_tiebreak(), heap_compare_slots(), multi_sort_compare(), pairingheap_allocate(), qsort_tuple_int32_compare(), qsort_tuple_unsigned_compare(), qunique(), qunique_arg(), setop_compare_slots(), and sort_pool().

free_chromo()

free_pool()

random_init_pool()

Definition at line 91 of file geqo_pool.c.

92{

94 int i;

95 int bad = 0;

96

97

98

99

100

101

102

103

104

105 i = 0;

106 while (i < pool->size)

107 {

112 i++;

113 else

114 {

115 bad++;

116 if (i == 0 && bad >= 10000)

117 elog(ERROR, "geqo failed to make a valid plan");

118 }

119 }

120

121#ifdef GEQO_DEBUG

122 if (bad > 0)

123 elog(DEBUG1, "%d invalid tours found while selecting %d pool entries",

124 bad, pool->size);

125#endif

126}

Cost geqo_eval(PlannerInfo *root, Gene *tour, int num_gene)

void init_tour(PlannerInfo *root, Gene *tour, int num_gene)

References Pool::data, DEBUG1, elog, ERROR, geqo_eval(), i, init_tour(), root, Pool::size, Pool::string_length, while(), and Chromosome::worth.

Referenced by geqo().

sort_pool()

spread_chromo()

Definition at line 187 of file geqo_pool.c.

188{

189 int top,

190 mid,

191 bot;

192 int i,

195 tmp_chromo;

196

197

199 return;

200

201

202

203 top = 0;

204 mid = pool->size / 2;

205 bot = pool->size - 1;

207

208 while (index == -1)

209 {

210

211

218 else if (bot - top <= 1)

220

221

222

223

224

225

226

228 {

229 bot = mid;

230 mid = top + ((bot - top) / 2);

231 }

232 else

233 {

234 top = mid;

235 mid = top + ((bot - top) / 2);

236 }

237 }

238

239

240

241

242

243

244

245

246

247

248

250

253

255 {

258

261

263 swap_chromo.worth = tmp_chromo.worth;

264 }

265}

void geqo_copy(PlannerInfo *root, Chromosome *chromo1, Chromosome *chromo2, int string_length)

References Pool::data, geqo_copy(), i, root, Pool::size, Chromosome::string, Pool::string_length, and Chromosome::worth.

Referenced by geqo().