简体   繁体   English

如何在CPLEX上向模型添加多维IloRangeArray

[英]How to add multi dimensional IloRangeArray to the model on CPLEX

I'm a beginner in CPLEx and using it to wite my mathematical model. 我是CPLEx的初学者,并使用它来建立我的数学模型。 I defined and built a three dimensional IloRangeArray as my constraint as follows: 我定义并构建了一个三维IloRangeArray作为约束,如下所示:

typedef IloArray<IloArray<IloRangeArray>> ThreeDimRange;
con = IloArray <IloArray <IloRangeArray> > (env, n);
for () 
{
    con [h] = IloArray <IloRangeArray> (env, nbRow);
    for ()
    {
        con[h][m] = IloRangeArray (env);
        for () 
        {
            IloExpr tempExp(env); 
            if ()
                 con [h][m].add(0 <= tempExp <= 0);
        }
    }
}

When I want to add "con" to the model (model.add(con);), I have the following error: 当我想在模型中添加“ con”(model.add(con);)时,出现以下错误:

error C2664: 'IloExtractable IloModel::add(const IloExtractable) const' : cannot convert parameter 1 from 'ThreeDimRange' to 'const IloExtractable' 错误C2664:'IloExtractable IloModel :: add(const IloExtractable)const':无法将参数1从'ThreeDimRange'转换为'const IloExtractable'

It is the same for 2 dim IloArrangeArray. 2个昏暗的IloArrangeArray相同。 What is your opinion? 你有什么意见?

Thanks 谢谢

Solved! 解决了! It seems that though we have a multi-dimensional vector of IloRangeArray , we have to add each IloRangeArray seperately to the model. 看起来,尽管我们有IloRangeArray的多维矢量,但我们必须将每个IloRangeArray分别添加到模型中。

typedef IloArray<IloArray<IloRangeArray>> ThreeDimRange;
con = IloArray <IloArray <IloRangeArray> > (env, n);
for () 
{
    con [h] = IloArray <IloRangeArray> (env, nbRow);
    for ()
    {
        con[h][m] = IloRangeArray (env);
        for () 
        {
            IloExpr tempExp(env); 
            if ()
                 con [h][m].add(0 <= tempExp <= 0);
        }
        **model.add(con[h][m]);**
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM