How to model soft constraints in Pyomo? - pyomo

I am quite new to the topic and saw some libraries that give the programmer the option to implement a SoftConstraints class. I was wondering how to do it with Pyomo? Can anyone give me a quick idea how to do it?

Related

Implement a may-join for a cache analysis

I came across this Stackoverflow question where the fellow user was trying to implement a LRU cache with must join. As I am a beginner in C++ I am struggling to implement and check how a may-join might work for a LRU cache. The resources for learning about this topic is very limited and I would be grateful if someone could help me out with this as it's hard to learn and code whilst having a full time job. Any help would be appreciated.
I understood the must join part but currently struggling with may join for over 2 months.
The code is present in the link above and I haven't copied the code here as it might be a plagiarism from my part. Kindly help with the code or refer to some good materials. Thank you
This link might help for a deep understanding. https://www.rw.cdl.uni-saarland.de/people/reineke/private/talks/cachesInWCETAnalysis.pdf

transition Vs custom_reaction in boost.statechart library

I've read the tutorial of boost.statechart library and its examples, and I've a question related to the transition and its action.
There are two ways to define the transition using transition<> and custom_reaction but what is the main difference between them and when to use anyone of this?
Custom reactions are more versatile. However they're also more work and more error prone.
Refer back to this section in the docs where lists limitations and concludes:
All these limitations can be overcome with custom reactions. Warning: It is easy to abuse custom reactions up to the point of invoking undefined behavior. Please study the documentation before employing them!
So you use custom reactions when you know what you are doing and require the flexibility.

PhpBB vs Jforum wrt customization

