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

#ifndef _SCORE_H
#define _SCORE_H

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*
 * 'optimal' score - computes a lower bound on the optimal score for this
 * mapping, so that if we find this score, we know we're done and can exit
 * early.
 */
#ifdef USE_OPTIMAL
#define OPTIMAL_SCORE(edges,nodes) (nodes*SCORE_PNODE + \
                                    nodes/opt_nodes_per_sw*SCORE_SWITCH + \
                                    edges*((SCORE_INTRASWITCH_LINK+ \
                                    SCORE_DIRECT_LINK*2)*4+\
                                    SCORE_INTERSWITCH_LINK)/opt_nodes_per_sw)
#else
#define OPTIMAL_SCORE(edges,nodes) 0
#endif

/*
 * Details about which violations are present
 */
class violated_info {

    /* Spit out the current violations (details only, not the total) */
    friend ostream &operator<<(ostream &o, const violated_info &vinfo) {
32 33 34 35 36 37 38 39
	o << "  unassigned:  " << vinfo.unassigned << endl;
	o << "  pnode_load:  " << vinfo.pnode_load << endl;
	o << "  no_connect:  " << vinfo.no_connection << endl;
	o << "  link_users:  " << vinfo.link_users << endl;
	o << "  bandwidth:   " << vinfo.bandwidth << endl;
	o << "  desires:     " << vinfo.desires << endl;
	o << "  vclass:      " << vinfo.vclass << endl;
	o << "  delay:       " << vinfo.delay << endl;
40 41
	o << "  trivial mix: " << vinfo.trivial_mix << endl;
	o << "  subnodes:    " << vinfo.subnodes << endl;
42
	o << "  max_types:   " << vinfo.max_types << endl;
43
#ifdef FIX_PLINK_ENDPOINTS
44
	o << "  endpoints:   " << vinfo.incorrect_endpoints << endl;
45 46 47 48 49 50 51 52
#endif
	return o;
    }
    
    public: /* No real reason to hide this stuff */
	violated_info():
	    unassigned(0), pnode_load(0), no_connection(0), link_users(0),
	    bandwidth(0), desires(0), vclass(0), delay(0),
53 54
	    incorrect_endpoints(0), trivial_mix(0), subnodes(0), max_types(0)
	{ }
55 56 57 58 59 60 61 62 63 64

	int unassigned;
	int pnode_load;
	int no_connection;
	int link_users;
	int bandwidth;
	int desires;
	int vclass;
	int delay;
	int incorrect_endpoints;
65
	int trivial_mix;
66
	int subnodes;
67
	int max_types;
68
};
Mac Newbold's avatar
Mac Newbold committed
69

70
extern double score;
Mac Newbold's avatar
Mac Newbold committed
71 72
extern int violated;
extern violated_info vinfo;
73
extern bool allow_trivial_links;
Robert Ricci's avatar
Robert Ricci committed
74
extern bool greedy_link_assignment;
Mac Newbold's avatar
Mac Newbold committed
75

76 77 78
/*
 * Scoring functions
 */
Mac Newbold's avatar
Mac Newbold committed
79
void init_score();
80
void remove_node(vvertex vv);
81
int add_node(vvertex vv,pvertex pv,bool deterministic, bool is_fixed);
82 83 84
double get_score();
pvertex make_lan_node(vvertex vv);
void delete_lan_node(pvertex pv);
Mac Newbold's avatar
Mac Newbold committed
85 86

#endif