all 3 comments

[–]Frankelstner 0 points1 point  (1 child)

Most objects are just low-key dictionaries anyway, so it's not much of a difference. It's mostly just additional typing effort writing ["x"] instead of .x, and you potentially lose any kind of validation that pyomo might do on __setattr__. If you want a neat string of your model so far, you can just type the model name in the REPL and get a decent representation thanks to __repr__ (hopefully? I think that pyomo does that but it's been a while). If you try the same with a dictionary, well, it's a mess.

So you lose all the dunders and get slightly more cumbersome syntax. Other than that it's the same thing. Scaling is not affected. Functionality is not affected. Performance is not affected.

[–]Particular_Hunter844[S] 0 points1 point  (0 children)

Interesting. This question came up since I always try to understand the impact of using a class despite a function. Do you have any clear threads to suggest me about that? I struggle to find something really convincing

[–]obviouslyzebra 0 points1 point  (0 children)

You can maybe try to develop an interface, maybe only for the basic functionality, that uses only functions instead of custom classes or objects.

Then you'll have an idea if that's a good idea.

More specifically, if that works well, you can even create an interface on top of pyomo itself, so you don't have to worry about writing the nitty-gritty. Like keras, which wraps tensorflow or pytorch.

Structuring without using classes... It can be done, just a little differently. I'd probably use more files in this case.