101 | 101 |
|
102 | 102 |
if (verbosity < 2)
|
103 | 103 |
sprintf(command, "cat %s >> %s; %s %s > %s 2> /dev/null",
|
104 | |
ctlpfilename, lpfilename, lpsolver, lpfilename, lpoutfilename);
|
|
104 |
ctlpfilename, lpfilename, lpsolver, lpfilename, lpoutfilename);
|
105 | 105 |
else
|
106 | 106 |
sprintf(command, "cat %s >> %s; %s %s | tee %s",
|
107 | 107 |
ctlpfilename, lpfilename, lpsolver, lpfilename, lpoutfilename);
|
|
129 | 129 |
}
|
130 | 130 |
break;
|
131 | 131 |
case 'C':
|
132 | |
if (strncmp(command, "Coin:Infeasible - objective value", 33) == 0)
|
|
132 |
if ((strncmp(command, "Coin:Infeasible - objective value", 33) == 0) ||
|
|
133 |
(strncmp(command, "CPLEX> MIP - Integer infeasible.", 32) == 0))
|
133 | 134 |
status = 0;
|
134 | 135 |
else if (strncmp(command, "Coin:Optimal - objective value", 30) == 0) {
|
135 | 136 |
status = 1;
|
136 | 137 |
if (sscanf(command+30, "%d", &iobjval) > 0) objval = objvals[iobj] = iobjval;
|
|
138 |
} else if (strncmp(command, "CPLEX> MIP - Integer optimal solution: Objective = ", 52) == 0) {
|
|
139 |
status = 1;
|
|
140 |
if (sscanf(command+52, "%d", &iobjval) > 0) objval = objvals[iobj] = iobjval;
|
137 | 141 |
}
|
138 | 142 |
break;
|
139 | 143 |
}
|
|
148 | 152 |
for (int i = 0; i < nb_packages; i++) solution[i] = 0;
|
149 | 153 |
|
150 | 154 |
bool eos = false;
|
151 | |
while ((! eos) && (! feof(fsol)) && (fgets(command, 1000, fsol) != NULL))
|
|
155 |
while ((! eos) && (! feof(fsol)) && (fgets(command, 1000, fsol) != NULL)) {
|
152 | 156 |
switch (command[0]) {
|
153 | 157 |
case 'x':
|
154 | |
{
|
155 | |
int l = 0, v = 0;
|
156 | |
if ((l = sscanf(command+1, "%d", &rank)) > 0)
|
157 | |
if (sscanf(command+l+2, "%d", &v) > 0)
|
158 | |
if (v == 1)
|
159 | |
solution[rank] = 1;
|
160 | |
}
|
|
158 |
if (sscanf(command+1, "%d", &rank) > 0) solution[rank] = 1;
|
161 | 159 |
break;
|
162 | 160 |
case ' ':
|
163 | 161 |
{
|
164 | |
int i = 1, l = 0, v = 0;
|
|
162 |
int i = 1;
|
165 | 163 |
for (; ((command[i] != 'x') && (i < 1000)); i++);
|
166 | 164 |
if (command[i] == 'x')
|
167 | |
if ((l = sscanf(command+i+1, "%d", &rank)) > 0)
|
168 | |
if (sscanf(command+i+l+2, "%d", &v) > 0)
|
169 | |
if (v == 1)
|
170 | |
solution[rank] = 1;
|
171 | |
|
|
165 |
if (sscanf(command+i+1, "%d", &rank) > 0) solution[rank] = 1;
|
172 | 166 |
}
|
173 | 167 |
break;
|
174 | 168 |
case '\n':
|
175 | |
case 'C':
|
176 | 169 |
eos = true;
|
177 | 170 |
break;
|
178 | 171 |
}
|
|
172 |
}
|
179 | 173 |
} else if (status == 0)
|
180 | 174 |
break;
|
181 | 175 |
}
|