SCIP Optimization Suite. Three main software –zimpl: Compiler of ZIMPL modeling language...

Preview:

Citation preview

SCIP Optimization Suite

2

SCIP Optimization Suite

• Three main software – zimpl: Compiler of ZIMPL modeling language

– soplex: LP solver (implementation of Simplex)

– scip: An advanced implementation of B&B to solve ILP

• All these are available in single packages– SCIP optimization suite

– Source code

– zimpl, soplex, scip are standalone applications

– Binary (Linux & Windows)

– Single executable scip application that is linked by zimpl & soplex

3

How Does It Work?• As a programming library

– It has API, you can call the functions in C, C++

• As a standalone solver– Develop a model in zimpl language – Compile/Translate your model: zimpl model.zpl– Solve it

• LP problems: soplex model.lp• ILP, MIP problems: scip -f model.lp

– scip by itself calls zimpl if the input file is not .lp• scip -f model.zpl

4

max( )

mins.t.

~

i ii

ij i ji

f x cx

a x b j

=

"

å

å

5

What we need

• Parameters • Variables

• Sets

• Objective function

• Constraints

, ,i ij jc a b

ix

,i I j JÎ Î

( )f x

~ij i ji

a x bå

6

Sets

• Set of numbers

• Set of strings

• Set of tuples

7

Set operations

8

{<1, “hi”>, <2, “hi”>, <3, “hi”>, <1, “ha”>, …}

{1, 6, 7, 8, 9}

9

Indexed Sets

• The arrays of ZIMPL

• Each element has its own index– A set indexes another set

• Refer to i-th element by S[i]

• Exampleset I := {1, 2, 4};

set A[I] := <1> {10}, <2> {20}, <4> {30,40,50};

set B[ <i> in I] := {10 * i};

10

Parameters

• set A := {1,2,3};

• param B := 10;

• param C[A] := <1> 10, <2> 20, <3> 30;

• param D[A] := <1> 100 default 0;

• param E := min A;

• param F := max <i> in A : C[i];

11

These operations are used in zimpl models to generate the numerical model.

Most operations are applicable only on parameters, cannot be used for variables, because they are not linear

12

Variables

• “real”, “binary”, or “integer”– Default is “real”

• var x1;

• var x2 integer;

• var x3 binary;

• set A := {1,2,3};

• var x4[A] real;

• var x5[A * A] integer >=0 <= 10;

13

Objective

• “maximize” or “minimize”

• var x1;

• var x2;

• var x3;

• maximize obj1: x1 + x2 + x3;

• minimize obj2: 2*x1 + 3*x2;

14

Objective

• set A := {1,2,3};

• param B[A] := <1> 10, <2> 20, <3> 30;

• var X[A];

• maximize obj1: sum <i> in A: X[i];

• minimize obj2: sum <i> in A: B[i] * X[i];

15

Constraint

• subto name: constraint– “<=“ , “=>”, “==“ – There is not “>” and “<“

• subto c1: x1 <= 10;

• subto c2: x1 + x2 <= 20;

• subto c3: x1 + x2 + x3 == 100;

16

Constraint

• set A := {1,2,3};

• param B[A] := <1> 10, <2> 20, <3> 30;

• var X[A];

• subto c1: forall <i> in A: X[i] <= B[i];

17

Expressions

• forall expression– forall <i> in S: x[i] <= b[i];

• sum expression– sum <i> in S: x[i];

• if expression– forall <i> in S: x[i] <= if (i mod 3 == 0) then A[i]

else B[i] end;

18

Example

max

s.t.

[1,20,300]

1 2 3 20,

30 20 10 200

Tc x

Ax b

c

A b

£

=

é ù é ùê ú ê ú= =ê ú ê úê ú ê úë û ë û

19

set I := {1,2,3};set J := {1,2};

param c[I] := <1> 1, <2> 20, <3> 300;param A[J * I] := <1,1> 1, <1,2> 2, <1,3> 3, <2,1>

30, <2,2> 20, <2,3> 10;param b[J] := <1> 20, <2> 200;

var X[I];

maximize obj: sum <i> in I: c[i] * X[i];

subto const: forall <j> in J:sum <i> in I: A[j,i] * X[i] <= b[j];

20

Realistic Problems

• A model for the problem

• Multiple instances– Each instance has its own data

• Separation between model and data– Create a general model

– Read data from file

21

Reading Set and Parameters from file

• “read filename as template”

• set A := {read "a.txt" as "<1n>"};

• a.txt12345

22

• set A := {read "a.txt" as "<1n>"};

• param B[A] := read "b.txt" as "<1n> 2s";

• a.txt b.txt

1 1 aa

2 3 bb

3 2 cc

23

max

s.t.

Tc x

Ax b£

24

set I := {read "I.txt" as "<1n>"};set J := {read "J.txt" as "<1n>"};

param c[I] := read "c.txt" as "<1n> 2n";param A[J * I] := read "A.txt" as "<1n,2n> 3n";param b[J] := read "b.txt" as "<1n> 2n";

var X[I];

maximize obj: sum <i> in I: c[i] * X[i];

subto const: forall <j> in J:sum <i> in I: A[j,i] * X[i] <= b[j];

25

26

Integrality Complexity: An Example

• Consider the LP problem– I = 1000 – J = 100

• If variables are “real”– Solution time = 0.21 sec.– Objective = 1727.05

• If variables are “integer”– Solution time = 22.85 sec.– Objective = 1724

Recommended