Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilan Tchernowitz committed Aug 7, 2014
1 parent 2481cc2 commit e50c017
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addToConf.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
% parallel with all the targets until the end of conf
endOflastNonParallelableTarget = confTimes(find(currConf == oldConfSize),2);
for t=oldConfSize:-1:1
if (missionLink(targetID,t) > 0)
if (missionLink(targetID,find(currConf == t)) == 1)
if (t == 1)
endOflastNonParallelableTarget = confTimes(find(currConf == t),1);
else
Expand Down
43 changes: 43 additions & 0 deletions findRealConfParralel.m
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
7 changes: 6 additions & 1 deletion getRealConf.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
end
% output => col1 = targetID, col2 = start time, col3 = end time col4 =
% val
realConf = findRealConf(sortedTargetsData,zeros(confSize,4),0,takeoffTime,takeoffTime + flightTime,1,speed,v);
% realConf = findRealConf(sortedTargetsData,zeros(confSize,4),0,takeoffTime,takeoffTime + flightTime,1,speed,v);
numTargets = size(targetsData,1);
confTimes = zeros(numTargets,2);
tempConf = zeros(numTargets,1);
realConf = findRealConfParralel(sortedTargetsData,zeros(confSize,4),tempConf,confTimes,0 ,takeoffTime,takeoffTime + flightTime,speed,numTargets,v);
%findRealConfParralel(sortedTargetsData,currRealConf ,tempConf,confTimes,currConfSize,takeoffTime,finishTime ,speed,numTargets,v)
end


Expand Down

0 comments on commit e50c017

Please sign in to comment.