-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ilan Tchernowitz
committed
Aug 7, 2014
1 parent
2481cc2
commit e50c017
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function[RealConf] = findRealConfParralel(sortedTargetsData,currRealConf,tempConf,confTimes,currConfSize,takeoffTime,finishTime,speed,numTargets,v) | ||
|
||
ID_COL =1; | ||
VAL_COL =3; | ||
DURATION_COL =6; | ||
|
||
% if curr realConf is full, return it | ||
if (currConfSize == size(currRealConf,1)) | ||
RealConf = currRealConf; | ||
return; | ||
end | ||
|
||
% find the next candidate, or return an empty conf to signal that no | ||
% one was found | ||
for (i = 1:size(sortedTargetsData,1)) | ||
|
||
currID = sortedTargetsData(i,ID_COL); | ||
currWasScheduled = currRealConf(currRealConf(:,ID_COL) == currID,:); | ||
% if this one is already in the conf, skip it | ||
if (size(currWasScheduled,1) == 0) | ||
% check if can schedule it next | ||
duration = sortedTargetsData(i,DURATION_COL); | ||
[success,confNew,confTimesNew] = addToConf(tempConf,confTimes,currID,takeoffTime,finishTime,speed,currConfSize); | ||
|
||
if (success) | ||
% add this row, and call the recursive function again | ||
tempCurrRealConf = currRealConf; | ||
val = sortedTargetsData(i,VAL_COL); | ||
val = 8 - val; | ||
tempCurrRealConf(currConfSize + 1,:) = [currID,confTimesNew(currID,1),confTimesNew(currID,2),val]; | ||
% recursive call | ||
foundConf = findRealConfParralel(sortedTargetsData,tempCurrRealConf,confNew,confTimesNew,currConfSize + 1,takeoffTime,finishTime,speed,numTargets,v); | ||
% if found conf is not good, continue, else - return it | ||
if (size(foundConf,1) > 0 ) | ||
RealConf = foundConf; | ||
return | ||
end | ||
end | ||
end | ||
end | ||
% if we got here - there is no feasible conf, return an empty matrix | ||
RealConf = zeros(0,0); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters