Set_start_value in JuMP for SCIP

Hi all,

I am using set_value_start function in JuMP 0.19 to pass a warm start to SCIP. Though, the solver doesn’t seem to use it.
When I plug in an optimal solution to the problem as the warm start, nothing changes in the iterations! So, I am wondering if that is an issue with SCIP or JuMP!

Any recommendations/suggestions to resolve this issue?

First, read PSA: make it easier to help you. It helps to provide a minimal working example.

Second, upgrade to JuMP 0.21. (0.19 is quite old, and this may be fixed in a new version.)

1 Like

I thought it might be a general question and not specific, and that was the reason I didn’t put a code.
I updated to 0.21.5 and the same issue.
As for small examples it is not that clear, I am attaching the code including the parameters.
In the code, commenting the set_start_value lines results in the same iterations, while the initial solution is optimal (so basically the preprocessing should be sufficient):

using JuMP, SCIP
n_x = 5;
A=[4.71035485409373 -0.7751694462183467 -4.460951531509877 2.8703677438748088 1.300770216708976 0.0881938474285846 0.6768615711390176 -1.908091328247854 2.471359728851893 -1.6333914978208597 3.833543766081192 -1.6634408044595417 2.960145688677045 3.0478382878017527 -4.497613236900087 -0.9749486915835828 4.651916428940266 -0.8562405649283136 -1.6947642937175447 1.3637235434048192 3.5802537020945273 2.8828398402691864 0.3840974318120649 2.4167044633103725 2.397206071131034 -0.5520539317627993 3.5040985825171376 -0.054651402236029156 4.4815753481283345 2.9778818949409604 -3.6695541654037847 -2.622302456147605 -3.7227653290599805 0.3412039894735388 -4.433033100418235 -0.31425001616150805 4.82687802974098 1.8222116159655313 3.7090071806482747 -0.037894345501243265 -2.1233778937127132 -3.169806826128326 4.612190124109825 2.562614757098565 4.503534905139837 1.7126664903197977 -3.139453898747886 -2.1015804185690334 -4.417921755030026 -4.5593377758989595; -2.204411686749931 -3.2953037917919223 1.7710055976967638 4.024179283262306 -1.480126783431528 -3.9984148391785546 2.930022357344697 -0.315675709650308 1.873412068935579 1.8307852874741624 -0.785641141303457 1.593425261209637 1.334271292093053 0.2514600876634985 -3.087185501778469 0.11906009740829315 2.483302628034771 -0.801730833339672 2.374794194777838 1.8646773390446958 4.557260125426689 -1.9209353866983503 -1.5769913745050026 -1.1296642799433112 -4.7382409464156385 1.3354640511713232 0.6525105904520725 -1.3448858716876866 -0.7854130114082132 -0.3779972797069071 -1.8556122394277397 -2.7433830865159123 -3.840631159292495 -3.6603389432181577 4.465234436605673 -0.07567028731607373 2.482136269464225 -1.890648404512313 -4.922947152328464 1.15621671090482 -1.424266607197425 1.4882907105690109 3.459772286069734 -3.986467879802529 0.8830183432177954 0.8238218860658639 0.2180376075211221 -0.45400170123477057 4.667020050639909 -3.1769304234358953; 0.5939212880371381 1.2647448939104846 -4.698700027257624 1.4227305727190949 3.3816113172677813 -1.0486398339353622 -0.6265779694176041 -4.151172219287163 0.8137747401912163 3.716819764413229 -2.930929229089899 -4.053899677636762 -3.1204780056668016 1.6783657674205896 2.324209055025097 1.310104488917502 -0.3179384501862632 -1.856376689812289 1.414666623123825 0.6202689538430226 1.6372666925021617 -3.7512295558532402 1.740271752071604 1.803112782208732 4.301201440619472 3.2881969114144116 -3.218996453427392 4.492406272330845 -3.0037715105804086 -2.82319338215279 -4.91478062740815 -1.9937342155488427 -2.2552917726986212 0.8644845073563125 -1.0344715251684677 -3.1359722615126175 -1.0718360133168936 -3.45406160182236 3.323044543698485 -3.5024792579850326 1.7954595170230814 2.5008998348854297 -4.851099917868478 -3.5775350188692934 -4.693443957550308 3.0869551273792446 -4.528540446900562 1.6618147810229313 -0.4396756441686813 3.0299637928610803; -1.4156109417905949 -4.746659548955744 -2.8141184370688355 2.1091490003479247 0.48920786284250006 3.6969303269399134 2.3883565579405284 -3.9676986757029664 4.714332142847491 2.3871260754906762 -4.8614242317498295 1.791216660669396 -0.1449726895549528 -4.652816495337153 -3.855603794792024 -4.23374889350921 1.078246783268355 -2.6653414800481876 -3.579885564509767 0.3017319826341316 4.303013382289329 1.169027702994021 1.898919176137282 -2.6557413332821813 -2.9315614007650312 -4.6263373408308865 1.6336496597836838 0.0725457062625745 -0.1419955067281622 3.6169500871873552 4.655149044462856 2.5968793532313104 -2.533205519081634 1.762674610030083 2.593054447404983 0.8618981404835857 3.224392670562917 4.268351454066988 1.3756687794255127 -4.8106213252176335 -3.1565936884747856 -4.73259290797468 4.349986710269958 -0.1553264165682844 2.947855590357559 -0.43164659908791947 -0.05790739082700824 -0.7428604750139982 3.917721551316541 3.7428511994270846; 1.33150369522766 -2.077206872049091 -2.083216596127083 -2.544999563280671 2.043479202181498 2.7461187292845493 3.2265356115860637 3.0618964573372534 -2.4622904651663555 3.0049986076873 1.2970872246262042 -2.6849843282760153 -1.189232384455312 -0.46798359597814976 0.005595581097153968 0.40571545174245927 -1.5485484136417629 -2.0856997196375335 2.0352859027723182 4.340784145306802 0.9417475729457303 0.9309077274486688 2.3873103386017434 -1.273568164709209 -0.46729624393541247 0.09375564521364765 4.287108353047554 -0.4921219335195506 1.3743486805373486 -0.4063614217584375 0.5377445941475676 -4.587673410754788 3.0220217890640075 1.7151163491690378 -2.9967240520942884 -4.854136265084266 2.6316602510701967 0.6751175986235038 1.5421380080684841 1.3474038850614969 2.3433020074257263 3.8732657945182574 1.6590901047365385 -3.793253985672812 2.1373559183832977 -0.5277282012007625 1.4098235277243445 1.4889612861605563 1.783753944971921 -4.411723609319451];
b=[0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0; 0.0];
D=[  1.0   0.0   0.0   0.0   0.0
  0.0   1.0   0.0   0.0   0.0
  0.0   0.0   1.0   0.0   0.0
  0.0   0.0   0.0   1.0   0.0
  0.0   0.0   0.0   0.0   1.0
 -1.0  -0.0  -0.0  -0.0  -0.0
 -0.0  -1.0  -0.0  -0.0  -0.0
 -0.0  -0.0  -1.0  -0.0  -0.0
 -0.0  -0.0  -0.0  -1.0  -0.0
 -0.0  -0.0  -0.0  -0.0  -1.0];
 d=[ 5.0
 2.5
 1.6666666666666667
 1.25
 1.0
 0.2
 0.4
 0.6
 0.8
 1.0];
 a=3;
 J=[ [1, 2, 3, 4, 5],
 [6, 7, 8, 9, 10],
 [11, 12, 13, 14, 15],
 [16, 17, 18, 19, 20],
 [21, 22, 23, 24, 25],
 [26, 27, 28, 29, 30],
 [31, 32, 33, 34, 35],
 [36, 37, 38, 39, 40],
 [41, 42, 43, 44, 45],
 [46, 47, 48, 49, 50]];
 Best_upp_x2=136.216102;
 best_solution=[ 1.7829526292444393
 2.1573064385462466
 0.0
 1.25
 0.0];
K=size(J,1);
total_J=sum(size(J[k],1) for k=1:K);
 tolerr=0;
model = Model(SCIP.Optimizer)
set_optimizer_attribute(model, "limits/time", 60)

@variable(model, x[1:n_x]>=0)
@variable(model, y[1:total_J])# y[]=A[:,j]'*x+b[j]
@variable(model, z[1:total_J-K])# maximum with yi and zi

## initialization
for tt=1:n_x
	set_start_value(x[tt], best_solution[tt]);
end

global up_to_k=0;
y_help=zeros(total_J,1);
z_help=zeros(total_J-K,1);
for k=1:K
	y_help[1+up_to_k:up_to_k+size(J[k],1)]=A[:,J[k]]'*best_solution+b[J[k]];
	for tt=1+up_to_k:up_to_k+size(J[k],1)
		set_start_value(y[tt],y_help[tt] );
	end
	z_help[up_to_k-(k-1)+1]=max(y_help[up_to_k+1],y_help[up_to_k+2]);
	set_start_value(z[up_to_k-(k-1)+1], z_help[up_to_k-(k-1)+1])
	for i=2:size(J[k],1)-1
		z_help[up_to_k-(k-1)+i] = max(z_help[up_to_k-(k-1)+i-1],y_help[up_to_k+i+1]);
		set_start_value(z[up_to_k-(k-1)+i],max(z_help[up_to_k-(k-1)+i-1],y_help[up_to_k+i+1]) );
	end
	global up_to_k=up_to_k+size(J[k],1);
