-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I initialize a partial solution? #621
Comments
No, you cannot say that. The obj parameter is the coefficient of the variable in the objective function. Suppose you had the following:
Here your objective function is min. 3*y. If you then do
You do two things. First, you create and add a new variable x, and then add it to the objective function. So now your new objective function is: min 3y + 5x. Please let me known if something is not clear. |
Ok, I see, thank you very much, but what if I want to use the solution of the heuristic algorithm as the initial value in the scip solver? i know that in gurobi you can do this: for example, if the heuristic algorithm x[i] has a feasible solution of 5, then in gurobi you can set the initial value of x[i] like this: x[i].Start = 5; |
If I understood correctly you want to initialize a partial solution, right? I have never done this, but I'm fairly certain that I got it. You first need to create a partial solution with model.createPartialSol(), and then add values to the variables you want. This method (createPartialSol) also has an optional parameter for the heuristic you used to find the values.
I made a non-linear model so that the trivial heuristic couldn't immediately find the solution. If you run this script, you will see that the first line is
And the optimal value is 1.2e+01, so I'm fairly certain that this is the way to do what you want. PS: I didn't know that this method existed, and I needed something like it for my own work, so thank you very much for the question! PPS: Can you please change the title of the issue to something like: "How can I initialize a partial solution?" That way, it will be easier for people to find it later. |
Ok, thank you for your advice, I have revised the title, I will try your way, thank you again! |
I'm sorry, I tried to run the model yesterday, but there was an error. Could you please check it again? The error message looks like this: My version of PySCIPOpt is 6.0.2 |
you mean that the version of SCIP that you are using is 6.0.2? You should update to the latest SCIP and the latest version of pyscipopt and try again |
Ok, thanks, I've thought of that, and now I've updated to version 7.0.2, which includes createPartialSol, |
The completesol heuristic of SCIP, which takes a partial solution as input and completes it, has a maximum threshold of 0.85 (85%) for the number of unknown variable values. Since the provided partial solution seems to have 0.996856 (more than 99.6%) of the unknown variable values, the heuristic printed the above warning message and exited without trying to create a complete solution. You may either provide a partial solution with more known variable values (recommended option) or change the threshold value of the completesol heuristic by setting the following SCIP parameter. This parameter takes values in the range [0, 1] with a default value of 0.85 (hence, the above warning message with 0.85 in it).
|
Let's say x = mode.addVar(self, name='', vtype='C', lb=0.0, ub=None, obj=5.0, pricedVar = False),then I can say that the initial value of x is 5.0?
The text was updated successfully, but these errors were encountered: