1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
on-restart-benchmarks/tests/spec/unit/test-globals-float.mzn
Jip J. Dekker fad1b07018 Squashed 'software/minizinc/' content from commit 4f10c8205
git-subtree-dir: software/minizinc
git-subtree-split: 4f10c82056ffcb1041d7ffef29d77a7eef92cf76
2021-06-16 14:06:46 +10:00

60 lines
1.8 KiB
MiniZinc

/***
!Test
solvers: [gecode, cbc]
expected:
- !Result
solution: !Solution
inc_avf: [1.0, 2.0, 2.0]
min_vf1: !Approx 0.0
min_vf2: !Approx 0.0
max_vf1: !Approx 9.9
max_vf2: !Approx 0.0
- !Result
solution: !Solution
inc_avf: [1.0, 2.0, 2.0]
min_vf1: !Approx 0.0
min_vf2: !Approx 0.0
max_vf1: !Approx 9.9
max_vf2: !Approx 9.9
***/
%-----------------------------------------------------------------------------%
% This file tests the global constraints in globals.mzn that involve
% variables of type `var float'.
%-----------------------------------------------------------------------------%
include "globals.mzn";
% Variable naming scheme: all variables for a constraint get a common
% prefix based on the constraint name, eg. "alldiff".
%-----------------------------------------------------------------------------%
% increasing
%-----------------------------------------------------------------------------%
% test satisfaction
array[1..3] of var float: inc_avf :: add_to_output = [1.0, 2.0, _];
constraint increasing(inc_avf);
%-----------------------------------------------------------------------------%
% minimum, maximum
%-----------------------------------------------------------------------------%
var 0.0..20.0: min_vf1 :: add_to_output;
var 0.0..20.0: min_vf2 :: add_to_output;
var 0.0..20.0: max_vf1 :: add_to_output;
var 0.0..20.0: max_vf2 :: add_to_output;
% XXX: min/2 for floats not yet handled
constraint minimum(min_vf1, [5.5, 3.3, 8.8, 0.0, 4.4]);
constraint minimum(0.0, [5.5, 3.3, 8.8, min_vf2, 4.4]);
% XXX: max/2 for floats not yet handled
constraint maximum(max_vf1, [5.5, 3.3, 8.8, 9.9, 4.4]);
constraint maximum(9.9, [5.5, 3.3, 8.8, max_vf2, 4.4]);
%-----------------------------------------------------------------------------%
solve satisfy;