中止:无法为“float_times(X_INTRODUCED_44_, X_INTRODUCED_45_, X_INTRODUCED_46_)”约束创建线性公式

Abort: Unable to create linear formulation for the `float_times(X_INTRODUCED_44_, X_INTRODUCED_45_, X_INTRODUCED_46_)` constraint

我正在使用带有 Coin-bc 求解器的 Minzinc 编写 MIP 问题。但是,它会像标题一样引发错误。这是由于 eta_cpu & cpu_used 都是变量,当我从 Objective 函数income,它变成了工作。系统指出set QuadrFloat=ture,但是我做了之后,又出现了这样的问题:Backend: [int/float]_times not supported.

MiniZinc 版本为 2.5.5

代码在这里:

include "Untitled1.dzn";
% include "redefinitions.mzn";

QuadrFloat = true;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ENVIRONMENT

int: numHosts;
set of int: hosts = 1..numHosts;

array[hosts] of int: cpu_resource;
array[hosts] of int: memory_resource;
array[hosts] of int: storage_resource;
array[hosts] of int: bandwidth_resource;

int: numVnfs;
set of int: vnf = 1..numVnfs;
array[vnf] of int: vnf_properties_bw;
array[vnf] of int: vnf_properties_cpu;
array[vnf] of int: vnf_properties_mem;
array[vnf] of int: vnf_properties_sto;

int: sliceLen;
set of int: sSlice = 1..sliceLen;
array[sSlice] of int: slice;


float: C;
float: G_c;
float: G_m;
float: G_s;

float: W_min;
float: W_max;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DECISION VARIABLES AND CONSTRAINTS
var float: income;
array[sSlice] of var hosts: placement;
array[hosts] of var int: cpu_used;
array[hosts] of var int: memory_used;
array[hosts] of var int: storage_used;
array[hosts] of var int: bandwidth_used;
array[hosts] of var 0..1: u;

array[hosts] of var float: eta_cpu;
array[hosts] of var float: eta_mem;
array[hosts] of var float: eta_sto;
array[hosts] of var float: eta_bw;


% RESOUECES UTILIZATION
constraint forall(host in hosts)
(
    cpu_used[host] = sum(s in sSlice where placement[s] = host) (vnf_properties_cpu[slice[s]])
);

constraint forall(host in hosts)
(
    memory_used[host] = sum(s in sSlice where placement[s] = host) (vnf_properties_mem[slice[s]])
);

constraint forall(host in hosts)
(
    storage_used[host] = sum(s in sSlice where placement[s] = host) (vnf_properties_sto[slice[s]])
);

constraint forall(host in hosts)
(
    bandwidth_used[host] = sum(s in sSlice where placement[s] = host) (vnf_properties_bw[slice[s]])
);

% RESOURCE CONSTRAINTS
constraint forall(host in hosts)
(
    cpu_used[host] <= cpu_resource[host]
);

constraint forall(host in hosts)
(
    memory_used[host] <= memory_resource[host]
);

constraint forall(host in hosts)
(
    storage_used[host] <= storage_resource[host]
);

constraint forall(host in hosts)
(
    bandwidth_used[host] <= bandwidth_resource[host]
);

% RESOUECES UTILIZATION RATE
constraint forall(host in hosts)
(
  (
    eta_cpu[host] = 
    if cpu_used[host] > 0
      then cpu_used[host] / cpu_resource[host]
    else
        0
    endif
  )
);

constraint forall(host in hosts)
(
  (
    eta_mem[host] = 
    if memory_used[host] > 0
      then memory_used[host] / memory_resource[host]
    else
        0
    endif
  )
);

constraint forall(host in hosts)
(
  (
    eta_sto[host] = 
    if storage_used[host] > 0
      then storage_used[host] / storage_resource[host]
    else
        0
    endif
  )
);

constraint forall(host in hosts)
(
  (
    eta_bw[host] = 
    if bandwidth_used[host] > 0
      then bandwidth_used[host] / bandwidth_resource[host]
    else
        0
    endif
  )
);

% HOST STATE
constraint forall(host in hosts)
(
    (
       u[host] = 
       if cpu_used[host] > 0 
         then 1
       else 0
       endif
    )
);
          
% OBJECTIVE FUNCTION
income = sum(host in hosts) ((G_c * (1.0 - eta_cpu[host]) * cpu_used[host] + G_m * memory_used[host] + G_s * storage_used[host]) - (W_max - W_min) * eta_cpu[host] + u[host] * W_min) * C;

% income = sum(host in hosts) ((G_c  * cpu_used[host] + G_m * memory_used[host] + G_s * storage_used[host]) - (W_max - W_min) * eta_cpu[host] + u[host] * W_min) * C;

% income = sum(host in hosts) ((G_c * (1 - eta_cpu[host]) + G_m * memory_used[host] + G_s * storage_used[host]) - (W_max - W_min) * eta_cpu[host] + u[host] * W_min) * C;

% income = sum(host in hosts) ((G_c * (1 - eta_cpu[host]) * 10.0 + G_m * 10.0 + G_s * 10.0) - (W_max - W_min) * eta_cpu[host] + u[host] * W_min) * C;                                                                                                        

% solve satisfy;
solve maximize income;

output ["\nplacement: ", show(placement),
        "\ncpu_used: ", show(cpu_used),
        "\nmemory_used: ", show(memory_used),
        "\nstorage_used: ", show(storage_used),
        "\nbandwidth_used: ", show(bandwidth_used),
        "\neta_cpu: ", show(eta_cpu),
        "\neta_mem: ", show(eta_mem),
        "\neta_sto: ", show(eta_sto),
        "\neta_bw: ", show(eta_bw),
        "\nu: ", show(u),
        "\nincome: ",  show_float(0, 5, income),
%         "\n111: ", show_float(0, 5, int2float(2, cpu_used[1]))
       ];

我应该怎么做才能解决这个问题。帮我。请。 ORZ.

这里的问题与求解器的类型有关。 Coin-or Branch-and-Cut (CBC) 是一种混合整数规划求解器。这些类型的求解器的局限性之一是它的问题只能包含线性(不)等式。所以你可以将决策变量乘以常数,你可以将这些项加在一起,但你不能将两个变量相乘。这超出了解决机制的范围。

整数乘法,有解法。您可以使用分解,将整数拆分为许多 0..1 个整数变量,每个变量代表原始整数是否采用特定值。然后可以使用这些变量来推断多个单独约束中的乘法值。这特别有效,但允许我们使用整数乘法(至少在某些时候)。

浮点乘法是另一种野兽。它需要求解器的明确支持。使用这些约束的问题称为二次问题,您经常会看到 MIP 求解器会指定它们是否可以解决二次问题。在 MiniZinc 求解器中,CBC 不支持二次约束,但我相信其他 MIP 求解器(SCIP、Gurobi 和 CPLEX)支持。