Scippy

SCIP

Solving Constraint Integer Programs

spring.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (c) 2002-2024 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file spring.c
26  * @brief Coil Compression Spring Design model
27  * @author Stefan Vigerske
28  *
29  * This example shows how to setup quadratic and nonlinear constraints in SCIP when using SCIP as callable library.
30  * The example implements a model for the design of a coil compression spring as it can be found in the GAMS model library:
31  * https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_spring.html
32  *
33  * The task is to find a minimum volume of a wire for the production of a coil compression spring.
34  *
35  * Original model source:
36  * @par
37  * E. Sangren@n
38  * Nonlinear Integer and Discrete Programming in Mechanical Design Optimization@n
39  * Journal of Mechanical Design, Trans. ASME 112 (1990), 223-229
40  */
41 
42 /*--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
43 
44 #define _USE_MATH_DEFINES /* to get M_PI, etc, on Windows */
45 
46 /* workaround if standard makefiles aren't used */
47 #if !defined(_XOPEN_SOURCE) || _XOPEN_SOURCE < 600
48 #undef _XOPEN_SOURCE
49 #define _XOPEN_SOURCE 600
50 #endif
51 
52 #include <stdio.h>
53 #include <math.h>
54 
55 #include "scip/scip.h"
56 #include "scip/scipdefplugins.h"
57 
58 /* Model parameters */
59 
60 /** number of possible wire types */
61 #define nwires 11
62 
63 /** diameters of available diameters (in) */
64 static const SCIP_Real diameters[] = { 0.207, 0.225, 0.244, 0.263, 0.283, 0.307, 0.331, 0.362, 0.394, 0.4375, 0.500 };
65 
66 /** preload (lb) */
67 static const SCIP_Real preload = 300;
68 
69 /** maximal working load (lb) */
70 static const SCIP_Real maxworkload = 1000;
71 
72 /** maximal deflection (in) */
73 static const SCIP_Real maxdeflect = 6;
74 
75 /** deflection from preload (in) */
76 static const SCIP_Real deflectpreload = 1.25;
77 
78 /** maximal free length of spring (in) */
79 static const SCIP_Real maxfreelen = 14.0;
80 
81 /** maximal coil diameter (in) */
82 static const SCIP_Real maxcoildiam = 3.0;
83 
84 /** maximal shear stress */
85 static const SCIP_Real maxshearstress = 189000.0;
86 
87 /** shear modulus of material */
88 static const SCIP_Real shearmod = 11500000.0;
89 
90 
91 /** sets up problem */
92 static
94  SCIP* scip /**< SCIP data structure */
95  )
96 {
97  SCIP_VAR* coil; /* coil diameter */
98  SCIP_VAR* wire; /* wire diameter */
99  SCIP_VAR* defl; /* deflection */
100  SCIP_VAR* ncoils; /* number of coils (integer) */
101  SCIP_VAR* const1; /* a constant */
102  SCIP_VAR* const2; /* another constant */
103  SCIP_VAR* volume; /* total volume */
104  SCIP_VAR* y[nwires]; /* wire choice (binary) */
105 
106  SCIP_EXPR* coilexpr;
107  SCIP_EXPR* wireexpr;
108  SCIP_EXPR* deflexpr;
109  SCIP_EXPR* ncoilsexpr;
110  SCIP_EXPR* const1expr;
111  SCIP_EXPR* const2expr;
112  SCIP_EXPR* volumeexpr;
113 
114  SCIP_CONS* voldef;
115  SCIP_CONS* defconst1;
116  SCIP_CONS* defconst2;
117  SCIP_CONS* shear;
118  SCIP_CONS* defdefl;
119  SCIP_CONS* freel;
120  SCIP_CONS* coilwidth;
121  SCIP_CONS* defwire;
122  SCIP_CONS* selectwire;
123 
124  char name[SCIP_MAXSTRLEN];
125  int i;
126 
127  /* create empty problem */
128  SCIP_CALL( SCIPcreateProbBasic(scip, "spring") );
129 
130  /* create variables */
131  SCIP_CALL( SCIPcreateVarBasic(scip, &coil, "coildiam", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS) );
132  SCIP_CALL( SCIPcreateVarBasic(scip, &wire, "wirediam", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS) );
133  SCIP_CALL( SCIPcreateVarBasic(scip, &defl, "deflection", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS) );
134  SCIP_CALL( SCIPcreateVarBasic(scip, &ncoils, "ncoils", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_INTEGER) );
135  SCIP_CALL( SCIPcreateVarBasic(scip, &const1, "const1", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS) );
136  SCIP_CALL( SCIPcreateVarBasic(scip, &const2, "const2", 0.0, SCIPinfinity(scip), 0.0, SCIP_VARTYPE_CONTINUOUS) );
137  SCIP_CALL( SCIPcreateVarBasic(scip, &volume, "volume", 0.0, SCIPinfinity(scip), 1.0, SCIP_VARTYPE_CONTINUOUS) );
138  for( i = 0; i < nwires; ++i )
139  {
140  (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "wire%d", i+1);
141  SCIP_CALL( SCIPcreateVarBasic(scip, &y[i], name, 0.0, 1.0, 0.0, SCIP_VARTYPE_BINARY) );
142  }
143 
144  /* set nonstandard variable bounds */
146  SCIP_CALL( SCIPchgVarUb(scip, defl, maxdeflect / preload) );
147 
148  /* add variables to problem */
149  SCIP_CALL( SCIPaddVar(scip, coil) );
150  SCIP_CALL( SCIPaddVar(scip, wire) );
151  SCIP_CALL( SCIPaddVar(scip, defl) );
152  SCIP_CALL( SCIPaddVar(scip, ncoils) );
153  SCIP_CALL( SCIPaddVar(scip, const1) );
154  SCIP_CALL( SCIPaddVar(scip, const2) );
155  SCIP_CALL( SCIPaddVar(scip, volume) );
156  for( i = 0; i < nwires; ++i )
157  {
158  SCIP_CALL( SCIPaddVar(scip, y[i]) );
159  }
160 
161  /* create variable expressions */
162  SCIP_CALL( SCIPcreateExprVar(scip, &coilexpr, coil, NULL, NULL) );
163  SCIP_CALL( SCIPcreateExprVar(scip, &wireexpr, wire, NULL, NULL) );
164  SCIP_CALL( SCIPcreateExprVar(scip, &deflexpr, defl, NULL, NULL) );
165  SCIP_CALL( SCIPcreateExprVar(scip, &ncoilsexpr, ncoils, NULL, NULL) );
166  SCIP_CALL( SCIPcreateExprVar(scip, &const1expr, const1, NULL, NULL) );
167  SCIP_CALL( SCIPcreateExprVar(scip, &const2expr, const2, NULL, NULL) );
168  SCIP_CALL( SCIPcreateExprVar(scip, &volumeexpr, volume, NULL, NULL) );
169 
170  /* nonlinear constraint voldef: PI/2 * (ncoils+2)*coil*wire^2 - volume == 0 */
171  {
172  SCIP_EXPR* exprs[3];
173  SCIP_EXPR* powexpr;
174  SCIP_EXPR* prodexpr;
175  SCIP_EXPR* sumexpr;
176  SCIP_EXPR* expr;
177  SCIP_Real coefs[2];
178 
179  /* create wire^2 */
180  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr, wireexpr, 2.0, NULL, NULL) );
181 
182  /* create (ncoils+2) */
183  SCIP_CALL( SCIPcreateExprSum(scip, &sumexpr, 1, &ncoilsexpr, NULL, 2.0, NULL, NULL) );
184 
185  /* create (ncoils+2)*coil*wire^2 */
186  exprs[0] = sumexpr;
187  exprs[1] = coilexpr;
188  exprs[2] = powexpr;
189  SCIP_CALL( SCIPcreateExprProduct(scip, &prodexpr, 3, exprs, 1.0, NULL, NULL) );
190 
191  /* create PI/2 * (ncoils+2)*coil*wire^2 - volume */
192  exprs[0] = prodexpr;
193  coefs[0] = M_PI_2;
194  exprs[1] = volumeexpr;
195  coefs[1] = -1.0;
196  SCIP_CALL( SCIPcreateExprSum(scip, &expr, 2, exprs, coefs, 0.0, NULL, NULL) );
197 
198  /* create nonlinear constraint */
199  SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &voldef, "voldef", expr, 0.0, 0.0) );
200 
201  /* release expressions */
202  SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
203  SCIP_CALL( SCIPreleaseExpr(scip, &prodexpr) );
204  SCIP_CALL( SCIPreleaseExpr(scip, &sumexpr) );
205  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr) );
206  }
207 
208  /* nonlinear constraint defconst1: coil / wire - const1 == 0.0 */
209  {
210  SCIP_EXPR* exprs[2];
211  SCIP_EXPR* powexpr;
212  SCIP_EXPR* prodexpr;
213  SCIP_EXPR* sumexpr;
214  SCIP_Real coefs[2];
215 
216  /* create 1 / wire */
217  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr, wireexpr, -1.0, NULL, NULL) );
218 
219  /* create coil / wire */
220  exprs[0] = coilexpr;
221  exprs[1] = powexpr;
222  SCIP_CALL( SCIPcreateExprProduct(scip, &prodexpr, 2, exprs, 1.0, NULL, NULL) );
223 
224  /* create coil / wire - const1 */
225  exprs[0] = prodexpr;
226  coefs[0] = 1.0;
227  exprs[1] = const1expr;
228  coefs[1] = -1.0;
229  SCIP_CALL( SCIPcreateExprSum(scip, &sumexpr, 2, exprs, coefs, 0.0, NULL, NULL) );
230 
231  /* create nonlinear constraint */
232  SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &defconst1, "defconst1", sumexpr, 0.0, 0.0) );
233 
234  /* release expressions */
235  SCIP_CALL( SCIPreleaseExpr(scip, &sumexpr) );
236  SCIP_CALL( SCIPreleaseExpr(scip, &prodexpr) );
237  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr) );
238  }
239 
240  /* nonlinear constraint defconst2: (4.0 * const1 - 1.0) / (4.0 * const1 - 4.0) + 0.615 / const1 - const2 == 0.0 */
241  {
242  SCIP_EXPR* exprs[3];
243  SCIP_EXPR* sumexpr1;
244  SCIP_EXPR* sumexpr2;
245  SCIP_EXPR* powexpr1;
246  SCIP_EXPR* powexpr2;
247  SCIP_EXPR* prodexpr;
248  SCIP_EXPR* expr;
249  SCIP_Real coefs[3];
250 
251  /* create (4.0 * const1 - 1.0) */
252  coefs[0] = 4.0;
253  SCIP_CALL( SCIPcreateExprSum(scip, &sumexpr1, 1, &const1expr, coefs, -1.0, NULL, NULL) );
254 
255  /* create (4.0 * const1 - 4.0) */
256  coefs[0] = 4.0;
257  SCIP_CALL( SCIPcreateExprSum(scip, &sumexpr2, 1, &const1expr, coefs, -4.0, NULL, NULL) );
258 
259  /* create 1 / (4.0 * const1 - 4.0) */
260  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr1, sumexpr2, -1.0, NULL, NULL) );
261 
262  /* create (4.0 * const1 - 1.0) / (4.0 * const1 - 4.0) */
263  exprs[0] = sumexpr1;
264  exprs[1] = powexpr1;
265  SCIP_CALL( SCIPcreateExprProduct(scip, &prodexpr, 2, exprs, 1.0, NULL, NULL) );
266 
267  /* create 1 / const1 */
268  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr2, const1expr, -1.0, NULL, NULL) );
269 
270  /* create (4.0 * const1 - 1.0) / (4.0 * const1 - 4.0) + 0.615 / const1 - const2 */
271  exprs[0] = prodexpr;
272  coefs[0] = 1.0;
273  exprs[1] = powexpr2;
274  coefs[1] = 0.615;
275  exprs[2] = const2expr;
276  coefs[2] = -1.0;
277  SCIP_CALL( SCIPcreateExprSum(scip, &expr, 3, exprs, coefs, 0.0, NULL, NULL) );
278 
279  /* create nonlinear constraint */
280  SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &defconst2, "defconst2", expr, 0.0, 0.0) );
281 
282  /* release expressions */
283  SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
284  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr2) );
285  SCIP_CALL( SCIPreleaseExpr(scip, &prodexpr) );
286  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr1) );
287  SCIP_CALL( SCIPreleaseExpr(scip, &sumexpr2) );
288  SCIP_CALL( SCIPreleaseExpr(scip, &sumexpr1) );
289  }
290 
291  /* quadratic constraint shear: 8.0*maxworkload/PI * const1 * const2 - maxshearstress * wire^2 <= 0.0 */
292  {
293  SCIP_VAR* quadvars1[2] = {const1, wire};
294  SCIP_VAR* quadvars2[2] = {const2, wire};
295  SCIP_Real quadcoefs[2] = {8.0 * maxworkload / M_PI, -maxshearstress};
296 
297  /* create empty quadratic constraint with right-hand-side 0.0 */
298  SCIP_CALL( SCIPcreateConsQuadraticNonlinear(scip, &shear, "shear", 0, NULL, NULL, 2, quadvars1, quadvars2, quadcoefs,
299  -SCIPinfinity(scip), 0.0, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
300  }
301 
302  /* nonlinear constraint defdefl: 8.0/shearmod * ncoils * const1^3 / wire - defl == 0.0 */
303  {
304  SCIP_EXPR* exprs[3];
305  SCIP_EXPR* prodexpr;
306  SCIP_EXPR* powexpr1;
307  SCIP_EXPR* powexpr2;
308  SCIP_EXPR* expr;
309  SCIP_Real coefs[3];
310 
311  /* create const1^3 */
312  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr1, const1expr, 3.0, NULL, NULL) );
313 
314  /* create 1 / wire */
315  SCIP_CALL( SCIPcreateExprPow(scip, &powexpr2, wireexpr, -1.0, NULL, NULL) );
316 
317  /* create ncoils * const1^3 / wire */
318  exprs[0] = ncoilsexpr;
319  exprs[1] = powexpr1;
320  exprs[2] = powexpr2;
321  SCIP_CALL( SCIPcreateExprProduct(scip, &prodexpr, 3, exprs, 1.0, NULL, NULL) );
322 
323  /* create 8.0/shearmod * ncoils * const1^3 / wire - defl */
324  exprs[0] = prodexpr;
325  coefs[0] = 8.0 / shearmod;
326  exprs[1] = deflexpr;
327  coefs[1] = -1.0;
328  SCIP_CALL( SCIPcreateExprSum(scip, &expr, 2, exprs, coefs, 0.0, NULL, NULL) );
329 
330  /* create nonlinear constraint */
331  SCIP_CALL( SCIPcreateConsBasicNonlinear(scip, &defdefl, "defdefl", expr, 0.0, 0.0) );
332 
333  /* release expressions */
334  SCIP_CALL( SCIPreleaseExpr(scip, &expr) );
335  SCIP_CALL( SCIPreleaseExpr(scip, &prodexpr) );
336  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr2) );
337  SCIP_CALL( SCIPreleaseExpr(scip, &powexpr1) );
338  }
339 
340  /* quadratic constraint freel: maxworkload * defl + 1.05 * ncoils * wire + 2.1 * wire <= maxfreelen */
341  {
342  SCIP_VAR* linvars[2] = {defl, wire};
343  SCIP_Real lincoefs[2] = {maxworkload, 2.1};
344  SCIP_Real one05 = 1.05;
345 
346  /* create quadratic constraint maxworkload * defl + 1.05 * ncoils * wire <= maxfreelen */
347  SCIP_CALL( SCIPcreateConsQuadraticNonlinear(scip, &freel, "freel", 2, linvars, lincoefs, 1, &ncoils, &wire, &one05,
349  FALSE, FALSE) );
350  }
351 
352  /* linear constraint coilwidth: coil + wire <= maxcoildiam */
353  {
354  /* create empty linear constraint with right-hand-side maxcoildiam */
355  SCIP_CALL( SCIPcreateConsBasicLinear(scip, &coilwidth, "coilwidth", 0, NULL, NULL, -SCIPinfinity(scip), maxcoildiam) );
356 
357  /* add linear term coil + wire */
358  SCIP_CALL( SCIPaddCoefLinear(scip, coilwidth, coil, 1.0) );
359  SCIP_CALL( SCIPaddCoefLinear(scip, coilwidth, wire, 1.0) );
360  }
361 
362  /* linear constraint defwire: sum_i b[i]*y[i] - wire == 0.0 */
363  {
364  /* create linear constraint sum_i b[i]*y[i] == 0.0 */
365  SCIP_CALL( SCIPcreateConsBasicLinear(scip, &defwire, "defwire", nwires, y, (SCIP_Real*)diameters, 0.0, 0.0) );
366 
367  /* add term -wire */
368  SCIP_CALL( SCIPaddCoefLinear(scip, defwire, wire, -1.0) );
369  }
370 
371  /* specialized linear constraint selectwire: sum_i y[i] == 1.0 */
372  {
373  SCIP_CALL( SCIPcreateConsBasicSetpart(scip, &selectwire, "selectwire", nwires, y) );
374  }
375 
376  /* add constraints to problem */
377  SCIP_CALL( SCIPaddCons(scip, voldef) );
378  SCIP_CALL( SCIPaddCons(scip, defconst1) );
379  SCIP_CALL( SCIPaddCons(scip, defconst2) );
380  SCIP_CALL( SCIPaddCons(scip, shear) );
381  SCIP_CALL( SCIPaddCons(scip, defdefl) );
382  SCIP_CALL( SCIPaddCons(scip, freel) );
383  SCIP_CALL( SCIPaddCons(scip, coilwidth) );
384  SCIP_CALL( SCIPaddCons(scip, defwire) );
385  SCIP_CALL( SCIPaddCons(scip, selectwire) );
386 
387  /* release variable expressions */
388  SCIP_CALL( SCIPreleaseExpr(scip, &volumeexpr) );
389  SCIP_CALL( SCIPreleaseExpr(scip, &const2expr) );
390  SCIP_CALL( SCIPreleaseExpr(scip, &const1expr) );
391  SCIP_CALL( SCIPreleaseExpr(scip, &ncoilsexpr) );
392  SCIP_CALL( SCIPreleaseExpr(scip, &deflexpr) );
393  SCIP_CALL( SCIPreleaseExpr(scip, &wireexpr) );
394  SCIP_CALL( SCIPreleaseExpr(scip, &coilexpr) );
395 
396  /* release variables and constraints
397  * the problem has them captured, and we do not require them anymore
398  */
399  SCIP_CALL( SCIPreleaseVar(scip, &coil) );
400  SCIP_CALL( SCIPreleaseVar(scip, &wire) );
401  SCIP_CALL( SCIPreleaseVar(scip, &defl) );
402  SCIP_CALL( SCIPreleaseVar(scip, &ncoils) );
403  SCIP_CALL( SCIPreleaseVar(scip, &const1) );
404  SCIP_CALL( SCIPreleaseVar(scip, &const2) );
405  SCIP_CALL( SCIPreleaseVar(scip, &volume) );
406  for( i = 0; i < nwires; ++i )
407  {
408  SCIP_CALL( SCIPreleaseVar(scip, &y[i]) );
409  }
410 
411  SCIP_CALL( SCIPreleaseCons(scip, &voldef) );
412  SCIP_CALL( SCIPreleaseCons(scip, &defconst1) );
413  SCIP_CALL( SCIPreleaseCons(scip, &defconst2) );
414  SCIP_CALL( SCIPreleaseCons(scip, &shear) );
415  SCIP_CALL( SCIPreleaseCons(scip, &defdefl) );
416  SCIP_CALL( SCIPreleaseCons(scip, &freel) );
417  SCIP_CALL( SCIPreleaseCons(scip, &coilwidth) );
418  SCIP_CALL( SCIPreleaseCons(scip, &defwire) );
419  SCIP_CALL( SCIPreleaseCons(scip, &selectwire) );
420 
421  return SCIP_OKAY;
422 }
423 
424 /** runs spring example */
425 static
427 {
428  SCIP* scip;
429 
430  SCIP_CALL( SCIPcreate(&scip) );
432 
433  SCIPinfoMessage(scip, NULL, "\n");
434  SCIPinfoMessage(scip, NULL, "************************************************\n");
435  SCIPinfoMessage(scip, NULL, "* Running Coil Compression Spring Design Model *\n");
436  SCIPinfoMessage(scip, NULL, "************************************************\n");
437  SCIPinfoMessage(scip, NULL, "\n");
438 
439  SCIP_CALL( setupProblem(scip) );
440 
441  SCIPinfoMessage(scip, NULL, "Original problem:\n");
442  SCIP_CALL( SCIPprintOrigProblem(scip, NULL, "cip", FALSE) );
443 
444  SCIPinfoMessage(scip, NULL, "\n");
445  SCIP_CALL( SCIPpresolve(scip) );
446 
447  /* SCIPinfoMessage(scip, NULL, "Reformulated problem:\n");
448  SCIP_CALL( SCIPprintTransProblem(scip, NULL, "cip", FALSE) );
449  */
450 
451  SCIPinfoMessage(scip, NULL, "\nSolving...\n");
452  SCIP_CALL( SCIPsolve(scip) );
453 
454  if( SCIPgetNSols(scip) > 0 )
455  {
456  SCIPinfoMessage(scip, NULL, "\nSolution:\n");
457  SCIP_CALL( SCIPprintSol(scip, SCIPgetBestSol(scip), NULL, FALSE) );
458  }
459 
460  SCIP_CALL( SCIPfree(&scip) );
461 
462  return SCIP_OKAY;
463 }
464 
465 
466 /** main method starting SCIP */
467 int main(
468  int argc, /**< number of arguments from the shell */
469  char** argv /**< array of shell arguments */
470  )
471 { /*lint --e{715}*/
472  SCIP_RETCODE retcode;
473 
474  retcode = runSpring();
475 
476  /* evaluate return code of the SCIP process */
477  if( retcode != SCIP_OKAY )
478  {
479  /* write error back trace */
480  SCIPprintError(retcode);
481  return -1;
482  }
483 
484  return 0;
485 }
static const SCIP_Real shearmod
Definition: spring.c:88
#define NULL
Definition: def.h:267
SCIP_RETCODE SCIPcreateExprPow(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_Real exponent, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_pow.c:3194
SCIP_RETCODE SCIPcreateConsBasicLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs)
static SCIP_RETCODE setupProblem(SCIP *scip)
Definition: spring.c:93
static const SCIP_Real deflectpreload
Definition: spring.c:76
#define SCIP_MAXSTRLEN
Definition: def.h:288
#define nwires
Definition: spring.c:61
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1250
#define FALSE
Definition: def.h:94
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10877
#define TRUE
Definition: def.h:93
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
static const SCIP_Real maxfreelen
Definition: spring.c:79
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
Definition: scip_var.c:194
static const SCIP_Real maxshearstress
Definition: spring.c:85
static const SCIP_Real preload
Definition: spring.c:67
SCIP_RETCODE SCIPchgVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4678
SCIP_RETCODE SCIPcreateExprVar(SCIP *scip, SCIP_EXPR **expr, SCIP_VAR *var, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_var.c:390
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:307
SCIP_RETCODE SCIPcreateExprSum(SCIP *scip, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefficients, SCIP_Real constant, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_sum.c:1114
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
SCIP_RETCODE SCIPcreateProbBasic(SCIP *scip, const char *name)
Definition: scip_prob.c:180
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2486
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2770
SCIP_RETCODE SCIPcreateConsBasicNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_EXPR *expr, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPpresolve(SCIP *scip)
Definition: scip_solve.c:2316
SCIP_RETCODE SCIPcreateConsQuadraticNonlinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nlinvars, SCIP_VAR **linvars, SCIP_Real *lincoefs, int nquadterms, SCIP_VAR **quadvars1, SCIP_VAR **quadvars2, SCIP_Real *quadcoefs, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable)
SCIP_RETCODE SCIPchgVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip_var.c:4768
SCIP_RETCODE SCIPprintOrigProblem(SCIP *scip, FILE *file, const char *extension, SCIP_Bool genericnames)
SCIP_RETCODE SCIPcreateExprProduct(SCIP *scip, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real coefficient, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
#define SCIP_CALL(x)
Definition: def.h:380
static SCIP_RETCODE runSpring(void)
Definition: spring.c:426
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
SCIP_RETCODE SCIPreleaseExpr(SCIP *scip, SCIP_EXPR **expr)
Definition: scip_expr.c:1417
int main(int argc, char **argv)
Definition: spring.c:467
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2070
static const SCIP_Real maxcoildiam
Definition: spring.c:82
#define M_PI
Definition: pricer_rpa.c:97
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2169
static const SCIP_Real diameters[]
Definition: spring.c:64
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1668
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1174
static const SCIP_Real maxworkload
Definition: spring.c:70
#define SCIP_Real
Definition: def.h:173
SCIP_VAR ** y
Definition: circlepacking.c:64
static const SCIP_Real maxdeflect
Definition: spring.c:73
SCIP_RETCODE SCIPcreateConsBasicSetpart(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars)
Definition: cons_setppc.c:9399
void SCIPprintError(SCIP_RETCODE retcode)
Definition: scip_general.c:221
default SCIP plugins
SCIP callable library.
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:339
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1631