简体   繁体   English

CPLEX Optimization Studio-没有可行的解决方案-二次约束

[英]CPLEX Optimization Studio - No feasible solution - Quadratic Constraints

I try to implement a Vehicle Routing Problem with two vehicles. 我尝试用两辆车实施一个车辆路线问题。

One vehicle is a carrier, the other one is a drone which can start from the carrier. 一种车辆是运载工具,另一种是可以从运载工具开始的无人机。

Both vehicles start at the point (0/0). 两辆车都从(0/0)点开始。 Then both vehicles move to a point where the drone should start from the carrier an visit some target locations consecutively. 然后,两辆车都移动到无人机应从航母出发的位置,并连续拜访一些目标位置。 In the beginning I only assume two targets located at t1(2/8) and t2(5/8). 一开始我只假设两个目标分别位于t1(2/8)和t2(5/8)。 After visiting the targets the drone should land on the carrier and both vehicles shoul go back to the starting point (0/0). 到达目标后,无人机应降落在航母上,两辆车都应返回起点(0/0)。

So the points where the drone launches and lands on the carrier are to choose optimally to minimze the tour of the carrier. 因此,要选择最佳的无人机发射点和降落点,以最大程度地减少对航母的旅行。

I have a visualization of the problem here: visualization 我在这里看到问题的可视化: 可视化

在此处输入图片说明

My Code looks like this: 我的代码如下所示:

//Data

int start[1..2]=[0,0]; //start

int R=10; //max drone flight time
int a=2;  //speed of drone

int z1A1[1..2]=[2,8]; //target1
int z2A1[1..2]=[7,8]; //target2

float intraDist1=sqrt(((z2A1[1]-z1A1[1])^2)+(z2A1[2]-z1A1[2])^2); //distance between targets
float intraFlugDist1;

float wegFlugDist1;
float hinFlugDist1; 

float kombiniertZeit0;
float kombiniertZeit1;
float getrenntZeit1;

//Dvar

dvar int+ sA1[1..2];
dvar int+ lA1[1..2];

//Model

minimize kombiniertZeit0+getrenntZeit1+kombiniertZeit1;

subject to{

E1:
kombiniertZeit0>=0;
(((sA1[1]-start[1])^2)+(sA1[2]-start[2])^2)<=kombiniertZeit0^2;

E2:
getrenntZeit1>=0;
(((lA1[1]-sA1[1])^2)+(lA1[2]-sA1[2])^2)<=getrenntZeit1^2;

E3:
kombiniertZeit1>=0;
(((start[1]-lA1[1])^2)+(start[2]-lA1[2])^2)<=kombiniertZeit1^2;

E4:
wegFlugDist1>=0;
(((z1A1[1]-sA1[1])^2)+(z1A1[2]-sA1[2])^2)<=wegFlugDist1^2;

E5:
hinFlugDist1>=0;
(((lA1[1]-z2A1[1])^2)+(lA1[2]-z2A1[2])^2)<=hinFlugDist1^2;

E6:
intraDist1<=intraFlugDist1;

E7:
(wegFlugDist1+intraFlugDist1+hinFlugDist1)/a<=getrenntZeit1;

E8:
R>=getrenntZeit1;

}

E1 ensures that kombiniertZeit0 is at least as large as the distance from the start to the launch point of the drone. E1确保kombiniertZeit0至少与无人机的起点到发射点的距离一样大。

E2 ensures that getrenntZeit1 is at least as large as the distance from the launch point to the land point of the drone. E2确保getrenntZeit1至少与无人机的发射点到着陆点的距离一样大。

E3 ensures that kombiniertZeit1 is at least as large as the distance from the land point of the drone to the start. E3确保kombiniertZeit1至少与从无人机着陆点到起点的距离一样大。

E4 ensures that wegFlugDist1 is at least as large as the distance from the launch point of the drone to the first target. E4确保wegFlugDist1至少与无人机发射点到第一个目标的距离一样大。

E5 ensures that hinFlugDist1 is at least as large as the distance from the last target to the land point of drone. E5确保hinFlugDist1至少与从最后一个目标到无人机着陆点的距离一样大。

