Skip to content
Snippets Groups Projects
Commit c9f286a8 authored by Markus Baumeister's avatar Markus Baumeister
Browse files

Use the proper AttributeScheduler-package.

parent 99bb321d
No related branches found
No related tags found
No related merge requests found
...@@ -76,7 +76,7 @@ PackageDoc := rec( ...@@ -76,7 +76,7 @@ PackageDoc := rec(
Dependencies := rec( Dependencies := rec(
GAP := ">= 4.8", GAP := ">= 4.8",
NeededOtherPackages := [ [ "Grape", ">=4.7" ]], NeededOtherPackages := [ [ "Grape", ">=4.7" ], [ "AttributeScheduler", ">=2017.10.06" ]],
SuggestedOtherPackages := [ [ "GAPDoc", ">= 1.6" ], ["AutoDoc", ">=2017.09.15"], [ "IO", ">=2.2" ], [ "NautyTracesInterface", ">0.1" ] ], SuggestedOtherPackages := [ [ "GAPDoc", ">= 1.6" ], ["AutoDoc", ">=2017.09.15"], [ "IO", ">=2.2" ], [ "NautyTracesInterface", ">0.1" ] ],
ExternalConditions := [ ], ExternalConditions := [ ],
), ),
......
...@@ -4,13 +4,24 @@ The GAP 4 package `SimplicialSurfaces' ...@@ -4,13 +4,24 @@ The GAP 4 package `SimplicialSurfaces'
To use this package, go into your local installation directory for GAP To use this package, go into your local installation directory for GAP
(often located under /opt/gap* ), and clone the repository in the (often located under /opt/gap* ), and clone the repository in the
pkg/-subfolder: pkg/-subfolder:
cd pkg/
cd pkg/
git clone https://github.com/markusbaumeister/simplicial-surfaces.git git clone https://github.com/markusbaumeister/simplicial-surfaces.git
You also need the NautyTracesInterface for isomorphism checks:
You also need the following package:
git clone https://github.com/sebasguts/AttributeScheduler.git
It is suggested that you also use the NautyTracesInterface for faster
isomorphism checks:
git clone https://github.com/sebasguts/NautyTracesInterface.git git clone https://github.com/sebasguts/NautyTracesInterface.git
To initialize it, perform the steps in the README of that package (this needs To initialize it, perform the steps in the README of that package (this needs
automake and libtools and probably something else that I do not know) automake and libtools and probably something else that I do not know)
Then Then
LoadPackage("SimplicialSurfaces") LoadPackage("SimplicialSurfaces")
can be used to access the package inside a GAP session. can be used to access the package inside a GAP session.
......
#############################################################################
##
## AttributeSchedulerGraph
##
## Copyright 2017, Markus Baumeister, RWTH Aachen
## Sebastian Gutsche, Siegen University
##
##! @Chapter Attrubte scheduler Graph
##
#############################################################################
DeclareGlobalFunction( "__ATTRIBUTESCHEDULER_evaluate_recursive" );
DeclareCategory( "IsAttributeSchedulerGraph", IsObject );
#! @BeginGroup
#! @Description
#! Constructor for the attribute scheduler graph.
#! Takes an optional argument <A>l</A>, which is a list of
#! strings and serves as nodes for the graph. Nodes can always be added
#! by adding edges via <C>AddPropertyIncidence</C>.
#! @Returns An attribute scheduling graph
#! @Arguments [l]
DeclareOperation( "AttributeSchedulerGraph", [ ] );
DeclareOperation( "AttributeSchedulerGraph", [ IsList ] );
#! @EndGroup
#! @Description
#! Add an attribute to the attribute scheduler graph. This method will
#! install a method for the attribute that calls the attribute
#! scheduler graph.
#! <Par/>
#! Careful: Due to a limitation of GAP, attributes and filter can only
#! be given as general objects
#! @Arguments graph, attribute, filter, description
DeclareOperation( "AddAttribute", [IsAttributeSchedulerGraph, IsObject, IsObject, IsString] );
#! @Arguments graph,property,requirements
#! @Description
#! Adds an edge to <Agraph</A>. Tells the graph that the property <A>property</A> can
#! be computed if the properties in <A>requirements</A> are computed. All names
#! must be given as string.
DeclareOperation( "AddPropertyIncidence", [ IsAttributeSchedulerGraph, IsString, IsList ] );
#! @Arguments graph,attribute,object
#! @Returns Value for <A>attribute</A>
#! Checks the attribute scheduler graph <A>graph</A> if there is a way to compute
#! <A>attribute</A> for <A>object</A>. If so, the value is returned. If not, an error
#! is raised.
DeclareOperation( "ComputeProperty", [ IsAttributeSchedulerGraph, IsFunction, IsObject ] );
#############################################################################
##
## AttributeSchedulerGraph
##
## Copyright 2017, Markus Baumeister, RWTH Aachen
## Sebastian Gutsche, Siegen University
##
#############################################################################
DeclareRepresentation( "IsAttributeSchedulerGraphRep",
IsAttributeSchedulerGraph and IsAttributeStoringRep,
[ ] );
BindGlobal( "TheFamilyOfAttributeSchedulerGraphs",
NewFamily( "TheFamilyOfAttributeSchedulerGraphs" ) );
BindGlobal( "TheTypeAttributeSchedulerGraph",
NewType( TheFamilyOfAttributeSchedulerGraphs,
IsAttributeSchedulerGraphRep ) );
##
InstallMethod( AttributeSchedulerGraph,
[ ],
function( )
return AttributeSchedulerGraph( [ ] );
end );
##
InstallMethod( AttributeSchedulerGraph,
[ IsList ],
function( methods )
local graph, i;
graph := rec( );
for i in methods do
graph.(i) := [ ];
od;
Objectify( TheTypeAttributeSchedulerGraph, graph );
return graph;
end );
InstallMethod( AddPropertyIncidence,
[ IsAttributeSchedulerGraph, IsString, IsList ],
function( graph, property_to_compute, property_depends_on )
local name;
# Check whether the elements of property_depends_on are already part
# of the graph
for name in property_depends_on do
if not IsBound( graph!.(name) ) then
graph!.(name) := [];
fi;
od;
# Check whether property_to_compute is already part of the graph
if not IsBound( graph!.(property_to_compute) ) then
graph!.(property_to_compute) := [];
fi;
Add( graph!.(property_to_compute), property_depends_on );
end );
InstallOtherMethod( AddPropertyIncidence,
[ IsAttributeSchedulerGraph, IsString, IsString ],
function( graph, property_to_compute, property_depends_on )
AddPropertyIncidence( graph, property_to_compute, [ property_depends_on ] );
end );
InstallGlobalFunction( __ATTRIBUTESCHEDULER_evaluate_recursive,
function( graph, name_property, object, spanning_tree )
local i, props;
if spanning_tree.( name_property ) = 0 then
return ValueGlobal( name_property )( object );
fi;
props := graph!.( name_property )[ spanning_tree.( name_property ) ];
for i in props do
__ATTRIBUTESCHEDULER_evaluate_recursive( graph, i, object, spanning_tree );
od;
return ValueGlobal( name_property )( object );
end );
InstallMethod( ComputeProperty,
[ IsAttributeSchedulerGraph, IsFunction, IsObject ],
function( graph, property, object )
local all_names, how_to_compute, i, property_name, possibilities, max, j;
all_names := NamesOfComponents( graph );
how_to_compute := rec();
for i in all_names do
how_to_compute.( i ) := -1;
od;
for i in [ 1 .. Length( all_names ) ] do
if Tester( ValueGlobal( all_names[ i ] ) )( object ) then
how_to_compute.( all_names[ i ] ) := 0;
fi;
od;
property_name := NameFunction( property );
if how_to_compute.( property_name ) > -1 then
return property( object );
fi;
for max in [ 1 .. Length( all_names ) ] do
for i in [ 1 .. Length( all_names ) ] do
if how_to_compute.( all_names[ i ] ) > -1 then
continue;
fi;
possibilities := graph!.( all_names[ i ] );
for j in [ 1 .. Length( possibilities ) ] do
if ForAll( possibilities[ j ], k -> how_to_compute.( k ) > -1 ) then
how_to_compute.( all_names[ i ] ) := j;
break;
fi;
od;
od;
if how_to_compute.( property_name ) > -1 then
break;
fi;
od;
if how_to_compute.( property_name ) = -1 then
Error( "cannot compute property" );
fi;
return __ATTRIBUTESCHEDULER_evaluate_recursive( graph, property_name, object, how_to_compute );
end );
InstallMethod( AddAttribute,
[IsAttributeSchedulerGraph, IsObject, IsObject, IsString],
function(graph, attr, filter, descr)
InstallMethod( attr, descr, [filter],
function(obj)
return ComputeProperty(graph, attr, obj);
end);
end
);
##
InstallMethod( ViewObj,
[ IsAttributeSchedulerGraph ],
function( graph )
Print( "<Attribute scheduler graph>" );
end );
##
InstallMethod( Display,
[ IsAttributeSchedulerGraph ],
function( graph )
Print( "Attribute scheduler graph" );
end );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment