/*
 * twopo.h
 *    Two Phase Optimization
 *
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * contributed by:
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
 *  Adriano Lange                  *  C3SL - Centro de Computação    *
 *  adriano@c3sl.ufpr.br           *  Científica e Software Livre /  *
 *                                 *  Departamento de Informática /  *
 *                                 *  Universidade Federal do Paraná *
 *                                 *  Curitiba, Brasil               *
 *                                 *                                 *
 *                                 *  http://www.c3sl.ufpr.br        *
 *                                 *                                 *
 *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
 *
 * Implementation based on:
 *   Y. E. Ioannidis and Y. Kang, "Randomized algorithms for optimizing
 *   large join queries," SIGMOD Rec., vol. 19, no. 2, pp. 312–321, 1990.
 */

#ifndef TWOPO_H
#define TWOPO_H

#include "nodes/relation.h"

#define DEFAULT_TWOPO_HEURISTIC_STATES          true
#define DEFAULT_TWOPO_II_STOP                   10
#define     MIN_TWOPO_II_STOP                   1
#define DEFAULT_TWOPO_SA_PHASE                  true
#define DEFAULT_TWOPO_SA_INITIAL_TEMPERATURE    0.2
#define     MIN_TWOPO_SA_INITIAL_TEMPERATURE    0.01
#define DEFAULT_TWOPO_SA_TEMPERATURE_REDUCTION  0.95
#define     MIN_TWOPO_SA_TEMPERATURE_REDUCTION  0.1
#define DEFAULT_TWOPO_SA_EQUILIBRIUM            16
#define     MIN_TWOPO_SA_EQUILIBRIUM            1

extern bool   twopo_heuristic_states;
extern int    twopo_ii_stop;
extern bool   twopo_sa_phase;
extern double twopo_sa_initial_temperature;    // T = X * cost(S0)
extern double twopo_sa_temperature_reduction;  // Tnew = X * Told
extern int    twopo_sa_equilibrium;            // E * Joins


extern RelOptInfo *twopo(PlannerInfo *root,
		int number_of_rels, List *initial_rels);

#endif   /* TWOPO_H */
