Skip to content

Commit

Permalink
Move into seperate interface files
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisJefferson committed Aug 26, 2024
1 parent b639452 commit fb8b821
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 82 deletions.
12 changes: 0 additions & 12 deletions gap/GraphBacktracking.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,7 @@
# Implementations
#

DeclareGlobalFunction( "GB_SimpleSearch" );

DeclareGlobalFunction( "GB_SimpleSinglePermSearch" );

DeclareGlobalFunction( "GB_SimpleAllPermSearch" );

DeclareGlobalFunction( "GB_CheckInitialGroup" );
DeclareGlobalFunction( "GB_CheckInitialCoset" );

#! @Description
#! Information about backtrack search
InfoGB := InfoBTKit;

# Merge infos
#DeclareInfoClass( "InfoGB" );
#SetInfoLevel(InfoGB, 0);
70 changes: 2 additions & 68 deletions gap/GraphBacktracking.gi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ InstallMethod(ApplyFilters, [IsGBState, IsTracer, IsObject],
return false;
fi;

if not IsList(filters) then
if not IsList(filters) then
filters := [filters];
fi;

Expand Down Expand Up @@ -119,7 +119,7 @@ end);
_GB.DefaultConfig :=
rec(cellSelector := BranchSelector_MinSizeCell, consolidator := GB_MakeEquitableStrong);

InstallMethod(ConsolidateState, [IsGBState, IsTracer],
InstallMethod(ConsolidateState, [IsGBState, IsTracer],
function(state, tracer)
return state!.config.consolidator(state!.ps, tracer, state!.graphs);
end);
Expand All @@ -128,69 +128,3 @@ _GB.BuildProblem :=
{ps, conlist, conf} -> Objectify(GBStateType, rec(ps := ps, conlist := conlist, graphs := [], raw_graphs := [],
config := _BTKit.FillConfig(conf, _GB.DefaultConfig)));

InstallGlobalFunction( GB_SimpleSearch,
{ps, conlist, conf...} -> _BTKit.SimpleSearch(_GB.BuildProblem(ps, conlist, conf)));

InstallGlobalFunction( GB_SimpleSinglePermSearch,
function(ps, conlist, conf...)
local ret;
ret := _BTKit.SimpleSinglePermSearch(_GB.BuildProblem(ps, conlist, conf), true);
if IsEmpty(ret) then
return fail;
else
return ret[1];
fi;
end);

InstallGlobalFunction( GB_SimpleAllPermSearch,
{ps, conlist, conf...} -> _BTKit.SimpleSinglePermSearch(_GB.BuildProblem(ps, conlist, conf), false));

#! Build the initial graph stack, and return the automorphisms
#! of this graph stack. second argument is if this is the solution
#! (if not it will be a super-group of the solutions).
InstallGlobalFunction( GB_CheckInitialGroup,
function(ps, conlist)
local state, tracer, sols, saved, gens, ret;
state := _GB.BuildProblem(ps, conlist,[]);
tracer := RecordingTracer();
saved := SaveState(state);
InitialiseConstraints(state, tracer, true);

sols := _GB.AutoAndCanonical(state!.ps, state!.graphs);
gens := GeneratorsOfGroup(sols.grp);
gens := List(gens, x -> PermList(ListPerm(x, PS_Points(state!.ps))));

ret := ForAll(gens, p -> BTKit_CheckSolution(p, state!.conlist));

RestoreState(state, saved);
return rec(gens := gens, answer := ret);
end);


InstallGlobalFunction( GB_CheckInitialCoset,
function(ps, conlist)
local state, tracer, rbase, sols1, sols2, saved, autgraph1, autgraph2;
state := _GB.BuildProblem(ps, conlist,[]);
tracer := RecordingTracer();
saved := SaveState(state);
InitialiseConstraints(state, tracer, true);

sols1 := _GB.AutoAndCanonical(state!.ps, state!.graphs);

RestoreState(state, saved);

rbase := BuildRBase(state, state!.config.cellSelector);
FinaliseRBaseForConstraints(state, rbase);

tracer := RecordingTracer();
saved := SaveState(state);
InitialiseConstraints(state, tracer, false);

sols2 := _GB.AutoAndCanonical(state!.ps, state!.graphs);

RestoreState(state, saved);

autgraph1 := [OnDigraphs(sols1.graph[1], sols1.canonicalperm), List(sols1.graph[2], x -> OnSets(x, sols1.canonicalperm))];
autgraph2 := [OnDigraphs(sols2.graph[1], sols2.canonicalperm), List(sols2.graph[2], x -> OnSets(x, sols2.canonicalperm))];
return rec(graph1 := autgraph1, graph2 := autgraph2, equal := autgraph1 = autgraph2);
end);
3 changes: 2 additions & 1 deletion init.g
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#

if not IsBound(_BT_SKIP_INTERFACE) then
ReadPackage( "GraphBacktracking", "gap/GraphBacktracking.gd");
ReadPackage( "GraphBacktracking", "gap/interface.gd");
fi;

ReadPackage( "GraphBacktracking", "gap/GraphBacktracking.gd");
ReadPackage( "GraphBacktracking", "gap/Equitable.gd");
3 changes: 2 additions & 1 deletion read.g
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
_GB := AtomicRecord(rec());

if not IsBound(_BT_SKIP_INTERFACE) then
ReadPackage( "GraphBacktracking", "gap/GraphBacktracking.gi");
ReadPackage( "GraphBacktracking", "gap/interface.gi");
fi;

ReadPackage( "GraphBacktracking", "gap/GraphBacktracking.gi");
ReadPackage( "GraphBacktracking", "gap/Equitable.gi");
ReadPackage( "GraphBacktracking", "gap/constraints/simpleconstraints.g");
ReadPackage( "GraphBacktracking", "gap/constraints/normaliser.g");
Expand Down

0 comments on commit fb8b821

Please sign in to comment.