accept dedicated types for parameters instead of strings
Closed this issue · 3 comments
According to the README, the current user interface has OptimizeParameters
accept arbitrary strings for some of the parameters. This is usually problematic because of the possibility of typos and the requirement to check for typos in the implementation for safety.
An approach that would be automatically safer would be to rely on dispatch for typo-checking: instead of accepting arbitrary strings you could define a type (each possibly a Union
of several other types) for each method parameter, and annotate the parameter with this type so the correct type would be required for the function invocation to succeed.
This approach would also allow for possibly tidier documentation, as it'd be possible to attach a doc string to each defined type (and/or constructor).
In a sense there are two approaches (may be combined/mixed variously): a different type for each specific configuration, or one type for all configurations. E.g.:
One type for all configs, for allowing better type stability:
module Options
module SolveMod
# or just use `@enum`, or one of the enum packages
struct O # not part of the public interface
o::Int
end
const both = O(1) # public interface
const bbc = O(2) # public interface
const ilp = O(3) # public interface
end
# other options
end
A type for each config, for allowing more specialization:
module Options
module SolveMod
struct Both end # public interface
struct BBC end # public interface
struct ILP end # public interface
const U = Union{Both,BBC,ILP} # not part of the public interface
end
# other options
end
Thank you, your contributions mean a lot for me! I was not aware of this and going to code it :)
First push done on main-dev, solve_mod
now accepts dedicated types instead of strings. Thanks @nsajko!
And README updated accordingly
All other parameters now :)
✅ solve_mod (pushed the 13th of July)
✅ sp_solve
✅ writeresults
✅ o_i
✅ s_ij
✅ r_ij (pushed the14th of July)