Debian Codegraph @

SYMPHONY/Applications/VRP/src/Master/Heuristics/exchange_heur.c

raw
1 /*===========================================================================*/
2 /* */
3 /* This file is part of a demonstration application for use with the */
4 /* SYMPHONY Branch, Cut, and Price Library. This application is a solver for */
5 /* the Vehicle Routing Problem and the Traveling Salesman Problem. */
6 /* */
7 /* This application was developed by Ted Ralphs ([email protected]) */
8 /* This file was modified by Ali Pilatin January, 2005 ([email protected]) */
9 /* */
10 /* (c) Copyright 2000-2005 Ted Ralphs. All Rights Reserved. */
11 /* */
12 /* This software is licensed under the Common Public License. Please see */
13 /* accompanying file for terms. */
14 /* */
15 /*===========================================================================*/
16
17 #include <stdio.h>
18 #include <memory.h>
19 #include <stdlib.h>
20
21 #include "exchange_heur.h"
22 #include "vrp_master_functions.h"
23 #include "vrp_const.h"
24 #include "sym_proccomm.h"
25
26 void exchange_heur(vrp_problem *vrp, heurs *eh, int trials, int jobs,
27 int which, int *tids, int *sent)
28 {
29 int i, info, dummy;
30 int s_bufid;
31 _node *tour;
32 best_tours tours;
33
34 if (vrp->par.verbosity >1){
35 if (which == FIRST_SET)
36 printf("\nNow beginning first set of exchange heuristics ....\n\n");
37 else if (which == SECOND_SET)
38 printf("\nNow beginning second set of exchange heuristics ....\n\n");
39 }
40
41 eh->tids = tids;
42 eh->jobs = trials;
43
44 if (trials)
45 for (i=0; i < eh->jobs; i++){
46 PVM_FUNC(s_bufid, pvm_initsend(PvmDataRaw));
47 PVM_FUNC(info, pvm_pkint(&dummy, 1, 1));
48 PVM_FUNC(info, pvm_send(tids[i%jobs], which ? S_EXCHANGE : S_EXCHANGE2));
49 sent[i%jobs]++;
50 }
51
52 if (jobs == 0){
53 fprintf(stderr, "\nNo jobs started... \n\n");
54 return;
55 }
56 else if (vrp->par.verbosity >2)
57 printf("\n%i jobs started ....\n\n", jobs);
58
59
60 /*-----------------------------------------------------------------------*\
61 | Broadcast data to the processes |
62 \*-----------------------------------------------------------------------*/
63
64 //data is already sent by start_heurs.c
65
66 /*-----------------------------------------------------------------------*\
67 | Broadcast best tours to the processes |
68 \*-----------------------------------------------------------------------*/
69
70 for (i=0; i<eh->jobs; i++){
71 s_bufid = init_send(DataInPlace);
72 tours = vrp->tours[vrp->tourorder[i%(vrp->tournum+1)]];
73 tour = tours.tour;
74 send_char_array((char *)&tours, sizeof(best_tours));
75 send_char_array((char *)tour, (vrp->vertnum)*sizeof(_node));
76 send_msg(tids[i%jobs],EXCHANGE_HEUR_TOUR);
77 }
78 }
79
80