This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathfcisep.cpp
133 lines (115 loc) · 3.72 KB
/
fcisep.cpp
1
2
3
4
5
6
7
8
9
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* SAS modified this file. */
/* (C) Copyright 2003 Jens Lysgaard. All rights reserved. */
/* OSI Certified Open Source Software */
/* This software is licensed under the Common Public License Version 1.0 */
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include "memmod.h"
#include "basegrph.h"
#include "cnstrmgr.h"
#include "compress.h"
#include "capsep.h"
#include "fcits.h"
void FCISEP_SeparateFCIs(int NoOfCustomers,
const double *Demand,
double CAP,
int NoOfEdges,
const int *EdgeTail,
const int *EdgeHead,
const double *EdgeX,
CnstrMgrPointer CMPExistingCuts,
int MaxNoOfTreeNodes,
int MaxNoOfCuts,
double EpsViolation,
double *MaxViolation,
CnstrMgrPointer CutsCMP)
{
int i,j,k;
int GeneratedCuts;
int NoOfV1Cuts;
int ShrunkGraphCustNodes;
int MaxFCITSLoops;
double *SuperDemand;
double *XInSuperNode;
double **XMatrix;
double **SMatrix;
ReachPtr SupportPtr;
ReachPtr V1CutsPtr;
ReachPtr SAdjRPtr;
ReachPtr SuperNodesRPtr;
#ifdef DEBUG
for (i=1; i<=NoOfEdges; i++){
assert(EdgeTail[i] <= NoOfCustomers+1);
assert(EdgeHead[i] <= NoOfCustomers+1);
}
#endif
ReachInitMem(&SupportPtr,NoOfCustomers+1);
ReachInitMem(&SAdjRPtr,NoOfCustomers+1);
ReachInitMem(&SuperNodesRPtr,NoOfCustomers+1);
SuperDemand = MemGetDV(NoOfCustomers+1);
XInSuperNode = MemGetDV(NoOfCustomers+1);
SMatrix = MemGetDM(NoOfCustomers+2,NoOfCustomers+2);
XMatrix = MemGetDM(NoOfCustomers+2,NoOfCustomers+2);
for (i=1; i<=NoOfCustomers+1; i++)
for (j=1; j<=NoOfCustomers+1; j++)
XMatrix[i][j] = 0.0;
for (i=1; i<=NoOfEdges; i++)
{
ReachAddForwArc(SupportPtr,EdgeTail[i],EdgeHead[i]);
ReachAddForwArc(SupportPtr,EdgeHead[i],EdgeTail[i]);
XMatrix[EdgeTail[i]][EdgeHead[i]] = EdgeX[i];
XMatrix[EdgeHead[i]][EdgeTail[i]] = EdgeX[i];
}
V1CutsPtr = NULL;
CAPSEP_GetOneVehicleCapCuts(CMPExistingCuts,
&V1CutsPtr,
&NoOfV1Cuts);
COMPRESS_ShrinkGraph(SupportPtr,
NoOfCustomers,
XMatrix,
SMatrix,
NoOfV1Cuts,
V1CutsPtr,
SAdjRPtr,
SuperNodesRPtr,
&ShrunkGraphCustNodes);
ReachFreeMem(&V1CutsPtr);
/* Compute data of supernodes */
//printf("ShrunkGraphCustNodes:%d\n",ShrunkGraphCustNodes);
for (i=1; i<=ShrunkGraphCustNodes; i++)
{
XInSuperNode[i] = SMatrix[i][i];
SuperDemand[i] = 0;
for (j=1; j<=SuperNodesRPtr->LP[i].CFN; j++)
{
k = SuperNodesRPtr->LP[i].FAL[j];
SuperDemand[i] += Demand[k];
//printf("Shrunk i:%d k:%d SuperDemand:%d\n",i,k,SuperDemand[i]);
}
}
/* Ready to call FCI separation */
MaxFCITSLoops = MaxNoOfTreeNodes;
FCITS_MainCutGen(SupportPtr,
NoOfCustomers,
Demand,
CAP,
XMatrix,
SuperNodesRPtr,
SAdjRPtr,
SuperDemand,
ShrunkGraphCustNodes,
MaxFCITSLoops,
MaxNoOfCuts,
EpsViolation,
MaxViolation,
&GeneratedCuts,
CutsCMP);
MemFree(SuperDemand);
MemFree(XInSuperNode);
MemFreeDM(SMatrix,NoOfCustomers+2);
MemFreeDM(XMatrix,NoOfCustomers+2);
ReachFreeMem(&SupportPtr);
ReachFreeMem(&SAdjRPtr);
ReachFreeMem(&SuperNodesRPtr);
}