This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% given an array of k subsets of numbers 1..n | |
% select a subset of 1..n such that at most one | |
% member of every subset is in it and the sum is maximized | |
int: n; % numbers from 1 to n | |
int: k; % number of subsets | |
set of int: OBJ = 1..n; | |
set of int: SET = 1..k; | |
int: u; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% try to define mydiv as integer division with partiality | |
function var int:mydiv(var int: x, var int: y) = | |
assert(lb(x) >= 0 /\ lb(y) >= 0, | |
"Mydiv got wrong arguments", | |
let {constraint y != 0 } in | |
safediv(x, y) | |
); | |
function var int: safediv(var int: x, var int: y) :: promise_total = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% a very minimal example to provoke isa: nullptr bug | |
% --------------------------------- | |
set of int: range = 1..5; | |
var set of range: x; | |
predicate onlyEvens(var set of range: y) = | |
( | |
forall(r in y) (r mod 2 = 0) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% a very minimal example to provoke isa: nullptr bug | |
% --------------------------------- | |
set of int: range = 1..5; | |
var set of range: x; | |
predicate onlyEvens(var set of range: y) = | |
( | |
forall(r in y) (r mod 2 = 0) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% a very minimal example to provoke isa: nullptr bug | |
% --------------------------------- | |
include "minisearch.mzn"; % include the search minisearch lite | |
set of int: range = 1..5; | |
var set of range: x; | |
predicate onlyEvens(var set of range: y) = | |
( | |
forall(r in y) (r mod 2 = 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% A really simplistic over-constrained model | |
% X: {x,y,z} D_i = {1,2,3}, i in X | |
% * c1: x + 1 = y | |
% * c2: z = y + 2 | |
% * c3: x + y <= 3 | |
% ------------------------------------------- | |
include "soft-constraints/soft_constraints.mzn"; % model additions for soft constraint business | |
include "soft-constraints/spd_worse.mzn"; % the actual isBetter predicate | |
include "soft-constraints/tpd_worse.mzn"; % the actual isBetter predicate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```matlab | |
include "classic_o.mzn"; % output of minibrass | |
include "soft_constraints/pvs_gen_search.mzn"; % for generic branch and bound | |
% the basic, "classic" CSP | |
set of int: NURSES = 1..3; | |
int: day = 1; int: night = 2; int:off = 3; | |
set of int: SHIFTS = {day,night,off}; | |
array[NURSES] of var SHIFTS: n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nCarTypes = 6; | |
nOptions = 5; | |
requires = array2d(CarTypes, Options, [ | |
true, false, true, true, false, | |
false, false, false, true, false, | |
false, true, false, false, true, | |
false, true, false, true, false, | |
true, false, false, false, false, | |
true, true, false, false, false]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first make sure to save the history ... | |
# let's actually fit our model | |
history = model.fit(train_images, train_labels, epochs=num_epochs, batch_size=batch_size) | |
# then, visualize the history | |
import pandas as pd | |
pd.DataFrame(history.history).plot(figsize=(8, 5)) | |
plt.grid(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# training für 10 epochen | |
history = model.fit(train_images, train_labels, batch_size=batch_size, | |
shuffle=True, epochs=n_epochs, validation_data = (test_images, test_labels)) | |
import pandas as pd | |
pd.DataFrame(history.history).plot(figsize=(8,5)) | |
plt.grid(True) | |
plt.gca().set_ylim(0, 1) | |
plt.show() |
OlderNewer