anneal.h 2.57 KB
Newer Older
1
/*
Robert Ricci's avatar
Robert Ricci committed
2
 * Copyright (c) 2003-2010 University of Utah and the Flux Group.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * 
 * {{{EMULAB-LICENSE
 * 
 * This file is part of the Emulab network testbed software.
 * 
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * }}}
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 */

/*
 * 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>
37 38
using namespace std;

39 40 41 42 43
#include <math.h>

#include "delay.h"
#include "physical.h"
#include "pclass.h"
44
#include "fstring.h"
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

// 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

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
/*
 * 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;

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

#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 */
100
inline bool accept(double change, double temperature);
101 102 103 104 105

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

/* The big guy! */
106 107 108
void anneal(bool scoring_selftest, bool check_fixed_nodes,
        double scale_neighborhood, double *initial_temperature,
        double use_connected_pnode_find);
109

110 111
typedef hash_map<fstring,fstring> name_name_map;
typedef slist<fstring> name_slist;
112

113
#endif