People have been saying that JForum is easily customizable, and lots of other things in favor of JForum. Through this question, I want to know from those who have used both Jforum and phpbb, that how easy or difficult is customization of the forum in both of these.
For example, say you want to change the theme/template. In my experience I found it much easier to change theme in phpbb ( but still haven't found a way to change the theme in JForum).
Please also suggest some resources where I can find some support for JForum, I couldn't find any support/documentation and so I'm still confused whether to switch to phpbb even if the client prefers Java?
To put this question another way, is there any reason why someone should use JForum when phpBB is available? (I hope it's not the same thing as Java vs Php)
Ok, 1 month and no answer! Looks like this question is not much important, perhaps because there aren't many who have used JForum and phpbb both.
After going through both of them, I eventually decided to go with phpbb given the customization possible, so my vote is towards phpbb. Opinions on this question are still welcome.

class diagram for C++

Guys ! I understood that my previous question did not meant to you guys as per my intentions. I apologize for the same.
Let me pose in a different way.
Take my case, yesterday I faced an interview.
The guy out there asked me that he is trying to develop an application similar to google maps for his windows mobile device.
He asked me to come up with a class diagram for the application.
It was like a bouncer for me.
In such cases, what should be my approach ? where should I start ? How should I look at the problem ?
I hope this is better understood.
I request you to answer me considering that I am an amateur C++ developer who has never worked on any projects from the analysis & design phase
and doesn't know abc's of design.
Thanks,
krisssam
Maybe a bit overkill for an interview, but even there I would still go for 1 and 3 and start with 4.
ask as much specifications as possible, so you know what is expected
When possible/needed, make use cases to get a clear view on how it will be used
Start high level, focus on the main features. Look for preferably less than 6 players (modules) and try to see how they interact. Define responsabilites and interfaces.
Break up these players in submodules and see how these interact (also define responsabilites and interfaces). Repeat until you have implementable entities (classes)
in parallel with 4, for architecture, see how it will be deployed and what language/frameworks/libraries are needed/available.
For google-maps, I assume that players could be the map-database, the map-viewer, the user-input, the search-engine, but I'm not a GUI/GIS/mobile expert.
First you need a clear understanding about what you should be written. Formulate that understanding in English. Now every noun is a candidate for a class. Every verb is a candidate for a method. and nouns that appear in the same sentence are candidates for association.
This sounds quite simple. That's because I simplified it a lot. Actually there is much more to it. Getting a clear understanding about what should be written alone is challenging. If you are interested I suggest reading a book on object oriented analysis and design.
Define the responsibilities that each component of the software will have, then flesh classes around those.
It doesn't relate to the language.
Class diagram - means you need to identify the major objects that "plays" in this app.
The map object and it's data members and actions
the icon objects and it's data members and actions ect...

How specific to get on design document?

I'm creating a design document for a security subsystem, to be written in C++. I've created a class diagram and sequence diagrams for the major use cases. I've also specified the public attributes, associations and methods for each of the classes. But, I haven't drilled the method definitions down to the C++ level yet. Since I'm new to C++ , as is the other developer, I wonder if it might not make sense go ahead and specify to this level. Thoughts?
edit: Wow - completely against, unanimous. I was thinking about, for example, the whole business about specifying const vs. non-const, passing references, handling default constructor and assigns, and so forth. I do believe it's been quite helpful to spec this out to this level of detail so far. I definitely have gotten a clearer idea of how the system will work. Maybe if I just do a few methods, as an example, before diving into the code?
I wouldn't recommend going to this level, but then again you've already gone past where I would go in a design specification. My personal feeling is that putting a lot of effort into detailed design up-front is going to be wasted as you find out in developing code that your guesses as to how the code will work are wrong. I would stick with a high-level design and think about using TDD (test driven development) to guide the low-level design and implementation.
I would say it makes no sense at all, and that you have gone too far already. If you are new to C++ you are in no position to write a detailed design document for a C++ project. I would recommend you try to implement what you already have in C++, learn by the inevitable mistakes (like public attributes) and then go back and revise it.
Since you're new, it probably makes sense not to drill down.
Reason: You're still figuring out the language and how things are best structured. That means you'll make mistakes initially and you'll want to correct them without constantly updating the documentation.
It really depends on who the design document is targeted at. If it's for a boss who is non-technical, then you are good with what you have.
If it's for yourself, then you are using the tool to help you, so you decide. I create method level design docs when I am creating a project, but it's at a high level so I can figure out what the features of the various classes should be. I've found that across languages, the primary functionalities of a class have little to do with the programming language we are working in. Some of the internal details and functions required certainly vary due to the chosen language, but those are implementation details that I don't bother with during the design phase.
It certainly helps me to know that for instance an authorization class might have an authenticate function that takes a User object as a parameter. I don't really care during design that I might need an internal string md5 function wrapper to accomplish some specific goal. I find out about that while coding.
The goal of initial design is to get organized so you can make progress with clarity and forethought rather than tearing out and reimplementing the same function 4 times because you forgot some scenario due to not planning.
EDIT: I work in PHP a lot, and I actually use PhpDoc to do some of the design docs, by simply writing the method signature with no implementation, then putting a detailed description of what the method should do in the method header comments. This helps anyone that is using my class in the future, because the design IS the documentation. I can also change the documentation if I do need to make some alterations while coding.
I work in php4 a lot, so I don't get to use interfaces. In php5, I create the interface, then implement it elsewhere.
The best way to specify how the code should actually fit together is in code. The design document is for other things that are not easily expressed in code. You should use it for describing the actual need the program fills, How it interacts with users, what the constraints are in terms of hardware and operating systems. Certainly describe the overall architecture of your application in a design document, but, for instance, the API should actually be described in the code that exposes the API.
You have already gone far enough with the documentation part. As you still a beginner in C++, when you would understand the language, you might want to change the structure of your program. Then you would have to do changes in the documentation. I would suggest that you have already gone too far with the documentation. No need to drill more into it
Like everyone else says, you've gone way past where you need to go with the design. Do you have a good set of requirements to the simple true/false statement level that you derived that design from? You can design all day long, but if you don't have requirements that simply say WHAT you're going to do, it doesn't matter how good your design is.