-
Notifications
You must be signed in to change notification settings - Fork 17
Adds support for defining and using classes/objects alongside species/agents #776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Adds support for defining and using classes/objects alongside species/agents #776
Conversation
Replaces hardcoded string keys like 'type', 'name', 'file', 'model', and 'species' with IKeyword constants throughout core, server, and utility classes. This improves maintainability and reduces risk of typos. Also updates copyright years and minor formatting in several files.
Extended GAML validation and SyntacticFactory to handle TYPE and SKILL keywords similarly to SPECIES and GRID. Updated copyright years and partner list for 2025 release.
Updated copyright years and partner list in headers for ExperimentDescription and GamlSpecies. Enhanced documentation and logic in DescriptionFactory for adding new type names. Added TYPE and SKILL keywords to GamlSpecies symbol annotation and performed minor code cleanups.
Introduces the 'class' keyword to the GAML language, updates grammar and lexer files, and adds AbstractClass and IClass abstractions for species. Refactors AbstractSpecies to inherit from AbstractClass, updates related interfaces, and ensures proper handling of class-based species definitions throughout the codebase.
Enhanced and clarified Javadoc comments in AbstractClass, AbstractSpecies, IClass, and ISpecies to better describe their roles, methods, and parameters in the GAMA modeling platform. These changes improve code readability and documentation for developers working with species-related abstractions.
Eliminated the 'population' variable and related annotations from the IClass interface to simplify its structure. Updated Javadoc formatting for improved readability.
Removed AbstractAgent and merged its logic into MinimalAgent, updating all references to use MinimalAgent. Updated MinimalGridAgent to extend MinimalAgent and refactored its population and geometry handling. Added class management to GamlModelSpecies and fixed a typo in IKeyword. Updated BufferingController with documentation and minor code improvements.
Updated the getGamlType method in GamlClass to improve clarity and added a new implementation in GamlSpecies to retrieve the container type from the species expression. This refactor aims to ensure correct type retrieval for class and species definitions.
Removed GamlGridAgent, IGridAgent, and MinimalGridAgent classes, refactored GridPopulation and related grid classes to use the generic IAgent interface instead of IGridAgent. Updated constructors, method signatures, and logic to remove grid agent-specific code and unify agent handling. Added new methods to IGrid and GamaSpatialMatrix for cell width, height, value access, and support image pixels. Updated copyright and partner information for 2025. This simplifies the grid agent model and improves maintainability.
Introduces IObject and IDelegatingShape interfaces to improve delegation and separation of concerns in agent and shape handling. Refactors IAgent to extend IObject and IDelegatingShape, moving shape delegation logic out of IAgent. Updates MinimalAgent and related classes to align with new interfaces. Also updates copyright years and adds/improves Javadoc comments for clarity.
Introduces parsing and grammar support for statements like `agent.action()` using the dot operator. Updates lexer, parser, grammar, and related generated files to recognize and handle the new action call syntax, improving expressiveness and consistency in GAML statement definitions. Still to be worked on, though, as we now need to make it compile correctly !
Changed the S_Do target from VariableRef to Expression in the grammar, Ecore model, and generated code. This enables the target of a 'do' statement to be any valid expression, increasing flexibility in action calls.
Added support for a TARGET facet in 'do' statements, allowing action calls on specific agent targets. Refactored syntactic conversion logic to handle target expressions and improved action resolution in DoDescription. Also updated StatementFactory to recognize '.' as a valid keyword for 'do' statements.
Added handling for the 'target' facet in DoStatement to allow invoking actions on a specific agent. The code now checks if a target agent is provided and executes the action on that agent, improving flexibility for agent-based action calls.
Added GamaClassType to support class meta-type in GAML. Refactored 'target' facet/keyword to 'target_agent' in DoStatement, DoDescription, and related parsing logic. Updated IType and IClass to support new class type and improved documentation. Fixed model code to use consistent attribute naming and updated references to class/the_class. GamaSpeciesType now extends GamaClassType for unified type handling.
Introduced GamaMetaClassType as a common abstract base for GamaClassType and GamaSpeciesType, clarifying the distinction between class and species types. Updated casting logic in GamaClassType to focus on IClass and IObject, and adjusted related documentation and method signatures. Added OBJECT type constant to IType. Updated IModel interface to support class retrieval by name.
Introduces SyntacticClassElement to represent class elements in the AST. Updates ISyntacticElement with isClass, CLASS_FILTER, and visitClasses methods, and modifies SyntacticFactory to instantiate SyntacticClassElement for class keywords. Also updates copyright years and partners in affected files.
Introduces a new static GamaClassType CLASS field and handles its initialization in the Types class. Updates copyright year and partner list in the file header.
Introduces ClassDescription and related infrastructure to support object classes in GAML, including new constant expression types and integration with model descriptions. Updates various core files to handle object types, adds IObjectConstructor, and refactors type handling to generalize species, skills, and classes. Also updates copyright years and documentation in affected files.
Ensures that all child elements are properly added by moving the super.addChild(child) call outside the switch statement and adding missing return statements for ClassDescription and ExperimentDescription cases.
Updated the GAMA 1.9.gaml model to use the correct plural 'objects' species and container references instead of 'object'. Also fixed the Java type casting in GamaSpeciesType to ensure proper container type handling. These changes improve consistency and correctness in species and container usage.
Moved the default implementation of isContainer() to IType and IContainerType interfaces, removing redundant overrides in GamaType, GamaContainerType, and ParametricType. This change centralizes container type logic and simplifies class implementations.
This commit refactors and extends support for 'class' statements in GAML. It updates factories to properly create and register ClassDescription instances, adjusts type checks and facet types for classes, and fixes a typo in Types.java. These changes improve the extensibility and correctness of class definitions and inheritance in GAML models.
Updated agent context management in runtime and scope classes to use the IObject interface instead of IAgent, allowing for more generic object handling. Added evaluate method for IObject in IScope and ExecutionScope, and updated method signatures and logic to support this change. Also fixed a keyword check in GamlModelSpecies and updated copyright/version info.
Introduces the GamlObject class and related interfaces to support object instantiation in the GAMA platform. Refactors agent creation methods to use createAgentAtIndex instead of createAgentAt, and adds the 'instantiate' operator for creating agents and objects. Updates variable handling to work with IObject instead of IAgent, and extends compiler logic to support constructors for object and agent types.
Introduces overloaded createMap methods in IExpressionFactory and GamlExpressionFactory to allow creation of map expressions from Map<String, IExpression>. Updates MapExpression to support construction from string-keyed maps. Refactors GamlExpressionCompiler to use the new map creation for attribute parsing and object instantiation. Also improves key extraction logic in EGaml for parameters with null keys.
Changed classes map in GamlModelSpecies to use unordered map creation. Added classes to the visitor traversal in ModelDescription to ensure all class descriptions are visited.
Moved user interaction related operators (e.g., clipboard, command execution, user input dialogs, wizard, and value entry) from System.java to a new User.java file. This improves separation of concerns and keeps System.java focused on system-level operations.
Replaces usage of Containers.opMean with Containers.mean in layout classes. Refactors and documents several methods in Containers.java for clarity and consistency, including sublist, slice, and submatrix operators. Updates copyright and documentation headers in multiple files. Improves code formatting and adds missing JavaDoc comments in Containers and SpatialStatistics.
Simplifies the logic for detecting constructors by adjusting argument checks and removing unnecessary argument passing to tryConstructor. Also ensures parseAttributes returns an empty map when input is null.
GamlObject now requires an IScope parameter in its constructor and initializes attributes with default values for missing variables. Added serialization methods to GamlObject and updated related interfaces and classes to support these changes. Also added JSON deserialization to GamaObjectType and improved attribute parsing in GamlExpressionCompiler.
Unifies species and class type registration under addUserDefinedType, replacing addSpeciesType and addClassType. Refactors DescriptionFactory to use dedicated factory instances and updates method calls for built-in descriptions. Updates copyright years and partner names in headers. Ensures class names are registered as types in SpeciesFactory.
Renamed initType to initBuiltInType in ITypesManager and related usages for clarity. Changed SPECIES_TYPES constant to USER_DEFINED_TYPES in IType and updated references. Added object type handling in DescriptionFactory. Updated comments in ModelFactory for consistency.
Simplifies attribute initialization by delegating to the variable's initializeWith method, ensuring attributes are set using provided values, init facets, or type defaults.
Introduces the CLASS concept and symbol kind, allowing definition of classes in GAML. Updates context validation for statements and variables to support classes and skills, adds canBeDefinedIn checks, and improves error reporting for invalid symbol placement. Also updates copyright years and partner list in headers.
Removed redundant addChildren override from ClassDescription. Added context validation to SymbolDescription's addChild method to prevent invalid child definitions and provide error reporting.
|
@lesquoyb I've solved the 3 problems identified above in your comment. Can you check if it is ok on your side ? |
Introduces AbstractPopulation to factorize common logic for GamaPopulation and GridPopulation. Refactors GamaPopulation and GridPopulation to extend AbstractPopulation, moving shared methods and attributes. Updates DefaultPopulationFactory and IPopulation to match new structure. This improves code maintainability and reduces duplication.
Reorganized AbstractPopulation to clarify method groups, improved attribute ordering logic, and moved/cleaned up several methods. Removed redundant overrides and boilerplate from GamaPopulation and GridPopulation, and updated copyright in SerialisedGrid. These changes improve maintainability and readability of the population metamodel.
Replaces the IsLiving inner class in IPopulation with a Predicate lambda in GamaPopulation. Updates related method signatures and usages for improved clarity and conciseness.
Removed redundant methods and unused imports in population classes. Unified agent addition and removal logic in AbstractPopulation, ensuring agent events are fired consistently. Simplified living agent filtering and list copying in GamaPopulation. Improved type handling in IList and GridPopulation for better consistency and code clarity.
Moved ISkill interface from core.common.interfaces to gama.gaml.skills and renamed the base Skill class to GamlSkill. Updated all references and skill implementations to use the new GamlSkill class and ISkill interface location. Also includes minor code cleanups, switch to IList in matrix operations, and small documentation/license updates.
|
I have a question regarding how classes are going to be used: is it something expected that a species can inherit from a class in gaml or do we force a composition pattern ? |
|
@AlexisDrogoul I reworked the unit test file to take into account your remarks, it seems like almost everything is working now.
|
Replaces all references to IModel with IModelSpecies, including interface renaming, imports, method signatures, and type usages throughout the core, headless, UI, and compiler modules. This change improves clarity and consistency in model-related abstractions.
Refactor the experiment plan interface and implementation to use the name IExperimentSpecies and ExperimentSpecies throughout the codebase. Update all references, method signatures, and variable names accordingly to improve clarity and consistency in experiment-related APIs.
Updated Containers.at() to use getPopulation().get() for agent retrieval. Removed redundant get() and getFromIndicesList() methods from GamlSpecies and ISpecies, and cleaned up ISpecies interface by removing IAddressableContainer inheritance. This streamlines agent access and simplifies the species interface.
Renamed GamaSpeciesType to GamaSpeciesMetaType and updated all relevant references. Removed StreamEx and getGamlType methods from IPopulationSet and IContainer interfaces to simplify their contracts. Updated CompoundSpatialIndex to use pattern matching for instanceof. Adjusted GamaType to reference the new GamaSpeciesMetaType class.
Renamed GamaClassType.java to GamaClassMetaType.java and updated all references in Types.java to reflect the new class name. This improves clarity by aligning the class name with its purpose as a meta-type for GAML classes.
Introduced new abstract class GamaInstanceType to unify logic for agent and object types. Refactored GamaAgentType and GamaObjectType to extend GamaInstanceType, reducing code duplication and improving maintainability. Updated related methods and type checks to use the new structure. Added utility methods in IModelSpecies for class or species retrieval.
Updated type handling to treat SPECIES as a GamaSpeciesMetaType instead of a container type. Adjusted GamlExpressionFactory and GamlExpressionCompiler to align with this change, simplifying experiment access logic and removing outdated type checks. Cleaned up GamaSpeciesMetaType and Types to reflect the new structure.
Replaces direct use of getConstantExpr() with getTypeOfVar() in type descriptions and expression compilation. Removes redundant constant expression methods from ClassDescription and SpeciesDescription, and updates GamaType to lazily create expressions. Cleans up and unifies type handling for class, skill, and species descriptions, and simplifies related meta-type classes.
|
I don't know since which commit but I'm not able to run models anymore on that branch, I have xtext errors in every model. |
This pull request introduces several enhancements and refactorings across the codebase, focusing on improved support for classes in the model kernel, keyword management, and type safety. The most significant changes include the addition of class management to the model species, updates to the keyword interface, and improved parameter handling in experiments. Minor updates to copyright headers and code style are also included.
Model and Class Management Enhancements
IClass) inGamlModelSpeciesandIModel, including new methods to get a class by name or by name and origin. Classes are now stored in a dedicated map and registered during the children setup process.Keyword Interface Updates
IKeywordand reorganized some existing keyword declarations for clarity and consistency.Experiment and Agent Refactoring
ExperimentAgentto useIObjectinstead ofIAgentfor variable access, reflecting broader applicability.BatchAgentto useMinimalAgentinstead ofAbstractAgentfor simulation disposal, aligning with current agent hierarchy.ExperimentPlanto useIKeywordconstants instead of string literals, improving maintainability and reducing errors.General Codebase Maintenance
These changes collectively improve the extensibility, maintainability, and clarity of the core model and experiment handling in the platform.