mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-29 08:17:20 +01:00
cody: lvlgraph: check best after shuffle
git-svn-id: trunk@40421 -
This commit is contained in:
parent
5f3d6729b0
commit
00ede9c2b3
@ -696,7 +696,7 @@ type
|
|||||||
procedure UnbindPairs;
|
procedure UnbindPairs;
|
||||||
procedure BindPairs;
|
procedure BindPairs;
|
||||||
function ComputeCrossCount: integer;
|
function ComputeCrossCount: integer;
|
||||||
procedure StoreAsBest;
|
procedure StoreAsBest(CheckIfBetter: boolean);
|
||||||
public
|
public
|
||||||
Graph: TLvlGraph;
|
Graph: TLvlGraph;
|
||||||
Levels: array of TMinXLevel;
|
Levels: array of TMinXLevel;
|
||||||
@ -729,7 +729,7 @@ begin
|
|||||||
g.InitSearch;
|
g.InitSearch;
|
||||||
Run:=0;
|
Run:=0;
|
||||||
g.SwitchAndShuffle(Graph.NodeCount*Graph.NodeCount div 3,
|
g.SwitchAndShuffle(Graph.NodeCount*Graph.NodeCount div 3,
|
||||||
Max(1000,Graph.NodeCount*Graph.NodeCount));
|
Max(10000,Graph.NodeCount*Graph.NodeCount));
|
||||||
g.Apply;
|
g.Apply;
|
||||||
finally
|
finally
|
||||||
g.Free;
|
g.Free;
|
||||||
@ -1148,15 +1148,17 @@ end;
|
|||||||
|
|
||||||
procedure TMinXGraph.InitSearch;
|
procedure TMinXGraph.InitSearch;
|
||||||
begin
|
begin
|
||||||
StoreAsBest;
|
StoreAsBest(false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMinXGraph.StoreAsBest;
|
procedure TMinXGraph.StoreAsBest(CheckIfBetter: boolean);
|
||||||
var
|
var
|
||||||
l: Integer;
|
l: Integer;
|
||||||
Level: TMinXLevel;
|
Level: TMinXLevel;
|
||||||
n: Integer;
|
n: Integer;
|
||||||
begin
|
begin
|
||||||
|
if CheckIfBetter and (BestCrossCount>=0) and (BestCrossCount<CrossCount) then
|
||||||
|
exit;
|
||||||
BestCrossCount:=CrossCount;
|
BestCrossCount:=CrossCount;
|
||||||
for l:=0 to length(Levels)-1 do begin
|
for l:=0 to length(Levels)-1 do begin
|
||||||
Level:=Levels[l];
|
Level:=Levels[l];
|
||||||
@ -1215,6 +1217,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
BindPairs;
|
BindPairs;
|
||||||
|
StoreAsBest(true);
|
||||||
{$IFDEF CheckMinXGraph}
|
{$IFDEF CheckMinXGraph}
|
||||||
ConsistencyCheck;
|
ConsistencyCheck;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1296,8 +1299,7 @@ begin
|
|||||||
for j:=0 to length(Node2.InEdges)-1 do
|
for j:=0 to length(Node2.InEdges)-1 do
|
||||||
UpdateSwitchDiff(Node1.InEdges[i],Node2.InEdges[j]);
|
UpdateSwitchDiff(Node1.InEdges[i],Node2.InEdges[j]);
|
||||||
|
|
||||||
if (BestCrossCount<0) or (BestCrossCount>CrossCount) then
|
StoreAsBest(true);
|
||||||
StoreAsBest;
|
|
||||||
|
|
||||||
{$IFDEF CheckMinXGraph}
|
{$IFDEF CheckMinXGraph}
|
||||||
ConsistencyCheck;
|
ConsistencyCheck;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user