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

Impossible to loop on a range with a float step #3810

Closed
lesquoyb opened this issue May 8, 2023 · 0 comments
Closed

Impossible to loop on a range with a float step #3810

lesquoyb opened this issue May 8, 2023 · 0 comments
Assignees
Labels
About GAML This issue concerns the GAML language 😱 Bug The issue reveals a bug in GAMA 🤗 Enhancement This is a request for enhancement 👍 Fix to be tested
Milestone

Comments

@lesquoyb
Copy link
Collaborator

lesquoyb commented May 8, 2023

Describe the bug
Somewhere between a bug and an enhancement request. Currently the loop statement used with facets from to and step assumes integers as values and casts the floats into int. But why ? It is very inconvenient if you have to convert your range into an integer range to initialise the loop and then do the conversion back to your float working value inside the loop. It also leads to infinite loops if the step value in ]-1, 1[ as it's going to be casted to 0. The worst part is that there's no warning when giving a float to those facets that the values are going to be casted to int.

To Reproduce
Steps to reproduce the behavior:

  1. Run:

model NewModel

global {
	init {
		loop i from:1.5 to:10.0 step:0.99 {
			write i;
		}		
	}
}

experiment name type: gui {
}
  1. Observe the infinite loop and that i's value is 1 instead of 1.5

Expected behavior
Either the loop accepts floats, or at least it gives warning for the casting it is going to do

@lesquoyb lesquoyb added 😱 Bug The issue reveals a bug in GAMA 🤗 Enhancement This is a request for enhancement About GAML This issue concerns the GAML language labels May 8, 2023
@AlexisDrogoul AlexisDrogoul self-assigned this May 28, 2023
@AlexisDrogoul AlexisDrogoul added this to the GAMA 1.9.2 milestone May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
About GAML This issue concerns the GAML language 😱 Bug The issue reveals a bug in GAMA 🤗 Enhancement This is a request for enhancement 👍 Fix to be tested
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants