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