anneal.h 2.1 KB
Newer Older
1 2
/*
 * EMULAB-COPYRIGHT
3
 * Copyright (c) 2003-2006 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * All rights reserved.
 */

/*
 * Contains the actual functions to do simulated annealing
 */

#ifndef __ANNEAL_H
#define __ANNEAL_H

#include "port.h"

#include <boost/graph/adjacency_list.hpp>
using namespace boost;

#include <iostream>
20 21 22 23 24 25
using namespace std;

/*
 * We have to do these includes differently depending on which version of gcc
 * we're compiling with
 */
26
#ifdef NEW_GCC
27 28 29 30 31 32 33
#include <ext/hash_map>
#include <ext/slist>
using namespace __gnu_cxx;
#else
#include <hash_map>
#include <slist>
#endif
34 35 36 37 38 39

#include <math.h>

#include "delay.h"
#include "physical.h"
#include "pclass.h"
40
#include "fstring.h"
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

// Some defaults for #defines
#ifndef NO_REVERT
#define NO_REVERT 0
#endif

#ifndef REVERT_VIOLATIONS
#define REVERT_VIOLATIONS 1
#endif

#ifndef REVERT_LAST
#define REVERT_LAST 0
#endif

#ifdef PHYS_CHAIN_LEN
#define PHYSICAL(x) x
#else
#define PHYSICAL(x) 0
#endif

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
/*
 * Parameters used to control annealing
 */
extern int init_temp;
extern int temp_prob;
extern float temp_stop;
extern int CYCLES;

// Initial acceptance ratio for melting
extern float X0;
extern float epsilon;
extern float delta;

// Number of runs to spend melting
extern int melt_trans;
extern int min_neighborhood_size;

extern float temp_rate;

80 81 82 83 84 85 86
/*
 * Globals - XXX made non-global!
 */
/* From assign.cc */
extern pclass_types type_table;
extern pclass_list pclasses;
extern pnode_pvertex_map pnode2vertex;
87 88
extern double best_score;
extern int best_violated, iters, iters_to_best;
89
extern bool allow_overload;
90 91 92 93 94 95

#ifdef PER_VNODE_TT
extern pclass_types vnode_type_table;
#endif

/* Decides based on the temperature if a new score should be accepted or not */
96
inline bool accept(double change, double temperature);
97 98 99 100 101

/* Find a pnode that can satisfy the give vnode */
tb_pnode *find_pnode(tb_vnode *vn);

/* The big guy! */
102 103 104
void anneal(bool scoring_selftest, bool check_fixed_nodes,
        double scale_neighborhood, double *initial_temperature,
        double use_connected_pnode_find);
105

106 107
typedef hash_map<fstring,fstring> name_name_map;
typedef slist<fstring> name_slist;
108

109
#endif