translating a "test" to minizinc

50 views
Skip to first unread message

Olaf

unread,
Dec 10, 2023, 5:12:42 PM12/10/23
to MiniZinc
I am investigating if constraint programming can help me finding testcases.
I am looking for beginners resources on this topic, it would be great if you have some suggestion.

Maybe it is possible to even guide me to a solution of a simple example.

a description of the "program" would be:
"If the input (uint8) is smaller then 128 then the the output is 0 otherwise 1"
I expect one could write a minizinc program that would implement this statement and return two testcases:
set input = 0 expected output == 0
set input = 128 expected output == 1

(more interesting would be the range of numbers in input 0..127 , 128..255, but i want to keep it simple for now)

Amr Hany Saleh

unread,
Dec 10, 2023, 6:39:58 PM12/10/23
to mini...@googlegroups.com
Hi,

I think the minizinc tutorial would be a good place to start.

For your given problem, one way to model this problem is to create a model where the input and output are variables and you can start relating between them via using constraints.

set of int: input_set = {0,128};
var input_set: i;
var 0..1: o;
constraint i = 0 -> o = 0;
constraint i = 128 -> o = 1;
solve satisfy;

we'd in this case need to find all solutions for the model to cover the entire search space of potential "test cases" ( needs to be enabled on the minizincIDE ) or use the command ( minizinc -a model.mzn ) in the command line.

Maybe also you can check the send more money problem, (https://www.minizinc.org/doc-2.8.1/en/modelling2.html).

hope this helps.


--
You received this message because you are subscribed to the Google Groups "MiniZinc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minizinc+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/minizinc/6131354c-e19e-4181-9ae7-bc7282453492n%40googlegroups.com.


--
Best Regards,
Amr Hany Saleh

Olaf

unread,
Dec 11, 2023, 6:06:17 PM12/11/23
to MiniZinc
thank you Amr Hany 
that was already a great help.
right now i am learning how to translate my ideas to minizinc and it works :-)

best
olaf

Amr Hany Saleh schrieb am Montag, 11. Dezember 2023 um 00:39:58 UTC+1:
Hi,

I think the minizinc tutorial would be a good place to start.

For your given problem, one way to model this problem is to create a model where the input and output are variables and you can start relating between them via using constraints.

set of int: input_set = {0,128}; var input_set: i; var 0..1: o; constraint i = 0 -> o = 0; constraint i = 128 -> o = 1; solve satisfy;

we'd in this case need to find all solutions for the model to cover the entire search space of potential "test cases" ( needs to be enabled on the minizincIDE ) or use the command ( minizinc -a model.mzn ) in the command line.

Maybe also you can check the send more money problem, (https://www.minizinc.org/doc-2.8.1/en/modelling2.html).

hope this helps.


On Sun, Dec 10, 2023 at 11:12 PM Olaf wrote:
I am investigating if constraint programming can help me finding testcases.
I am looking for beginners resources on this topic, it would be great if you have some suggestion.

Maybe it is possible to even guide me to a solution of a simple example.

a description of the "program" would be:
"If the input (uint8) is smaller then 128 then the the output is 0 otherwise 1"
I expect one could write a minizinc program that would implement this statement and return two testcases:
set input = 0 expected output == 0
set input = 128 expected output == 1

(more interesting would be the range of numbers in input 0..127 , 128..255, but i want to keep it simple for now)



--
Reply all
Reply to author
Forward
0 new messages