Error with array of var string

103 views
Skip to first unread message

Dhuha Al-Zobaie

unread,
Mar 12, 2023, 6:43:36 PM3/12/23
to MiniZinc
Hi All,
on this code line :
array[intof var string: path;
I have this error:MiniZinc: type error: invalid type of variable declaration: `array[int] of var string' 

is anyone have idea why this error  appear eventhough the code is correct?

and how fix it?

I used Minizinc IDE 2.7.0

Thank you in advance.

guido.tack

unread,
Mar 12, 2023, 6:49:32 PM3/12/23
to MiniZinc
Hi,

MiniZinc does not support string variables. There has been some work on adding string variables both to MiniZinc and to the backend solvers, see e.g.

However, this has not been a priority so far, and we don't have concrete plans to include those features in the near future.

If you need to model problems over string variables, you could introduce an enumerated type for the character set and then model the variable as

enum CHARSET = { alb,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z };
array[1..MAXLENGTH] of var opt CHARSET: path;
constraint forall (i in 1..MAXLENGTH-1) (path[i]=<> -> path[i+1]=<>);

You'd have to define predicates for things like concatenation etc.

Cheers,
Guido

Reply all
Reply to author
Forward
0 new messages