Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gboml
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smart_grids
public
gboml
Commits
df47c3d8
Commit
df47c3d8
authored
2 years ago
by
Derval Guillaume
Browse files
Options
Downloads
Patches
Plain Diff
Remove classes for old import syntax, and convert between both
parent
f12e276b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#10649
passed
2 years ago
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/gboml/ast/__init__.py
+1
-1
1 addition, 1 deletion
src/gboml/ast/__init__.py
src/gboml/ast/hyperedges.py
+0
-8
0 additions, 8 deletions
src/gboml/ast/hyperedges.py
src/gboml/ast/nodes.py
+2
-11
2 additions, 11 deletions
src/gboml/ast/nodes.py
src/gboml/parsing.py
+8
-4
8 additions, 4 deletions
src/gboml/parsing.py
with
11 additions
and
24 deletions
src/gboml/ast/__init__.py
+
1
−
1
View file @
df47c3d8
...
...
@@ -4,7 +4,7 @@ __all__ = [
"
VarOrParam
"
,
"
Array
"
,
"
Loop
"
,
"
BaseLoop
"
,
"
Function
"
,
"
BoolExpressionOp
"
,
"
BoolExpressionComparison
"
,
"
ScopeChange
"
,
"
ImportFile
"
,
"
Definition
"
,
"
Constraint
"
,
"
StdConstraint
"
,
"
SOSConstraint
"
,
"
Objective
"
,
"
VariableDefinition
"
,
"
Node
"
,
"
HyperEdge
"
,
"
NodeDefinition
"
,
"
NodeImport
"
,
"
HyperEdgeDefinition
"
,
"
HyperEdgeImport
"
,
"
HyperEdge
"
,
"
NodeDefinition
"
,
"
HyperEdgeDefinition
"
,
"
ExpressionOp
"
,
"
GBOMLGraph
"
,
"
ImplicitLoop
"
,
"
RValue
"
,
"
RValueWithGen
"
,
"
GeneratedRValue
"
,
"
Range
"
,
"
MultiLoop
"
,
"
DictEntry
"
,
"
Dictionary
"
,
"
NodeGenerator
"
,
"
HyperEdgeGenerator
"
,
"
DefinitionType
"
,
"
FunctionDefinition
"
,
"
ConstantDefinition
"
,
"
ExpressionDefinition
"
,
...
...
This diff is collapsed.
Click to expand it.
src/gboml/ast/hyperedges.py
+
0
−
8
View file @
df47c3d8
...
...
@@ -33,11 +33,3 @@ class HyperEdgeGenerator(HyperEdge):
constraints
:
list
[
Constraint
]
=
field
(
default_factory
=
list
)
activations
:
list
[
CtrActivation
]
=
field
(
default_factory
=
list
)
tags
:
list
[
str
]
=
field
(
default_factory
=
list
)
@dataclass
class
HyperEdgeImport
(
HyperEdge
):
name
:
str
imported_name
:
VarOrParam
imported_from
:
str
redefinitions
:
list
[
Definition
]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/gboml/ast/nodes.py
+
2
−
11
View file @
df47c3d8
...
...
@@ -24,7 +24,7 @@ class NodeDefinition(Node):
parameters
:
list
[
Definition
]
=
field
(
default_factory
=
list
)
nodes
:
list
[
Node
]
=
field
(
default_factory
=
list
)
hyperedges
:
list
[
HyperEdge
]
=
field
(
default_factory
=
list
)
variables
:
list
[
VariableDefinition
]
=
field
(
default_factory
=
list
)
variables
:
list
[
VariableDefinition
|
ScopeChange
]
=
field
(
default_factory
=
list
)
constraints
:
list
[
Constraint
]
=
field
(
default_factory
=
list
)
objectives
:
list
[
Objective
]
=
field
(
default_factory
=
list
)
activations
:
list
[
Activation
]
=
field
(
default_factory
=
list
)
...
...
@@ -39,17 +39,8 @@ class NodeGenerator(Node):
parameters
:
list
[
Definition
]
=
field
(
default_factory
=
list
)
nodes
:
list
[
Node
]
=
field
(
default_factory
=
list
)
hyperedges
:
list
[
HyperEdge
]
=
field
(
default_factory
=
list
)
variables
:
list
[
VariableDefinition
]
=
field
(
default_factory
=
list
)
variables
:
list
[
VariableDefinition
|
ScopeChange
]
=
field
(
default_factory
=
list
)
constraints
:
list
[
Constraint
]
=
field
(
default_factory
=
list
)
objectives
:
list
[
Objective
]
=
field
(
default_factory
=
list
)
activations
:
list
[
Activation
]
=
field
(
default_factory
=
list
)
tags
:
list
[
str
]
=
field
(
default_factory
=
list
)
@dataclass
class
NodeImport
(
Node
):
name
:
str
imported_name
:
VarOrParam
imported_from
:
str
scope_changes
:
list
[
ScopeChange
]
=
field
(
default_factory
=
list
)
redefinitions
:
list
[
Definition
]
=
field
(
default_factory
=
list
)
This diff is collapsed.
Click to expand it.
src/gboml/parsing.py
+
8
−
4
View file @
df47c3d8
...
...
@@ -63,7 +63,6 @@ def _lark_to_gboml(tree: Tree, filename: Optional[str] = None) -> GBOMLGraph:
# obj(*children, meta=meta)
#
to_obj
=
{
"
hyperedge_import
"
:
HyperEdgeImport
,
"
var_or_param_leaf
"
:
VarOrParamLeaf
,
"
var_or_param
"
:
VarOrParam
,
"
constraint_std
"
:
StdConstraint
,
...
...
@@ -173,9 +172,14 @@ def _lark_to_gboml(tree: Tree, filename: Optional[str] = None) -> GBOMLGraph:
objectives_block
,
activations
,
tags
,
meta
=
meta
)
def
node_import
(
self
,
meta
:
Meta
,
name
:
str
,
imported_name
:
VarOrParam
,
imported_from
:
str
,
redef
:
list
[
ScopeChange
|
Definition
]):
return
NodeImport
(
name
,
imported_name
,
imported_from
,
[
x
for
x
in
redef
if
isinstance
(
x
,
ScopeChange
)],
[
x
for
x
in
redef
if
isinstance
(
x
,
Definition
)],
meta
=
meta
)
return
NodeDefinition
(
name
,
Extends
(
imported_name
,
imported_from
,
meta
=
meta
),
parameters
=
[
x
for
x
in
redef
if
isinstance
(
x
,
Definition
)],
variables
=
[
x
for
x
in
redef
if
isinstance
(
x
,
ScopeChange
)],
meta
=
meta
)
def
hyperedge_import
(
self
,
meta
:
Meta
,
name
:
str
,
imported_name
:
VarOrParam
,
imported_from
:
str
,
redef
:
list
[
Definition
]):
return
HyperEdgeDefinition
(
name
,
Extends
(
imported_name
,
imported_from
,
meta
=
meta
),
parameters
=
redef
,
meta
=
meta
)
def
start
(
self
,
meta
:
Meta
,
time_horizon
:
Optional
[
int
],
global_defs
:
list
[
Definition
],
nodes_hyperedges
:
NodesAndHyperEdges
):
return
GBOMLGraph
(
time_horizon
,
global_defs
,
nodes_hyperedges
.
nodes
,
nodes_hyperedges
.
hyperedges
,
meta
=
meta
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment