Skip to content
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

Syntax check of @multiagent is not as correct as it should be: #967

Closed
Datseris opened this issue Feb 4, 2024 · 3 comments · Fixed by #972
Closed

Syntax check of @multiagent is not as correct as it should be: #967

Datseris opened this issue Feb 4, 2024 · 3 comments · Fixed by #972
Labels
agent-construction About making agents bug Something isn't working multi-agent Related with multi-agent models quality of life QoL enhancements that make user experience smoother

Comments

@Datseris
Copy link
Member

Datseris commented Feb 4, 2024

MWE:

@multiagent struct MultiSchelling{X}(GridAgent{2})
    @agent struct Civilian # can't re-define existing `Schelling` name
        mood::Bool = false
        group::Int
    end
    @agent struct Governor{X<:Real} # can't redefine existing `Politician` name
        group::Int
        influence::X
    end
end

civ = Civilian(; id = 2, pos = (2, 2), group = 2) # default `mood`

gov = Governor(; id = 3 , pos = (2, 2), group = 2, influence = 0.5)

the gov line errors with

ERROR: MethodError: Cannot `convert` an object of type Float64 to an object of type MixedStructTypes.Uninitialized

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84

Stacktrace:
 [1] MultiSchelling{…}(id::Int64, pos::Tuple{…}, mood::MixedStructTypes.Uninitialized, group::Int64, influence::Float64, type#226::Symbol)
   @ Main C:\Users\datse\.julia\packages\MixedStructTypes\U6UR1\src\CompactStructTypes.jl:51
 [2] Governor(; id::Int64, pos::Tuple{Int64, Int64}, group::Int64, influence::Float64)
   @ Main C:\Users\datse\.julia\packages\MixedStructTypes\U6UR1\src\CompactStructTypes.jl:104
 [3] top-level scope
   @ c:\Users\datse\.julia\dev\Agents\docs\src\tutorial.jl:737
Some type information was truncated. Use `show(err)` to see complete types.

it is because I did {X} in the super type but {X<:Real} in the subtype.

@Datseris Datseris added bug Something isn't working quality of life QoL enhancements that make user experience smoother agent-construction About making agents multi-agent Related with multi-agent models labels Feb 4, 2024
@Tortar Tortar removed their assignment Feb 5, 2024
@Tortar
Copy link
Member

Tortar commented Feb 5, 2024

I guess we could even allow this syntax if we want to, I think that again it should be done in MixedStructTypes.jl

@Tortar
Copy link
Member

Tortar commented Feb 10, 2024

This works with :opt_speed after #972, but still doesn't with the other version

@Tortar
Copy link
Member

Tortar commented Feb 10, 2024

Should be now fixed for all cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-construction About making agents bug Something isn't working multi-agent Related with multi-agent models quality of life QoL enhancements that make user experience smoother
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants