Here is the dat file
depot={"D1", "D2"};
customer={"C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12" };
node={"C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9", "C10", "C11", "C12", "D1", "D2" };
vehicle={"V1", "V2"};
dist=[[0.0 5.1 10.2 17.1 26.2 4.1 11.7 8.5 14.6 23.4 29.4 29.1 15.0 21.2],
[5.1 0.0 5.1 12.4 21.4 6.4 8.6 9.2 15.0 20.6 26.2 26.9 13.6 17.0],
[10.2 5.1 0.0 8.1 16.8 10.8 8.0 12.2 17.1 18.8 23.6 25.6 14.0 13.5],
[17.1 12.4 8.1 0.0 9.1 16.1 8.1 15.2 17.7 13.0 16.6 20.1 12.8 5.8],
[26.2 21.4 16.8 9.1 0.0 25.0 16.3 23.5 24.6 14.4 14.1 20.2 19.2 7.2],
[4.1 6.4 10.8 16.1 25.0 0.0 9.2 4.5 10.4 20.2 26.4 25.5 11.3 19.2],
[11.7 8.6 8.0 8.1 16.3 9.2 0.0 7.3 10.0 12.0 17.8 18.4 6.1 10.0],
[8.5 9.2 12.2 15.2 23.5 4.5 7.3 0.0 6.1 16.6 22.8 21.3 7.2 17.0],
[14.6 15.0 17.1 17.7 24.6 10.4 10.0 6.1 0.0 14.0 20.2 17.0 5.4 17.5],
[23.4 20.6 18.8 13.0 14.4 20.2 12.0 16.6 14.0 0.0 6.3 7.1 9.5 8.2],
[29.4 26.2 23.6 16.6 14.1 26.4 17.8 22.8 20.2 6.3 0.0 7.1 15.8 10.8],
[29.1 26.9 25.6 20.1 20.2 25.5 18.4 21.3 17.0 7.1 7.1 0.0 14.1 15.0],
[15.0 13.6 14.0 12.8 19.2 11.3 6.1 7.2 5.4 9.5 15.8 14.1 0.0 0.0],
[21.2 17.0 13.5 5.8 7.2 19.2 10.0 17.0 17.5 8.2 10.8 15.0 0.0 0.0]];
fcost = [100, 100];
D= [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20];
R= [3, 3, 4, 3, 2, 4, 4, 4, 3, 4, 3, 4];
VC=[140, 140];
VD=[280, 280];
pr=350;
"Think Green. Keep it on the screen.
If printing is necessary, please print it on both sides."
The information contained in this e-mail message and any accompanying files is or may be confidential. If you are not the intended recipient, any use, dissemination, reliance, forwarding, printing or copying of this e-mail or any attached files is unauthorized. This e-mail is subject to copyright. No part of it should be reproduced, adapted or communicated without the written consent of the copyright owner. If you have received this e-mail in error please advise the sender immediately by return e-mail or telephone and delete all copies. UMP does not guarantee the accuracy or completeness of any information contained in this e-mail or attached files. Internet communications are not secure, therefore UMP does not accept legal responsibility for the contents of this message or attached files.
Original Message:
Sent: 11/19/2020 11:45:00 AM
From: ALEX FLEISCHER
Subject: RE: Linearization in objective function
Hi
and can you share the dat file too ?
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Thu November 19, 2020 09:35 AM
From: Farahanim Misni
Subject: Linearization in objective function
Here is my coding in CPLEX. My nonlinear objective is actually on the setup cost where the Q[i] is the decision variable. But this decision variable also appears in a holdinginventory cost.
using CP;
execute
{
cp.param.timeLimit=6400;
}
{string} depot=...;
{string} customer=...;
{string} vehicle=...;
{string} node=...;
int M=12;
int pr=...;
int scale=10;
float dist[node][node]=...;
float fcost[depot]=...;
float D[customer]=...;
float R[customer]=...;
float VC[vehicle]=...;
float VD[depot]=...;
dvar boolean x[node][node][vehicle];
dvar boolean z[depot];
dvar boolean y[depot][customer];
dvar int u[customer][vehicle];
dvar int scaleQ[i in depot] in 0..2400;
dexpr float Q[i in depot]=scaleQ[i]/scale;
dexpr float travel=sum(i in node, j in node, k in vehicle: i!=j)x[i][j][k]*dist[i][j];
dexpr float facility=sum(i in depot)fcost[i]*z[i];
dexpr float setup=17*sum(i in depot, j in customer)(D[j]-R[j])*y[i][j]/Q[i];
dexpr float holdinginventory=(1/pr)*sum(i in depot)(Q[i]*pr - Q[i]*sum(j in customer)(D[j]+R[j])*y[i][j]);
dexpr float cost=travel + facility + setup + holdinginventory;
minimize cost;
subject to {
forall(j in customer) sum(i in node, k in vehicle)x[i][j][k]==1;
forall(k in vehicle) sum(i in depot, j in customer)x[i][j][k]<=1;
forall(k in vehicle) sum(i in node, j in customer)D[j]*x[i][j][k]<=VC[k];
forall(i in node, k in vehicle) (sum(j in node)x[i][j][k])- (sum(j in node)x[j][i][k])==0;
forall(i in depot) sum(j in customer)D[j]*y[i][j]<=VD[i]*z[i];
forall(j in customer) sum(i in depot)y[i][j]==1;
forall(l in customer, j in customer, k in vehicle) u[l][k]-u[j][k]+M*x[l][j][k]<= M-1;
forall(i in depot, j in customer, k in vehicle) sum(h in node)(x[i][h][k]+x[h][j][k])-y[i][j]<=1;
}
"Think Green. Keep it on the screen.
If printing is necessary, please print it on both sides."
The information contained in this e-mail message and any accompanying files is or may be confidential. If you are not the intended recipient, any use, dissemination, reliance, forwarding, printing or copying of this e-mail or any attached files is unauthorized. This e-mail is subject to copyright. No part of it should be reproduced, adapted or communicated without the written consent of the copyright owner. If you have received this e-mail in error please advise the sender immediately by return e-mail or telephone and delete all copies. UMP does not guarantee the accuracy or completeness of any information contained in this e-mail or attached files. Internet communications are not secure, therefore UMP does not accept legal responsibility for the contents of this message or attached files.
Original Message:
Sent: 11/19/2020 9:14:00 AM
From: ALEX FLEISCHER
Subject: RE: Linearization in objective function
Hi,
yes using a time limit is right.
Do you want to share your model here so that other users could give you some advice ?
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Thu November 19, 2020 09:07 AM
From: Farahanim Misni
Subject: Linearization in objective function
I did not get an optimal solution means my solution is not optimal. and because the computation time is also too long even for the small data size, I need to use cp.limit time to stop the iteration. Did I do the right thing?
"Think Green. Keep it on the screen.
If printing is necessary, please print it on both sides."
The information contained in this e-mail message and any accompanying files is or may be confidential. If you are not the intended recipient, any use, dissemination, reliance, forwarding, printing or copying of this e-mail or any attached files is unauthorized. This e-mail is subject to copyright. No part of it should be reproduced, adapted or communicated without the written consent of the copyright owner. If you have received this e-mail in error please advise the sender immediately by return e-mail or telephone and delete all copies. UMP does not guarantee the accuracy or completeness of any information contained in this e-mail or attached files. Internet communications are not secure, therefore UMP does not accept legal responsibility for the contents of this message or attached files.
Original Message:
Sent: 11/19/2020 9:03:00 AM
From: ALEX FLEISCHER
Subject: RE: Linearization in objective function
Hi,
do you mean you do not get any solution ?
Or your solution is not optimal ?
regards
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Thu November 19, 2020 08:53 AM
From: Farahanim Misni
Subject: Linearization in objective function
Sorry for asking this, if I am using CP for my nonlinear function in my CPLEX, I did not get an optimal solution in my problem. Is it possible to get that solutions?
------------------------------
Farahanim Misni
Original Message:
Sent: Sun November 08, 2020 02:13 PM
From: ALEX FLEISCHER
Subject: Linearization in objective function
Hi
could
https://community.ibm.com/community/user/datascience/communities/community-home/digestviewer/viewthread?GroupId=5557&MessageKey=73708de6-81f4-4f75-b789-2f97d93c0892&CommunityKey=ab7de0fd-6f43-47a9-8261-33578a231bb7&tab=digestviewer&ReturnUrl=%2fcommunity%2fuser%2fdatascience%2fcommunities%2fcommunity-home%2fdigestviewer%3fcommunitykey%3dab7de0fd-6f43-47a9-8261-33578a231bb7%26tab%3ddigestviewer
help ?
------------------------------
[Alex] [Fleischer]
[EMEA CPLEX Optimization Technical Sales]
[IBM]
Original Message:
Sent: Sun November 08, 2020 09:39 AM
From: Farahanim Misni
Subject: Linearization in objective function
Hi,
I want to ask about linearization in my objective function since my objective is nonlinear function. Is there any example how to linearize the fraction function (example 1/x) in cplex since the cplex can't solve the nonlinear function.
Thank you. Regards.
------------------------------
Farahanim Misni
------------------------------
#DecisionOptimization