Getting LP relaxation before SCIPsolve - scip

I would like to use the LP relaxation of the problem before calling SCIPsolve() and I would like to know what is the best/simplest way of doing this.
I'm currently creating a SCIP_LPI that I would like to populate with my original problem's data. I thought that a simple way would be to call SCIPgetLPI() (and then copy everything), but when I write that problem to file (to see it) I get an empty problem. I guess this is because since I haven't called SCIPsolve() yet. I even tried calling SCIPpresolve() first, but the problem is still empty.

To get the LP relaxation I believe you will have to call SCIPsolve at some point. One way I see to do this and that does use SCIPsolve is to set the parameter limits/nodes to 1, call SCIPsolve, which will only solve the root node. Then you can set limits/nodes to -1 and call SCIPsolve again to solve completely if needed. Note that doing so will give you the LP relaxation of the presolved problem, and cuts will be added. Depending on what you would like to do, you may want to disable presolving and cuts.

Related

Changing a parameter while branching in SCIP

I use pyscipopt. I know how to add constraints while branching using handlers (kind of), but now I also want to change some parameters. I imagine that is similar, but couldn’t found an example.
What I want is as follows: -Every time a feasible node is found (or every 10 nodes for example) update a parameter.
How do I do this? Are there examples or documentation on this?
You should implement an event handler. Look in test_eventy.py for an example. The eventtype should be SCIP_EVENTTYPE_NODEBRANCHED. Then you can change parameters in the exec callback.

Is it possible to write a presolved problem into a file?

I would like to write a presolved problem into a file. Is there any way to do it?
write problem does not do it for me, it gives me the original problem that I read with SCIP.
The context is that I am working on SAT problems. The presolving phase of SCIP reduces the number of constraints and variables of the problem, effectively making the problem a little smaller. I would like to take a look at the presolved problem and compare it with the original problem and make some observations.
Yes, it is very easy, just use write transproblem.
The SCIP interactive shell also tells you all the possible commands that you can use, e.g. if you just type write in the SCIP shell, you see all available write commands

Cloning partially solved MIP and keeping current B&B tree

I would like to partially solve a MIP, clone the problem and have that copy of the problem continue optimization but with a different strategy (node selection rule, variable selection rule, etc), and keeping the current branch-and-bound tree. I know that this can't be done with either CPLEX or Gurobi, since they would start optimization from scratch in the copy.
Is there any way of doing this with SCIP?
I would really appreciate any help.
Best,
Rodolfo
If you don't insist on having a copy/clone, you always have the possibility to code your stopping criterion in terms of an event handler. I am sure you know our How to on adding event handlers.
There is also an event handler in the scip source code, the so-called soft time limit event handler src/scip/event_softtimelimit.c. There you can find sample code that changes the time limit after the first solution has been found. Parameters can be fed one by one by using the SCIPchg{Real,Bool,Int,Longint,Char,String}Param() methods in the code, or passed as a settings file, which might be easier if you want to change lots of parameters without adapting the code each time.
It is good practice to use settings files saved via the set diffsave command, which saves only the nondefault-settings. Otherwise, using a complete settings file, you might run into troubles because a time limit or memory limit gets changed without control.
A copy that includes data structures such as the tree used during the branch-and-bound solving process is currently not possible. The copy-mechanism of SCIP only allows to copy the problem as a whole and adjust the formulation by changing variable domains and/or objective coefficients.

Labview 2012 Passing Dynamic data into/out of a while loop

I'm trying to pass data which is continuously changed from the inside of one While loop to the inside of another While loop of a sub-vi. The main program on the left is constantly reading new data and the program on the right is adding 1 to the new value. My issue is that I cannot input new values to a While loop which is already running and thus my sub-vi is never updated. I've tried a global variable ("write" from the main program control and then "read" into the sub-vi) but that doesn't work either (same result as if the main were just passing data into the sub).
I apparently don't have enough reputation to post a picture of my program but I'm basically trying to run parallel loops (almost inside each other). Can anyone lend me an experienced hand?
The most common problem with while loops are based on lack of knowledge how exactly does the while loop work in LabVIEW.
First of all the information will be given outside the loop only if the condition terminal (right down corner of the loop) will be flagged as true.
If you want to pass the data earlier (while the loop is running) you have to choose easiest option:
Use queue (is the most common and well working). I can elaborate how this one work in practise if you want, or just try to run an example from LabVIEW help.
local/shared variables - you can define in your own library variables and pass the data by READ/WRITE option.
Please try to upload some documentation to an external server (as you are blocked here), and post a link, and then I could help you with a specific example.
Help»Find Examples. Search for "queue". Pick out an example with parallel loops.
You might want to look into Queues or Notifiers as means of passing data between running loops.

WinDev - Using a variable in a Looper Content Query

I am hoping someone will be able to point me in the right direction. I have a Looper control within WinDev and am filling the Content using a Query.
How do I utilise a global variable within the query? It seems that it must be passed in as a parameter to the query, however there is no opportunity to set the parameter unless executing the query from code. It all seems a little contradictory and I am sure I'm missing something obvious.
UPDATE
Having read about MySource but also read that MySource cannot be utilised in an Initialization block; I have moved the query to independent. Thereby allowing me to set the parameter with
Query name.Parameter = Value
However, although the Query is specified in the Content table of the Looper control, it does not seem to return anything.
Have tried calling HExecuteQuery() and LooperDisplay(), neither of which seem to do anything.
The query is a simple select and works when tested in the query editor.
Any help would be greatly appreciated,
It turns out that I had to go into the Description of each field and re-click the Link entry. Nothing changed as I clicked them but the data now appears.
Not a great solution but it resolved the issue :-(
Changing from embedded to independent is the best thing you could do and it's the best practice as well. Once the source has changed though you do have to rebind all the data to the attributes since it loses it's references.
You better execute the query at the window's Global Declarations section if you don't want to eat up resources and I/Os for nothing by using the Window's End of Initialization section like I've seen people doing .
This way you don't need to call LooperDisplay() and your independent Query will only be called once by your HExecuteQuery().