Solving several problem at once using command line

47 views
Skip to first unread message

Rasheed

unread,
Feb 17, 2024, 6:37:32 AMFeb 17
to MiniZinc
Hi everyone
I tried to solve several problems (or instances) using this batch :

set $dir="C:\Program Files\MiniZinc\"
pushd %$dir%
@echo off
for /l %%i in (50, 50, 100) do (
    for /l %%j in (7,3, 10) do (
for /l %%w in (1,1,10) do (
set filename=N10D%%iA%%jK%%w.dzn
set filename2=R_N10D%%iA%%jK%%w.txt
minizinc --solver Chuffed "CPMODEL.mzn" "C:\Users\Sony\Data1\%filename%"  -t 10000000 --output-time -o "C:\Users\Sony\Results\%filename2%"
)
    )
)
popd
pause


Unfortunatly I'm getting the following errors :

C:\Users\Sony>set $dir="C:\Program Files\MiniZinc\"

C:\Users\Sony>pushd "C:\Program Files\MiniZinc\"
minizinc: Unrecognized option or bad format `C:\Users\Sony\Data1"  -t 10000000 --output-time -o C:\Users\Sony\Results"'
minizinc: MiniZinc driver.
Usage: minizinc  [<options>] [-I <include path>] <model>.mzn [<data>.dzn ...] or just <flat>.fzn
More info with "minizinc --help"
minizinc: Unrecognized option or bad format `C:\Users\Sony\Data1"  -t 10000000 --output-time -o C:\Users\Sony\Results"'
minizinc: MiniZinc driver.
Usage: minizinc  [<options>] [-I <include path>] <model>.mzn [<data>.dzn ...] or just <flat>.fzn
More info with "minizinc --help"
Appuyez sur une touche pour continuer...


Thanks for your help !
Rasheed


Cyderize

unread,
Feb 18, 2024, 6:11:28 PMFeb 18
to MiniZinc
This is because in batch files the expansion of the %filename% variables happens immediately (because the for loop with its contents is one command - the variables get expanded before starting the loop).

You can try something like:

set $dir="C:\Program Files\MiniZinc\"
pushd %$dir%
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

for /l %%i in (50, 50, 100) do (
    for /l %%j in (7,3, 10) do (
for /l %%w in (1,1,10) do (
set filename=N10D%%iA%%jK%%w.dzn
set filename2=R_N10D%%iA%%jK%%w.txt
minizinc --solver Chuffed "CPMODEL.mzn" "C:\Users\Sony\Data1\!filename!"  -t 10000000 --output-time -o "C:\Users\Sony\Results\!filename2!"

)
    )
)
popd
pause


Thank you,
Jason

Rasheed

unread,
Feb 19, 2024, 1:54:14 PMFeb 19
to MiniZinc
Great ! Thanks a lot Jason for your help !
I had to put the entire path of the "CPMODEL.mzn" file in ordrer to avoid another error.
Thanks to Jip also for your suggestion.
Rasheed
Reply all
Reply to author
Forward
0 new messages