end

#model construction
@constraint(model, D*x .<= d + tolerr*ones(size(D,1),1));
@NLconstraint(model, log(sum(exp(x[i]) for i=1:n_x))<=a+tolerr);
@objective(model, Max, sum(z[sum(size(J[k_tilde],1) for k_tilde=1:k)-(k-1)-1] for k=1:K));
@constraint(model,sum(z[sum(size(J[k_tilde],1) for k_tilde=1:k)-(k-1)-1] for k=1:K)<=Best_upp_x2);
global up_to_k=0;

for k=1:K
	@constraint(model, y[1+up_to_k:up_to_k+size(J[k],1)] .== A[:,J[k]]'*x+b[J[k]])
	@NLconstraint(model,z[up_to_k-(k-1)+1]==max(y[up_to_k+1],y[up_to_k+2]))
	for i=2:size(J[k],1)-1
		@NLconstraint(model, z[up_to_k-(k-1)+i]==max(z[up_to_k-(k-1)+i-1],y[up_to_k+i+1]) );
	end
	global up_to_k=up_to_k+size(J[k],1);
end

optimize!(model)

Your example does not work. With using JuMP, SCIP added, I get:

UndefVarError: total_J not defined

Whether or not SCIP uses the start values could be seen from the log (in either case, I think). I suspect that the warm start solution is not used, because none of your variables are integral. It might be possible to work around that by parameter settings.

Also note that SCIP is a global solver and uses an algorithm based on LP-based relaxations and spatial branching. So, even given the optimal solution as a warm start, it’s not true that the solver should stop immediatly, because it still needs to prove optimality.

For nonlinear problems, it’s highly recommended to provide finite bounds for all related variables.

2 Likes

Apologies for the inconvenience. I have updated the code.

I totally agree with you, but I also put the optimal value as the active cut. So, the use of warm start and checking the feasibility should be fine to prove optimality.

As you said, I see that SCIP doesn’t use the warm start from the log. It basically do the same iterations as if there is no warm start given.

Regarding your point on integer values, that is a bit strange to me. Are you sure about it?

But does it give a reason for it? Usually, it prints something like “Constraint […] violated in partial solution” or so.

It was just a hint, but I had a related problem in the past, where I fixed only a subset of the integer variables and SCIP didn’t attempt to solve the subproblem.

Check the parameters within /heuristics/completesol.

You could also try to write out the problem and warm start to files and run SCIP directly.

But does it give a reason for it? Usually, it prints something like “Constraint […] violated in partial solution” or so.

Below, you can find the log of the first iterations.

It was just a hint, but I had a related problem in the past, where I fixed only a subset of the integer variables and SCIP didn’t attempt to solve the subproblem.

Check the parameters within /heuristics/completesol .

I did check it, and no changes.

You could also try to write out the problem and warm start to files and run SCIP directly.

That is a bit challenging, as I am solving many randomly generated instances, and no that familiar with SCIP to directly make a for-loop there. At least this is what I am avoiding.

******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
 Ipopt is released as open source code under the Eclipse Public License (EPL).
         For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************

feasible solution found by trivial heuristic after 2.0 seconds, objective value 0.000000e+00
presolving:
(round 1, fast)       0 del vars, 10 del conss, 0 add conss, 11 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 2, fast)       0 del vars, 10 del conss, 0 add conss, 109 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 3, fast)       0 del vars, 10 del conss, 1 add conss, 109 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
(round 4, fast)       0 del vars, 10 del conss, 1 add conss, 110 chg bounds, 0 chg sides, 0 chg coeffs, 0 upgd conss, 0 impls, 0 clqs
presolving (5 rounds: 5 fast, 1 medium, 1 exhaustive):
 0 deleted vars, 10 deleted constraints, 1 added constraints, 110 tightened bounds, 0 added holes, 0 changed sides, 0 changed coefficients
 0 implications, 0 cliques
