common.h 6.19 KB
Newer Older
Robert Ricci's avatar
Robert Ricci committed
1 2 3 4 5 6
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2000-2003 University of Utah and the Flux Group.
 * All rights reserved.
 */

Mac Newbold's avatar
Mac Newbold committed
7 8 9
#ifndef __COMON_H
#define __COMON_H

10 11
#include "config.h"

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Exit vaules from assign
 */

// A solution with no violations was found
#define EXIT_SUCCESS 0

// No valid solution was found, but one may exist
// No violation-free solution was found after annealing, or there was an
// internal error
#define EXIT_RETRYABLE 1

// It is not possible to map the given top file into the given ptop file,
// so there's no point in re-running assign.
// Can also occur if the top or ptop file does not exist or cannot be parsed
#define EXIT_UNRETRYABLE 2
28 29 30 31 32 33 34

/*
  To use these on the command line, each entry gets a
  <name>=<value> pair on the command line.
  Here we declare them all and give them defaults.
*/

35 36
//static int init_temp = 100;
static int init_temp = 10;
37 38
static int USE_OPTIMAL = 1;
static int temp_prob = 130;
39 40 41 42 43 44 45
#ifdef LOW_TEMP_STOP
//static int temp_stop = 1;
static float temp_stop = .005;
#else
static float temp_stop = 2;
//static int temp_stop = 20;
#endif
46
static int CYCLES = 20;
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61
// The following are basically arbitrary constants
// Initial acceptance ratio for melting
static float X0 = .95;
//static float epsilon = 0.1;
#ifdef LOCAL_DERIVATIVE
static float epsilon = 0.0001;
#else
static float epsilon = 0.01;
#endif
static float delta = 2;
//static float delta = 1;
//static float min_temp_end = 0.01;
//static float min_temp_end = 10000000.0;

Robert Ricci's avatar
Robert Ricci committed
62 63 64
// The weight at which a feature or desire triggers a violations if
// unstatisfied or unused
static float FD_VIOLATION_WEIGHT = 1.0;
65 66

// Number of runs to spend melting
67 68
static int melt_trans = 1000;
static int min_neighborhood_size = 1000;
69 70


71 72
static float temp_rate = 0.9;
static float opt_nodes_per_sw = 5.0;
73 74 75 76 77
#ifdef PENALIZE_BANDWIDTH
static float SCORE_DIRECT_LINK = 0.0;/* Cost of a direct link */
static float SCORE_INTRASWITCH_LINK = 0.0;/* Cost of an intraswitch link*/
static float SCORE_INTERSWITCH_LINK = 0.0;/* Cost of an interswitch link*/
#else
78
static float SCORE_DIRECT_LINK = 0.01;/* Cost of a direct link */
79
static float SCORE_INTRASWITCH_LINK = 0.02;/* Cost of an intraswitch link*/
80 81 82
static float SCORE_INTERSWITCH_LINK = 0.2;/* Cost of an interswitch link*/
#endif
static float SCORE_DIRECT_LINK_PENALTY = 0.5;/* Cost of overused direct link*/
83
static float SCORE_NO_CONNECTION = 0.5;/* Cost of not filling a virt. link*/
84
static float SCORE_PNODE = 0.2;/* Cost of using a pnode*/
85 86
static float SCORE_PNODE_PENALTY = 0.5;/* Cost of overusing a pnode*/
static float SCORE_SWITCH = 0.5;/* Cost of using a switch.*/
87 88 89
static float SCORE_UNASSIGNED = 1.0;/* Cost of an unassigned node*/
static float SCORE_DESIRE = 1.0;/* Multiplier for desire costs*/
static float SCORE_FEATURE = 1.0;/* Multiplier for feature weights*/
Robert Ricci's avatar
Robert Ricci committed
90 91
static float SCORE_MISSING_LOCAL_FEATURE = 1.0;
static float SCORE_OVERUSED_LOCAL_FEATURE = 0.5;
92 93 94
#ifdef NO_PCLASS_PENALTY
static float SCORE_PCLASS = 0.0; /* Cost of each pclass */
#else
95
static float SCORE_PCLASS = 0.5; /* Cost of each pclass */
96 97
#endif
static float SCORE_VCLASS = 1.0; /* vclass score multiplier */
98
static float SCORE_EMULATED_LINK = 0.01; /* cost of an emualted link */
99 100 101 102 103 104
static float SCORE_OUTSIDE_DELAY = 0.5;	/* penalty for going out of delay
					   requirements */
static float SCORE_DELAY = 10.0; /* multiplier to distance for delay scoring */
#ifdef PENALIZE_UNUSED_INTERFACES
static float SCORE_UNUSED_INTERFACE = 0.04;
#endif
105
static float SCORE_TRIVIAL_PENALTY = 0.5; /* Cost of over-using a trivial link */
106

