如何将AMPL转换为CPLEX [英] How do I convert AMPL to CPLEX

查看:121
本文介绍了如何将AMPL转换为CPLEX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下设置和参数是在AMPL环境中编写的.如何将它们转换为CPLEX?

The following set and parameters are written in the AMPL environment. How can they be converted to CPLEX?

set B;      #set of all blocks
set T;      #set of time periods
set BI{B};  #set of blocks that overlie a block
set BY{T};  #set of blocks that can be excavated in time period t
param C_min;        #minimum processing capacity of a mill
param g{B};     #average grade for block
param x_cord{B};    #x-coordinate of a block
param r{B} symbolic;
param early{B} default 1;
var alpha{B,T} binary;  # indicator for which sequencing constraint 6 won't be met

此外,以下约束是在AMPL环境中编写的.如何将它们转换为CPLEX?(特别是条件部分)

Also, the following Constraints are written in the AMPL environment. How can they be converted to CPLEX?(Especially the conditional part)

subject to processing{t in T}:  C_min <= sum{b in B: early[b] <= t}(if g[b] > total[b]  
then total[b] else 0)*y[b,t];

subject to sequencing{b in B, vb in B, t in T: early [b] <= t  and (x_cord[b]=x_cord[vb]) 
and 
(y_cord[b]=y_cord[vb]) and (z_cord[b] = z_cord[vb]-1)}: y[b,t] <= sum{u in 
early[vb]..t}y[vb,u];

subject to logic:sum{b in B, t in T} alpha[b,t] <= card(T)*card(B)-1;

在Cplex中:

forall (t in T) {
processing:
C_min<=sum(b in B: early[b] <= t) 
[(g[b] > total[b])=> (total[b])(g[b] <= total[b])=>(0)]*y[b][t];
}

forall (b in B)
  forall (vb in B)
        forall (t in T:early [b] <= t  &&  
        (x_cord[b]==x_cord[vb]) && (y_cord[b]==y_cord[vb]) && (z_cord[b] == z_cord[vb]-1)){
        sequencing:                             
            y[b][t]<=sum(u in early[vb]..t) y[vb][u];
}   

logic:                          
        sum(b in B)sum(t in T) alpha[b][t]<= ??;

推荐答案

让我在语法方面提供帮助

let me help with the syntax

range B=1..4;
range T=1..3;
{int} BT[t in T]=asSet(1..t);
int early[b in B]=b;

int C_min=0;

dvar boolean y[B][T];
dvar boolean alpha[B][T];
dvar int g[B];
int total[B];
int x_cord[B];
int y_cord[B];
int z_cord[B];

subject to
{
  
  forall (t in T) {
processing:
C_min<=sum(b in B: early[b] <= t) 
((g[b] >= total[b])=> (total[b]*g[b] <= total[b]*y[b][t]));
}

forall (b in B)
  forall (vb in B)
        forall (t in T:early [b] <= t  &&  
        (x_cord[b]==x_cord[vb]) && (y_cord[b]==y_cord[vb]) && (z_cord[b] == z_cord[vb]-1)){
        sequencing:                             
            y[b][t]<=sum(u in early[vb]..t) y[vb][u];
}   

logic:                          
        sum(b in B)sum(t in T) alpha[b][t]<= card(asSet(T))*card(asSet(B))-1;;


 
} 

工作正常

这篇关于如何将AMPL转换为CPLEX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