E7 ensures that getrenntZeit1 is at least as large as the sum of hinFlugDist1, intraFlugDist1 and wegFlugDist1 divided by the speed of the drone a. E7确保getrenntZeit1至少等于hinFlugDist1,intraFlugDist1和wegFlugDist1之和除以无人机速度a。

E8 ensures that getrenntZeit1 is not larger than the max flight time of the drone R. E8确保getrenntZeit1不大于无人机R的最大飞行时间。

When I debug the programm I get no feasible solution and I can`t figure out why. 当我调试程序时,没有可行的解决方案,我也弄不清原因。

I am very thankful for every hint! 我非常感谢每一个提示! Thanks in Advance! 提前致谢!

Sven 斯文

I ported your problem to MiniZinc and added some domain limits for distances and times: 我将您的问题移植到MiniZinc,并为距离和时间添加了一些域限制:

array[1..2] of int: start = [0,0]; % start location

int: R=10; % max drone flight time
int: vDrone=2;    % speed of drone
int: vCarrier=1;  %  speed of carrier
float: minDist = 0.0;
float: maxDist = 100.0;
float: minTime = 0.0;
float: maxTime = 20.0;

array[1..2] of int: z1A1=[2,8]; %  target1
array[1..2] of int: z2A1=[7,8]; %  target2

function var float: sqr(float: x) = x * x;
function var float: sqr(var float: x) = x * x;
function var int:   sqr(var int: x) = x * x;

float: intraDist1=sqrt((z2A1[1]-z1A1[1])*(z2A1[1]-z1A1[1]) + 
                       (z2A1[2]-z1A1[2])*(z2A1[2]-z1A1[2])); % distance between targets
var minDist .. maxDist: intraFlugDist1;

var minDist .. maxDist: wegFlugDist1;
var minDist .. maxDist: hinFlugDist1; 

var minTime .. maxTime: kombiniertZeit0;
var minTime .. maxTime: kombiniertZeit1;
var minTime .. maxTime: getrenntZeit1;

array[1..2] of var 0..100: sA1;
array[1..2] of var 0..100: sA2;


solve minimize kombiniertZeit0 + getrenntZeit1 + kombiniertZeit1;

% E1:
constraint ((sqr(sA1[1]-start[1])+sqr(sA1[2]-start[2])) <= sqr(kombiniertZeit0)*vCarrier);

% E2:
constraint ((sqr(sA1[1]-sA2[1]) + sqr(sA1[2]-sA2[2])) <= sqr(getrenntZeit1)*vCarrier);

% E3:
constraint ((sqr(start[1]-sA2[1]) + sqr(start[2]-sA2[2])) <= sqr(kombiniertZeit1)*vCarrier);

% E4:
constraint ((sqr(z1A1[1]-sA1[1]) + sqr(z1A1[2]-sA1[2])) <= sqr(wegFlugDist1)*vDrone);

% E5:
constraint ((sqr(sA2[1]-z2A1[1]) + sqr(sA2[2]-z2A1[2])) <= sqr(hinFlugDist1)*vDrone);

% E6:
constraint (intraDist1 <= intraFlugDist1);

% E7:
constraint ((wegFlugDist1 + intraFlugDist1 + hinFlugDist1) <= getrenntZeit1*vDrone);

% E8:
constraint (R >= getrenntZeit1);

This leads to the following: 这导致以下结果:

intraFlugDist1 = 5.0;
wegFlugDist1 = 5.8309518948453;
hinFlugDist1 = 7.51664818918645;
kombiniertZeit0 = 0.0;
kombiniertZeit1 = 0.0;
getrenntZeit1 = 9.173800042015881;
sA1 = array1d(1..2, [0, 0]);
sA2 = array1d(1..2, [0, 0]);

This means that the carrier stays in the start position and the drone travels all alone. 这意味着运载工具停留在起始位置,而无人机则独自行进。 The constraints have to be modified to enforce a less trivial behaviour. 必须修改约束以强制执行一些琐碎的行为。 R = 6 is an easy way to prevent the drone from a solo. R = 6是防止无人机独奏的简便方法。

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

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