107 108 109 110 111
static float SCORE_TRIVIAL_MIX = 0.5; /* Cost of mixing trivial and non-trivial
					 links */

static float SCORE_SUBNODE = 0.5; /* Cost of not properly assigning subnodes */

112 113 114 115 116 117
// The following are used to weight possible link resolutions.  Higher
// numbers mean a more likely resolution.  Trivial resolutions are always
// used if possible.
static float LINK_RESOLVE_DIRECT = 4.0;
static float LINK_RESOLVE_INTRASWITCH = 2.0;
static float LINK_RESOLVE_INTERSWITCH = 1.0;
118

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
static struct config_param options[] = {
  { "IT",	CONFIG_INT,	&init_temp,			0 },
  { "OP",	CONFIG_INT,	&USE_OPTIMAL,			0 },
  { "TP",	CONFIG_INT,	&temp_prob,			0 },
  { "TS",	CONFIG_INT,	&temp_stop,			0 },
  { "CY",	CONFIG_INT,	&CYCLES,			0 },
  { "UN",	CONFIG_FLOAT,	&SCORE_UNASSIGNED,     		0 },
  { "DE",	CONFIG_FLOAT,	&SCORE_DESIRE,			0 },
  { "FE",	CONFIG_FLOAT,	&SCORE_FEATURE,			0 },
  { "1S",	CONFIG_FLOAT,	&SCORE_INTERSWITCH_LINK,	0 },
  { "2S",	CONFIG_FLOAT,	&SCORE_INTRASWITCH_LINK,	0 },
  { "NC",	CONFIG_FLOAT,	&SCORE_NO_CONNECTION,		0 },
  { "DL",	CONFIG_FLOAT,	&SCORE_DIRECT_LINK,		0 },
  { "DP",	CONFIG_FLOAT,	&SCORE_DIRECT_LINK_PENALTY,	0 },
  { "PN",	CONFIG_FLOAT,	&SCORE_PNODE,			0 },
  { "PP",	CONFIG_FLOAT,	&SCORE_PNODE_PENALTY,		0 },
135
  { "PC",	CONFIG_FLOAT,	&SCORE_PCLASS,		        0 },
136
  { "VC",       CONFIG_FLOAT,   &SCORE_VCLASS,                  0 },
137
  { "SW",	CONFIG_FLOAT,	&SCORE_SWITCH,			0 },
138
  { "EL",	CONFIG_FLOAT,	&SCORE_EMULATED_LINK,		0 },
139
  { "ON",	CONFIG_FLOAT,	&opt_nodes_per_sw,		0 },
140 141 142 143 144 145
  { "TR",	CONFIG_FLOAT,	&temp_rate,			0 },
  { "LD",       CONFIG_FLOAT,   &LINK_RESOLVE_DIRECT,           0 },
  { "LI",       CONFIG_FLOAT,   &LINK_RESOLVE_INTRASWITCH,      0 },
  { "LT",       CONFIG_FLOAT,   &LINK_RESOLVE_INTERSWITCH,      0 },
  { "OD",       CONFIG_FLOAT,   &SCORE_OUTSIDE_DELAY,           0 },
  { "DM",       CONFIG_FLOAT,   &SCORE_DELAY,                   0 }
146 147 148
};

static int noptions = sizeof(options) / sizeof(options[0]);
Mac Newbold's avatar
Mac Newbold committed
149

150 151 152 153 154 155 156 157 158 159 160 161
void parse_options(char **argv, struct config_param options[], int nopt);

struct eqstr
{
  bool operator()(const char* A, const char* B) const
  {
    return (! strcmp(A, B));
  }
};

enum edge_data_t {edge_data};
enum vertex_data_t {vertex_data};
Mac Newbold's avatar
Mac Newbold committed
162

163 164 165 166
namespace boost {
  BOOST_INSTALL_PROPERTY(edge,data);
  BOOST_INSTALL_PROPERTY(vertex,data);
}
Mac Newbold's avatar
Mac Newbold committed
167

168 169
typedef hash_map<crope,crope> name_name_map;
typedef slist<crope> name_slist;
Mac Newbold's avatar
Mac Newbold committed
170

171 172 173 174
/*
 * Used to count the number of nodes in each ptype and vtype
 */
typedef hash_map<crope,int> name_count_map;
175
typedef hash_map<crope,vector<crope> > name_list_map;
176

177 178 179
/*
 * A hash function for pointers
 */
180 181 182 183 184 185
template <class T> struct hashptr {
  size_t operator()(T const &A) const {
    return (size_t) A;
  }
};

186 187 188 189 190 191 192 193 194
/*
 * Misc. debugging stuff
 */
#ifdef ROB_DEBUG
#define RDEBUG(a) a
#else
#define RDEBUG(a)
#endif

195
#endif