在OPL中将元组转换为4D数组的问题

发布于 2025-02-11 05:05:44 字数 992 浏览 4 评论 0 原文

我正在与IBM ILOG Studio/OPL合作。

我想将一个元组转换为我正在将Excel数据文件读取到(4D)数组中的元组。 以前提出了类似的问题,但是给定的答案在5月的情况下不起作用,我找不到原因。这里的链接。

excel Works的元组读取(我检查了“启动”是否正确读取)。 mod中的元组。文件定义为:

tuple mipstart { 
int  i;
int q;
int d;
int k;
int value; }


{mipstart} start =...;

int valuemip[I][Q][D][K]; 

execute
{
for(var x in start) valuemip[x.i][x.q][x.d][x.k]=x.value;
}

我收到的错误消息是“值valuemip#0超出有效范围(0)”。索引(i,q,d,k)都被宣布为从1开始的范围。 换句话说,我正在尝试从元组开始构建4D阵列“ valuemip”。

(有关更多信息:在.dat文件“测试”中是命名的数据空间 - > Works)

start from SheetRead (sheet, "test");

我是新手与元组一起工作的新手,并且以前主要使用了IBM ILOG Studio的“基本学生”使用(编写模型(编写一个模型)(主要带有MOD文件中的数组),并在数据读取frome excel中具有相应的dat文件)。

欢迎任何帮助。

I am working with the IBM Ilog Studio/OPL.

I want to transform a tuple, that I am reading out of an excel data file into an (4D)array.
A similar question has been raised before, but the given answer does not work in may case and I cannot find the reason. Here the link.

How to represent and read 4D array in Opl Cplex from Excel

The reading of the tuple from excel works (I have checked that the "start" is read correctly).
The Tuple in the mod. file is defined as:

tuple mipstart { 
int  i;
int q;
int d;
int k;
int value; }


{mipstart} start =...;

int valuemip[I][Q][D][K]; 

execute
{
for(var x in start) valuemip[x.i][x.q][x.d][x.k]=x.value;
}

The error message I get is that "the value valuemip#0 is outside of the valid range (0)." The indexes (I,Q,D,K) are all declared to be ranges starting with 1....
In other words I am trying to build the 4D array "valuemip" from the tuple start.

(For further information: In .dat file "test" is the named data space --> works)

start from SheetRead (sheet, "test");

I am new at working with tuples and have previously mainly used the "basic student" use of IBM Ilog Studio (writing a model (mainly with arrays) in a mod file and having a corresponding dat file with data read frome Excel).

Any help is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

喵星人汪星人 2025-02-18 05:05:44

如果元组成员为零,并且最终用作ValueMip指数,则问题可能来自您的数据。

The problem may come from your data if tuple members are zero and end up used as valuemip indices.

旧故 2025-02-18 05:05:44

我会从元组套装中重新计算您的范围:

tuple mipstart { 
int  i;
int q;
int d;
int k;
int value; }


{mipstart} start ={<1,2,3,4,100>};

{int} I={e.i | e in start};
{int} Q={e.q | e in start};
{int} D={e.d | e in start};
{int} K={e.k | e in start};

int valuemip[I][Q][D][K]; 

execute
{
for(var x in start) valuemip[x.i][x.q][x.d][x.k]=x.value;
}

工作正常

I would recompute yur ranges out of the tuple set:

tuple mipstart { 
int  i;
int q;
int d;
int k;
int value; }


{mipstart} start ={<1,2,3,4,100>};

{int} I={e.i | e in start};
{int} Q={e.q | e in start};
{int} D={e.d | e in start};
{int} K={e.k | e in start};

int valuemip[I][Q][D][K]; 

execute
{
for(var x in start) valuemip[x.i][x.q][x.d][x.k]=x.value;
}

works fine

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文