Is there a function that can compare two SCIP_SOLs and determine whether one SCIP_SOL is more optimal than the other?
I am hoping to use this in a branching rule using the solutions in the solution pool.
To get the objective value of a solution you need to call SCIPgetSolOrigObj(). SCIP will automatically store the best found solution - call SCIPgetBestSol() to get it.
There is no such thing as a "more optimal" solution. If you want to compare solutions based on something other than their objective values you need to implement that metric yourself.
Related
When using custom branching or node selection rules in SCIPopt, is it possible to force an immediate exit of the branch-and-bound search once a certain known solution is found? I want to say that a specific node is the solution that I want to take, and the B&B procedure should then exit immediately.
I looked at the callback return options for custom branching (https://www.scipopt.org/doc/html/BRANCH.php) and node selection. I don't see an obvious way to return an "exit now". Alternative ways I'm considering: globally fix all the variables or update the global lower bound to match my chosen solution.
Do you want to declare that solution to be optimal somehow? (or do you even know that it is?)
If that is not so important then you could simply callinterruptSolve. Other options would be to set, e.g., the gaplimit to what your gap currently is after finding that solution (using setRealParam)
Edit: So unless you can somehow prove to SCIP that your solution is indeed optimal all your possible options to do this will be somewhat hacky. At that point you might as well force the global lowerbound to match your found solution. Since I don't know how you know that your found solution is optimal I can't really help much more.
So I am looking at modelling an overconstrained routing problem, where not all tasks have to be picked up in that specific planning problem. Rather the objective will be to maximise the tasks picked up in that planning problem.
I was thinking this should be easy to achieve by allowing the planning variable to be nullable, but it seems that Optaplanner does not allow this on chained planning variables.
So the workaround I am thinking about would be to devise a Dummy/Ghost vehicle for which the objective be to rather minimise the tasks assigned to this vehicle. This approach seems to echo what has been said here.
Alternatively, I think I can put the value null in the valueRangeProvider but I am not sure if this would work as intended.
Is this a reasonable approach, or are there caveats using this approach ?
null in ValueRangeProvider doesn't work.
The Dummy workaround is very, very common - I did it a few times myself (including for the RH summit demo). But once PLANNER-226 is fixed, we can get rid of that dummy workaround.
I want to store a feasible solution from an event handler that catches the SCIP_EVENTTYPE_BESTSOLFOUND event, and later I would like to give this solution as an heuristic solution to another SCIP instance that is optimizing the same problem but with different parameter settings (this could be in a subsequent optimization or in parallel).
My problem is that the solution I get from using SCIPgetBestSol() will be in terms of the transformed problem, which can be different from the transformed problem in the second SCIP instance.
Would turning presolve off (using SCIPsetPresolving()) be enough for ensuring that SCIP is always referring to the original variables within callback functions?
Is there a particular way that you would recomend for doing this?
Thanks!
Make sure that your event handler can access the array of original variables (SCIPget(N)OrigVars() does the trick). You can always query solution values of original variables, even from transformed solutions, using SCIPgetSolVal(), and store the values in a solution created via SCIPcreateOrigSol().
In order to feed this solution into a different SCIP instance, you have to get the mapping between variables of the primary and secondary SCIP instance right. Create a new solution for the secondary SCIP instance, and set the solution value of a variable to the value of its (pre-)image variable in the primary SCIP.
I want to get from redis all the keys that the number of elements in their list
(Each value is a list type) has more than x items?
How do I do that?
Any simple way or just have to use lua? if lua - how?
There are many ways to achieve that, each with its own pros and cons. The first decision you have to make is whether you want to have the answer to your query pre-prepared or computed ad-hoc.
For pre-prepared, you'll have to maintain an index of the lists by length. For ad-hoc, you'll have to scan all the lists and get their lengths at runtime.
Assuming you are trying to implement an ad-hoc query, a server-side Lua script is a good choice if you already know how. If not, you can either learn it (https://redis.io/commands/eval) or use a regular Redis client in your language of choosing.
I am going to attend the Instance Matching of OAEI, now I need to make my results to Alignment Format. In order to achieve it, I have learned official tutorials.(link:http://alignapi.gforge.inria.fr/tutorial/tutorial1/index.html).
But there are many differences between the method taught and the method I want. In other words, I can't understand the API.
This is my situation:
I have 2 rdf file(person11.rdf and person12.rdf respectively.data link is http://oaei.ontologymatching.org/2010/im/index.html, the PR dataset), each file has information of many person. I want to find the coreferent entities, the results must be printed in Alignment Format. I find the results by using SPARQL, but I don't know how to print it in Alignment Format.
So, I have three questions:
First, if I want to generate a Alignment Format file, is the method taught the only way?
Second, can you give me your method(code better) to generate the Alignment Format file? Maybe I am wrong from the beginning, can you give me some suggestions?
Third, if you attended OAEI or know something about Instance Matching, can you give me some advice? I want to find the coreferent entities.
Thank you!
First question: I guess that the "mentioned method" is the one in tutorial1. It is not the appropriate one since you have to write a program to output the alignment format and this is a command line interface tutorial. In this case, you'd better look at http://alignapi.gforge.inria.fr/tutorial/tutorial2/index.html
Then, there are basically two ways to do:
The advised one (for several reasons and for participating to OAEI) is to follow these tutorials, to create an empty alignment in it, to create the correspondences from the results of your SPARQL query and to render it. Everything is covered by the tutorials but the part concerning your SPARQL queries. This assumes that you are programming in Java.
The non-advised solution (primarily non advised because you will have to debug your own renderer), is to write, in any programming language that you want a program that output the format (which corresponds to what you cite).
Think about it: how would you expect that the Alignment API knows the results of your SPARQL query? If you come up with a nice solution, contact the API developers, they may integrate it and others could benefit.
Second question: I cannot do better than what is above.
Third question: too general. Read the OAEI results (http://oaei.ontologymatching.org) and look at the code of others.
Good luck!