That sounds like that could be my solution! I already use post-processing and I see the feasible solutions in my scripting log.
I tried to create a dexpr, but I keep getting errors when defining them.
I also tried Daniel's option with auxvar, but as I am new to CPLEX I don't know how to define a auxvar and I cannot find it online.
How should I define them? Thank you for helping!
These are my sets, parameters and objective function:
int ns = ...;
range S = 0..ns;
int nv = ...;
range V = 1..nv;
int nr = ...;
range R = 1..nr;
int nt = ...;
range T = 1..nt;
int c[S][S] = ...;
int d[i in S][t in T] = ...;
int l1 = ...;
int l2 = ...;
float p1 = ...;
float p2 = ...;
int M = ...;
dvar boolean x[S][T][V][R];
dvar boolean y[S][S][V][R];
dvar boolean z[V][R];
dvar int+ u[S][V][R];
dvar int+ w[V][R];
maximize sum (i in S, t in T, v in V, r in R) (w[v][r] <= t + l1) * d[i][t] * x[i][t][v][r]
+ sum (i in S, t in T, v in V, r in R) ((w[v][r] >= t + l1 + 1) && (w[v][r] <= t + l2)) * d[i][t] * x[i][t][v][r] * p1
+ sum (i in S, t in T, v in V, r in R) (w[v][r] >= t + l2 + 1) * d[i][t] * x[i][t][v][r] * p2
- sum (i, j in S, v in V, r in R) c[i][j] * y[i][j][v][r];
------------------------------
Floor M
------------------------------
Original Message:
Sent: Wed June 17, 2020 09:20 AM
From: Frederic Delhoume
Subject: If function in scipting log
You may also want to create some dexpr (decision expressions) and use them in your objective function (or not).
You can then display them easily in scripting
execute {
writeln(somedexpr);
}
The CPO engine uses automatically dexprs as KPI and display them in its log. They are also displayed in the statistics panel.
------------------------------
Frederic Delhoume
Original Message:
Sent: Wed June 17, 2020 09:01 AM
From: Frederic Delhoume
Subject: If function in scipting log
You may look at OPL parameter Language / Run / Postprocess feasible solutions.
It allows post-processing (execute blocks after the constraints) to be called whenever CPLEX encounters a feasible solution.
You may display a dexpr (KPI) value in scripting, or whatever model element value you want.
------------------------------
Frederic Delhoume
Original Message:
Sent: Wed June 17, 2020 05:39 AM
From: Floor M
Subject: If function in scipting log
Hi Daniel,
I just want to calculate the amount of d[i][t] * c[i][[t][v][r] before, between and after certain time limits
The constraints are all set, but I want CPLEX to show me those results, because the optimal solution gives a summation of these three calculations and I want to see these results also separated from each other
I thought the best way to do that is to use execute DISPLAY.
------------------------------
Floor M
Original Message:
Sent: Wed June 17, 2020 05:28 AM
From: Daniel Junglas
Subject: If function in scipting log
I am not sure what you are trying to do with the scripting log. This is an output-only widget, so you cannot edit that.
Would it help to define an auxiliary variable and use logical constraints to set this? With the implication constraint '=>' you can write the conditions you listed:
(w[v][r] <= t + l1) => (auxvar == d[i][t] * x[i][t][v][r]).
If you want to do that only for feasible solutions then you could also post process feasible solutions and output whatever you like, see this chapter in the manual.
------------------------------
Daniel Junglas
Original Message:
Sent: Wed June 17, 2020 04:58 AM
From: Floor M
Subject: If function in scipting log
Hi!
I would like to create an if function in the scripting log based on the outcomes of my objective function.
My objective function is: maximize sum (i in S, t in T, v in V, r in R) (w[v][r] <= t + l1) * d[i][t] * x[i][t][v][r]
+ sum (i in S, t in T, v in V, r in R) ((w[v][r] >= t + l1 + 1) && (w[v][r] <= t + l2)) * d[i][t] * x[i][t][v][r] * p1
+ sum (i in S, t in T, v in V, r in R) (w[v][r] >= t + l2 + 1) * d[i][t] * x[i][t][v][r] * p2;
I would like to calculate:
d[i][t] * x[i][t][v][r] if w[v][r] <= t + l1,
d[i][t] * x[i][t][v][r] if w[v][r] >= t + l1 + 1) && (w[v][r] <= t + l2, and
d[i][t] * x[i][t][v][r] if w[v][r] >= t + l2 + 1.
I have not used the scripting log often before, so I think I make minor mistakes in the formulation. However, I could not find an answer online that helped me.
Thank you in advance!
------------------------------
Floor M
------------------------------
#DecisionOptimization