presolved problem has 96 variables (0 bin, 0 int, 0 impl, 96 cont) and 93 constraints
     51 constraints of type <linear>
     42 constraints of type <nonlinear>
Presolving Time: 2.00

 time | node  | left  |LP iter|LP it/n|mem/heur|mdpt |vars |cons |rows |cuts |sepa|confs|strbr|  dualbound   | primalbound  |  gap   | compl.
  2.0s|     1 |     0 |   531 |     - |  1798k |   0 |  96 |  93 | 104 |   1 |  0 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
  2.0s|     1 |     0 |   541 |     - |  2802k |   0 |  96 |  93 | 119 |  16 |  1 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
  2.0s|     1 |     0 |   568 |     - |  2802k |   0 |  96 |  93 | 120 |  17 |  2 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
  2.0s|     1 |     0 |   575 |     - |  2802k |   0 |  96 |  93 | 132 |  29 |  3 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
  2.0s|     1 |     0 |   576 |     - |  2802k |   0 |  96 |  93 | 133 |  30 |  4 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
  2.0s|     1 |     2 |   576 |     - |  2802k |   0 |  96 |  93 | 133 |  30 |  6 |   0 |   0 | 1.362161e+02 | 0.000000e+00 |    Inf | unknown
* 3.0s|    67 |    45 |  1008 |  12.9 |    LP  |  54 |  96 |  99 | 267 | 273 |  2 |   6 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|   0.43%
  3.0s|   100 |    64 |  1226 |  10.8 |  3630k |  54 |  96 | 101 | 193 | 408 |  2 |   8 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|   0.43%
  4.0s|   200 |   116 |  2236 |  10.5 |  4309k |  54 |  96 | 118 | 171 | 975 |  4 |  25 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|   0.43%
  4.0s|   300 |   170 |  3098 |   9.8 |  4549k |  54 |  96 | 132 | 167 |1496 |  3 |  39 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|   0.43%
  5.0s|   400 |   212 |  4642 |  11.2 |  4714k |  54 |  96 | 135 | 292 |2278 | 13 |  49 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|  20.79%
  5.0s|   500 |   278 |  5792 |  11.3 |  5621k |  54 |  96 | 139 | 262 |2921 |  2 |  54 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|  20.79%
  5.0s|   600 |   350 |  7586 |  12.4 |  6146k |  54 |  96 | 140 | 215 |3846 |  3 |  55 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|  20.79%
  5.0s|   700 |   416 |  8498 |  11.9 |  6272k |  54 |  96 | 144 | 173 |4395 |  8 |  60 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|  20.80%
  5.0s|   800 |   472 |  9744 |  12.0 |  6612k |  54 |  96 | 151 | 193 |5037 |  1 |  68 |   0 | 1.362161e+02 | 1.127854e+02 |  20.77%|  21.22%