3

I have a scientific code that has a parameters.txt file. This file contains 50+ parameters that have default values associated with them. The user has to change the parameters to fit the particular simulation they want to run.

Here is a specific case: there are about 7 options for creating a lattice of sites and assigning energies to the lattice.

However, there are also options to read the energies from a file. If this option is used non of the 7 options pertaining to how the energies are assigned to the lattice are needed.

My question is what is the best way to deal with the unused options. If I have assigned default options to these parameters it may be confusing for the user as they may not realize they are not being used.

I could also set aside a keyword that the user must use with those specific parameters to indicate they are not being used and throw an error if they are not specified as such. This would follow the principle of least astonishment. However, this would also force the user to change multiple parameters. Is there a better way to approach this problem?

  • Can the users simply comment out unneeded parameters? For this kind of program it's probably good to warn on unused parameters. – amon Jul 16 '18 at 16:07
  • Yes I suppose they could. Your suggesting that if certain parameters are not used but they have been defined that a warning should be output? – user2267258 Jul 16 '18 at 22:50
2

You have two problems:

  • you need the ability to say "do the default" in the users configuration file
  • You need to somehow communicate to the user, what are the defaults

One simple way to do this (easiest if you are using JSON for your config file, but possible otherwise too):

Have TWO configuration files

  • Configuration.My.json,
  • Configuration.Defaults.json

The USER creates and edits Configuration.My.json. They can DELETE any items from the file they wish, or give them a 'null' value to make them take on the default.

And automatically emit from the program a Configuration.Defaults.json right next to it, so the user can easily see what options (at least the names) that are available.

Your Configuration.Defaults.json could also contain comments (ok - maybe yaml better than json for this) saying what are possible values for each option, and the meaning of the option.

  • The problem is how in this case would you specify when a specific parameter is not used at all. Would you also follow the structured layout idea proposed by candied_orange? – user2267258 Jul 16 '18 at 22:57
  • Perhaps I've misunderstood. But I think the answer is - you don't need to worry about whether an option is used or not. Just forget that part. Each option - IF used - has a well defined value (look at defaults, and then apply user overrides). If its not used, nobody cares what its value is. – Lewis Pringle Jul 17 '18 at 14:04
  • It maybe - in general - hard to tell if an option will be used. For example, if you have a system that can operate in one of three modes, maybe one guy just uses one mode, and only fills in the options for that mode. But then he lends the system to a friend, who uses another mode. – Lewis Pringle Jul 17 '18 at 14:05
  • One nice thing about this approach, however, is that the user of it ONLY needs to pay attention to the parts they care about - the parts they are using, and where they want something OTHER than the default behavior. So what they need to specify in their config file often will not be much, or very large. – Lewis Pringle Jul 17 '18 at 14:06
2

I like structured data languages for this. My current fave is json but xml will do in a pinch. The idea is that the conditional options become sub options that are required when their parent exists.

Ideally you can offer a configuration wizard that walks the user through the choices and builds the config file.

If you can assume all your users are code monkeys you can also solve the problem with a DSL and let the IDE tell the user what they can and can't do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.