score.h 2.21 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/*
 * '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) {
	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;
#ifdef FIX_PLINK_ENDPOINTS
	o << "  endpoints:  " << vinfo.incorrect_endpoints << endl;
#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),
	    incorrect_endpoints(0) { }

	int unassigned;
	int pnode_load;
	int no_connection;
	int link_users;
	int bandwidth;
	int desires;
	int vclass;
	int delay;
	int incorrect_endpoints;
};
Mac Newbold's avatar
Mac Newbold committed
62

63
extern double score;
Mac Newbold's avatar
Mac Newbold committed
64 65
extern int violated;
extern violated_info vinfo;
66
extern bool allow_trivial_links;
Mac Newbold's avatar
Mac Newbold committed
67

68 69 70
/*
 * Scoring functions
 */
Mac Newbold's avatar
Mac Newbold committed
71
void init_score();
72 73 74
void remove_node(vvertex vv);
int add_node(vvertex vv,pvertex pv,bool deterministic);
double get_score();
Christopher Alfeld's avatar
 
Christopher Alfeld committed
75
double fd_score(tb_vnode &vnoder,tb_pnode &pnoder,int *fd_violated);
76 77
pvertex make_lan_node(vvertex vv);
void delete_lan_node(pvertex pv);
Mac Newbold's avatar
Mac Newbold committed
78 79

#endif