Set initial bestSolution to all INT_MAX and if all INT_MAX set
bestSolutionLength to 17
This commit is contained in:
parent
5398b9dccd
commit
029ce6264f
17
supervisor.c
17
supervisor.c
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <limits.h>
|
||||
|
||||
static const char *pname;
|
||||
|
||||
@ -67,7 +68,7 @@ void initCircBuf()
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
bestSolution[i] = -1;
|
||||
bestSolution[i] = INT_MAX;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -107,20 +108,24 @@ void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace)
|
||||
int newSolutionLength = 0;
|
||||
|
||||
// Compute length of current bestSolution
|
||||
if (bestSolution[0] != -1) {
|
||||
if ((bestSolution[0] != -1) && (bestSolution[0] != INT_MAX)) {
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
if (bestSolution[i] == -1) {
|
||||
bestSolutionLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (bestSolution[0] == INT_MAX) {
|
||||
bestSolutionLength = 17;
|
||||
}
|
||||
|
||||
// Compute length of newSolution
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
if ((solution[i] == -1) && (i != 0)) {
|
||||
newSolutionLength = i+1;
|
||||
break;
|
||||
if (solution[0] != -1) {
|
||||
for (int i = 0; i < MAX_ITEMS; i++) {
|
||||
if (solution[i] == -1) {
|
||||
newSolutionLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user