如何在 CPlex opl 中编码非线性约束?

问题描述 投票:0回答:1

这是我的 CPLEX 代码的一部分。我想对下面的约束进行编码,但它似乎是非线性约束,并且无法在 CPlex opl 中运行。谁能帮我处理一下吗? Here is the constraint

...



int Z_val = ...;
int T_val = 10;
int I_val = ...;
int J_val = ...;
float alpha = ...; // The average loading rate of delivery trucks;
range Z = 1 .. Z_val;// Number of vessels
range T = 1 .. T_val; // Number of time intervals
range I = 1 .. I_val; // Number of gate lanes
range J = 1 .. J_val; // Number of yard blocks

float beta_zj[Z][J] = ...;

// Define sets
{int} Z_j[J];

// Objective function or constraints go here

execute {
  // Iterate over j and z to update Z sets
  for (var j in J) {
    for (var z in Z) {
      if (beta_zj[z][j] > 0) {
        Z_j[j].add(z); // Add z to the set Z_j[j]
      }
    }
  }

  // Print the result (optional)
  for (var j in J) {
    writeln("Z_j[", j, "] = ", Z_j[j]);
  }
}

// Derived variables
dvar int+ lambda_zt_g[Z][T];// Number of trucks related to vessel z arriving at terminal gate at interval t
dvar int+ lambda_it_g[I][T];// Number of trucks arriving at gate lane i at interval t
dvar int+ lambda_t_y[T];// Number of export containers arriving at yard at interval t
dvar int+ lambda_jt_y[J][T];// Number of export containers arriving at block j at interval t
…..
….
subject to 
{

    forall ( j in J, t in T ){//(15)
    
    lambda_jt_y[j][t] == lambda_t_y[t] * alpha * sum ( z in Z_j[j] )
       (beta_zj[z][j] * lambda_zt_g[z][t] / sum ( i in I ) lambda_it_g[i][t]);
 }   
  

编写非线性约束代码

linear-programming cplex nonlinear-optimization check-constraints opl
1个回答
0
投票

由于所有决策变量都是整数,因此您可以在 CPLEX 中使用约束规划。

以下模型有效:

using CP;

int Z_val = 10;
int T_val = 10;
int I_val = 10;
int J_val = 2;
float alpha = 0.5; // The average loading rate of delivery trucks;
range Z = 1 .. Z_val;// Number of vessels
range T = 1 .. T_val; // Number of time intervals
range I = 1 .. I_val; // Number of gate lanes
range J = 1 .. J_val; // Number of yard blocks

float beta_zj[i in Z][j in J] = i*j;

// Define sets
{int} Z_j[J];

// Objective function or constraints go here

execute {
  // Iterate over j and z to update Z sets
  for (var j in J) {
    for (var z in Z) {
      if (beta_zj[z][j] > 0) {
        Z_j[j].add(z); // Add z to the set Z_j[j]
      }
    }
  }

  // Print the result (optional)
  for (var j in J) {
    writeln("Z_j[", j, "] = ", Z_j[j]);
  }
}

// Derived variables
dvar int+ lambda_zt_g[Z][T];// Number of trucks related to vessel z arriving at terminal gate at interval t
dvar int+ lambda_it_g[I][T];// Number of trucks arriving at gate lane i at interval t
dvar int+ lambda_t_y[T];// Number of export containers arriving at yard at interval t
dvar int+ lambda_jt_y[J][T];// Number of export containers arriving at block j at interval t
subject to 
{

    forall ( j in J, t in T ){//(15)
    
    lambda_jt_y[j][t] == lambda_t_y[t] * alpha * sum ( z in Z_j[j] )
       (beta_zj[z][j] * lambda_zt_g[z][t]/ sum ( i in I ) lambda_it_g[i][t]);
     }
   }            
 
© www.soinside.com 2019 - 2024. All rights reserved.