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

Position implementation change #1510

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Position implementation change #1510

wants to merge 15 commits into from

Conversation

bam241
Copy link
Member

@bam241 bam241 commented May 20, 2019

Position change:
The way the Position is working now, each agent have to define their coordinates (all the cycamore have them) and have there own method to Record them (all have the same), what I did, is add the coordinates and the RecordPosition at the Agent level (each cycamore agent still have to get latitude and longitude on their own), each agent calling the RecordPosition at the Cyclus::Agent::EnterNotify() level, avoiding copy/pasting the RecordPosition method over and over...

I also added a RecordPosition(Agent* agent) method in Position, so the Position knows how to register itself in the database. (this add agent and context include in the Position, if we don't like it, it will be as easy to add the RecordPosition in the agent itself...)
I think this last change make sense, as it allows to keep the Agent class fairly simple and will allow each attribute (Position) to know how to Record himself...

This is redondant with #1508 , but @gonuke advised me to do a separate PR for this change.

@gonuke
Copy link
Member

gonuke commented May 29, 2019

A better way to streamline this without forcing every agent to have a Position (since that's not in the spirit of the toolkit):

  1. add RecordPosition() to position.h (as already one here)
  2. all agents with a position do the following things
    • inherit from Toolkit::Position
    • #include a special snippet that adds variables with cyclus pragmas in header (e.g. position.cycpp)
    • add Position(latitude,longitude) to the initializer list of their constructor
    • call RecordPosition(this) from EnterNotify()

@@ -0,0 +1,19 @@
#pragma cyclus var { \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file really intended to be part of the PR?

src/toolkit/position.h Outdated Show resolved Hide resolved
src/toolkit/position.h Outdated Show resolved Hide resolved
tests/toolkit/position_tests.cc Show resolved Hide resolved
src/toolkit/CMakeLists.txt Outdated Show resolved Hide resolved
@bam241
Copy link
Member Author

bam241 commented Jun 3, 2019

@katyhuff thx for your review !
To reply to your comments, the idea here is to include the position.cycpp in the different archetype we develop (#include toolkit/position.cycpp) to avoid having to copy paste over and over:

#pragma cyclus var { \
"default": 0.0, \
"uilabel": "Geographical latitude in degrees as a double", \
"doc": "Latitude of the agent's geographical position. The value should " \
       "be expressed in degrees as a double." \
}
double latitude;

#pragma cyclus var { \
"default": 0.0, \
"uilabel": "Geographical longitude in degrees as a double", \
"doc": "Longitude of the agent's geographical position. The value should " \
       "be expressed in degrees as a double." \
}
double longitude;

so adding position on an archetype, one will only have to:

  • inherit from Position
  • #include position.cycpp whithin the class header
  • call the position constructor for the archetype constructor
  • call the RecorPosition(this) from the EnterNotify() of the archetype

@bam241
Copy link
Member Author

bam241 commented Jun 3, 2019

you can see the related PR draft on cyclus/cycamore#502

@bam241
Copy link
Member Author

bam241 commented Jun 5, 2019

@gonuke @katyhuff I believe this is ready for a second review :)

@FlanFlanagan
Copy link
Member

@bam241 Are we concerned about the cymetric failures? It seems like the tests are returning larger tables than expected.

@bam241
Copy link
Member Author

bam241 commented Jun 7, 2019

@FlanFlanagan I did not investigate this yet, but this is just showing that Cyclus has evolve to something that cymetric don't understand.
So I am not concern about it, but we need to PR a fix for symmetric.
the cymetric_master and the cycamore_master are just there as highlight that the impact of a cyclus change on cycamore and cymetric

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few requests

tests/toolkit/position_tests.cc Show resolved Hide resolved
src/toolkit/position.cycpp.h Outdated Show resolved Hide resolved
@@ -0,0 +1,32 @@

// This includes the required header to add geographic coordinates to a
// archetypes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thinks we need a longer message here that explains how it all works, since it is a brand new concept,

Also, can we use one of the archetypes that’s in cyclus/cyclus to demonstrate?

}
double latitude;
// required for compilation but not added by the cycpp preprocessor...
std::vector<int> cycpp_shape_latitude;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is because cycpp is not run on the file generate by the cpp

see

SET(ORIG "--pass3-use-orig")

and

cyclus/cli/cycpp.py

Lines 2328 to 2335 in 279a758

parser.add_argument('--pass3-use-pp', action="store_true", default=True,
help=("On pass 3, use the preproccessed version of the "
"original file. This options is mutually exclusive"
"with --pass3-use-orig."), dest="pass3_use_pp")
parser.add_argument('--pass3-use-orig', action="store_false",
help=("On pass 3, use the preproccessed version of the "
"original file. This options is mutually exclusive"
"with --pass3-use-pp."), dest="pass3_use_pp")

so when using this snippet method we miss generated code for the additional included variables...
I try to change the --pass3-use-orig to --pass3-use-pp and cyclus is not compiling :(

I don't know what the best solution is...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @gonuke this is a follow-up on the conversation we had this morning...

@gonuke
Copy link
Member

gonuke commented Oct 29, 2019

This needs a news file

@gonuke
Copy link
Member

gonuke commented Nov 21, 2019

will merge with news file!

@bam241
Copy link
Member Author

bam241 commented Nov 22, 2019

shall we not wait for the CEP27 to be ready ?

@gonuke
Copy link
Member

gonuke commented Feb 7, 2024

This was paused waiting for CEP27 to be accepted. That did happen in March 2021, so this should be reconsidered.

A similar approach, based on CEP27, would be very valuable for @nuclearkatie's #1634

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

4 participants