Skip to content

feat: allow inspection of variable definitions#103

Closed
KnorpelSenf wants to merge 2 commits intomainfrom
transparent-vars
Closed

feat: allow inspection of variable definitions#103
KnorpelSenf wants to merge 2 commits intomainfrom
transparent-vars

Conversation

@KnorpelSenf
Copy link
Copy Markdown
Contributor

This makes the fields in variable definitions public. That solves two problems I have.

Cannot Inspect Variable Definitions

Before variable definitions are added to the problem variables, they're very simple containers. After creating many of them, I'd like to log detailed information about their definitions so that I know what I'm passing to the solver.

Currently, all fields are hidden. There is no way to inspect them after building them. Thus I'm currently forced to roll my own copy of variable definitions which let me do these inspections. I then translate them to the good_lp variable definitions (which effectively is a no-op). This could be improved by making the fields public.

Cannot Mutate by Reference

Another issue is that if one has an &Vec<VariableDefinition> then it is currently impossible to add a name, bounds, an int constraint, or an initial value to any of the definitions because the builder pattern always requires ownership. We could clone a variable and then overwrite the old value, but it feels wrong to do several copies just to flip a boolean.

This PR allows for a different workaround. The field can now be set directly by mutating the definition, which is better.

@KnorpelSenf KnorpelSenf requested a review from lovasoa June 27, 2025 14:06
@lovasoa
Copy link
Copy Markdown
Collaborator

lovasoa commented Jun 27, 2025

I don't think mutating variables after their creation should be allowed. But you can add accessors to read the values

@KnorpelSenf
Copy link
Copy Markdown
Contributor Author

Will do!

@KnorpelSenf KnorpelSenf deleted the transparent-vars branch June 27, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants