Questions in topic: "optimization"
https://developer.ibm.com/answers/questions/topics/single/165265.html
The latest questions for the topic "optimization"Planning Analytics and Cplex (DO) Connection/Integration
https://developer.ibm.com/answers/questions/512130/planning-analytics-and-cplex-do-connectionintegrat.html
Do you know any examples that shows how to connect Planning Analytics with Cplex. I want to run an optimization model from a Planning Analytics dashboard but I couldn't find any resources that explains it clearly.
What I am trying to achieve is:
1 - Providing the Input data for the optimization model from Planning Analytics cubes
2 - Running Optimization model from Planning Analytics with an "optimize" button
3 - Writing optimization outputs back to the Planning Analytics cubes and dashboards
Thank you in advance.ibm-cloudanalyticsintegrationcplexconnectionoptimizationplanningThu, 18 Jul 2019 07:41:45 GMTA.AydoganWhy does Cplex provide slack on constraints when providing a feasible solution?
https://developer.ibm.com/answers/questions/499879/why-does-cplex-provide-slack-on-constraints-when-p.html
I developed a linear mathematical programming model in Visual Studio (C++) and solved the problem using Cplex (12.7.1). However I noticed some strange behavior of Cplex. For some problem instances, Cplex provides a feasible (non-optimal solution), that could be easily improved. A simplified example of the mathematical model is as follows:
Minimize A
Subject to
c*X – d*Y <= A
d*Y – c*X <= A
X, Y binary, A continuous, c,d parameters
Given the values of X and Y in the provided feasible (non-optimal) solution, there is slack on both constraints. The continuous A variable could be easily reduced given the values of decision variables X and Y. I understand that Cplex provides a solution that is feasible given the constraints of the problem, but the solution can be easily improved by removing the slack on the constraints and reducing the A variable. Why is Cplex not able to provide this solution without slack on the constraints? What can I do to ensure Cplex always provides at least a solution with binding constraints?cplexoptimizationoptimizerWed, 03 Apr 2019 08:55:06 GMTTeunvanGilsCPLEX non-convex error for MIQP using Python API
https://developer.ibm.com/answers/questions/499596/cplex-non-convex-error-for-miqp-using-python-api.html
I read online that CPLEX can solve non-convex MICP, but I'm receiving an error "Error: Model is non-convex" when trying to solve this using the Python API. Is there something special I need to do to get CPLEX to solve these types of programs, or is there bug in my code?
![alt text][1]
[1]: /answers/storage/temp/27529-error.pngerrorpythoncplexoptimizationMon, 01 Apr 2019 21:20:05 GMTntsa15Point/Feasibility Cuts in Benders Decomposition
https://developer.ibm.com/answers/questions/499527/pointfeasibility-cuts-in-benders-decomposition-1.html
Dear all,
I am learning about Benders Decomposition and now, I am working with the file bendersatsp.py. I understand that in this case it isn't necessary add feasibility cuts but, how could they be added in this file? I would like to know where it is necessary to add this part of code in order to check in other MIP problems.
Thanks in advance!pythoncplexoptimizationcallbackMon, 01 Apr 2019 14:44:04 GMTTWonderAutomatic Benders Decomposition parameter in CPLEX
https://developer.ibm.com/answers/questions/497546/automatic-benders-decomposition-parameter-in-cplex.html
Dear all,
I have a maximization model implemented in PYTHON, which has two blocks of integer variables, X and Y. Only the block of Y variables appear in the objective function. As I would like to solve by the Automatic Benders Decomposition algorithm from CPLEX (using the parameter [parameters.benders.strategy.set(3)][1]) I have to relax one of two blocks of variables.
It turns out that if variables Y (which do not appear in the objective function) are relaxed I get the solution. However, if variables X are relaxed I get the CPLEX error: `CPLEX Error 2000: No Benders decomposition available.`
I do not understand where is the problem. Would it be necessary to use auxiliary variables? In that case, could anyone show me a toy example?
Thanks in advance!
[1]: https://www.ibm.com/support/knowledgecenter/pl/SSSA5P_12.7.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/BendersStrategy.htmlcplexannotationoplparameteroptimizationmainquery-modificationMon, 18 Mar 2019 16:11:39 GMTTWonderCannot set CURRENT OPTIMIZATION HINT special register via db2dsdriver.cfg section.
https://developer.ibm.com/answers/questions/497261/cannot-set-current-optimization-hint-special-regis-1.html
Hi
I was trying to provide a default value for the CURRENT OPTIMIZATION HINT special register for my DB2 client application.
I tried db2dsdriver.cfg file and it's section and JDBC specialRegisters Uri parameter. Both lead to the same result:
1. When I set the value without quotes like so:
db2dsdriver.cfg:
<specialregisters>
<parameter name="CURRENT OPTIMIZATION HINT" value="HELLO1"/>
</specialregisters>
or with JDBC Uri:
jdbc:db2://<ip>:<port>/<database>:retrieveMessagesFromServerOnGetMessage=true;emulateParameterMetaDataForZCalls=1;specialRegisters=CURRENT OPTIMIZATION HINT=HELLO1;
I get an exception saying I have a problem with the SET instruction:
> Message: ERROR [42721] [IBM][DB2] SQL0969N There is no message text corresponding to SQL error "-725" in the message file on this workstation. The error was returned from module "DSNLXENV" with original tokens "CURRENT QUERY OPTIMIZATION DALLASA". SQLSTATE=42721
Here is the exempt from the java trace:[java trace][1]
2. When I try the same and put quoted around the value, I get some strange results:
db2dsdriver.cfg:
<specialregisters>
<parameter name="CURRENT OPTIMIZATION HINT" value="'HELLO1'"/>
</specialregisters>
or with JDBC Uri:
jdbc:db2://<ip>:<port>/<database>:retrieveMessagesFromServerOnGetMessage=true;emulateParameterMetaDataForZCalls=1;specialRegisters=CURRENT OPTIMIZATION HINT='HELLO1';
The result is that the special registed is set to some faulty value:
SELECT CURRENT OPTIMIZATION HINT FROM SYSIBM.SYSDUMMY1;
returns a string:
> "\0\0\0\u00010\u001a\0\0"
[1]: /answers/storage/temp/27230-javatrace.txtdb2clioptimizationFri, 15 Mar 2019 10:23:48 GMTlircoCannot set CURRENT OPTIMIZATION HINT special register via db2dsdriver.cfg section.
https://developer.ibm.com/answers/questions/497259/cannot-set-current-optimization-hint-special-regis.html
Hi
I was trying to provide a default value for the CURRENT OPTIMIZATION HINT special register for my DB2 client application.
I tried db2dsdriver.cfg file and it's section and JDBC specialRegisters Uri parameter. Both lead to the same result:
1. When I set the value without quotes like so:
db2dsdriver.cfg:
<specialregisters>
<parameter name="CURRENT OPTIMIZATION HINT" value="HELLO1"/>
</specialregisters>
or with JDBC Uri:
jdbc:db2://<ip>:<port>/<database>:retrieveMessagesFromServerOnGetMessage=true;emulateParameterMetaDataForZCalls=1;specialRegisters=CURRENT OPTIMIZATION HINT=HELLO1;
I get an exception saying I have a problem with the SET instruction:
> Message: ERROR [42721] [IBM][DB2] SQL0969N There is no message text corresponding to SQL error "-725" in the message file on this workstation. The error was returned from module "DSNLXENV" with original tokens "CURRENT QUERY OPTIMIZATION DALLASA". SQLSTATE=42721
Here is the exempt from the java trace:[java trace][1]
2. When I try the same and put quoted around the value, I get some strange results:
db2dsdriver.cfg:
<specialregisters>
<parameter name="CURRENT OPTIMIZATION HINT" value="'HELLO1'"/>
</specialregisters>
or with JDBC Uri:
jdbc:db2://<ip>:<port>/<database>:retrieveMessagesFromServerOnGetMessage=true;emulateParameterMetaDataForZCalls=1;specialRegisters=CURRENT OPTIMIZATION HINT='HELLO1';
The result is that the special registed is set to some faulty value:
SELECT CURRENT OPTIMIZATION HINT FROM SYSIBM.SYSDUMMY1;
returns a string:
> "\0\0\0\u00010\u001a\0\0"
[1]: /answers/storage/temp/27229-javatrace.txtdb2clioptimizationFri, 15 Mar 2019 10:21:02 GMTlircoBenders Worker Algorithm parameters
https://developer.ibm.com/answers/questions/493710/benders-worker-algorithm-parameters-1.html
Dear all,
I have seen that there is a parameter to select which algorithm CPLEX should apply to solve subproblems of a Benders decomposition between five options.
[Worker Algorithm parameter][1]
[1]: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/WorkerAlgorithm.html?view=embed
By default, this parameter is 0 which means that CPLEX decide.
In this case, my question is: Is there any way (or parameter) to know what choice CPLEX has taken in each subproblem?
Thanks in advance!cplexannotationoploptimizationmainquery-modificationTue, 19 Feb 2019 16:01:27 GMTTWonderBenders Worker Algorithm parameters
https://developer.ibm.com/answers/questions/493707/benders-worker-algorithm-parameters.html
Dear all,
I have seen that there is a parameter to select which algorithm CPLEX should apply to solve subproblems of a Benders decomposition between five options.
[Worker Algorithm parameter][1]
[1]: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/Parameters/topics/WorkerAlgorithm.html?view=embed
By default, this parameter is 0 which means that CPLEX decide.
In this case, my question is: Is there any way (or parameter) to know what choice CPLEX has taken in each subproblem?
Thanks in advance!cplexannotationoplparameteroptimizationmainquery-modificationTue, 19 Feb 2019 15:56:10 GMTTWonderCPLEX Error 1426: Low-level file I/O error.
https://developer.ibm.com/answers/questions/490550/cplex-error-1426-low-level-file-io-error.html
Hello,
I'm using docloud's python api to solve a MIP; input is a .lp.gz file and i expect a output json result.
I have a error message "Engine error: CPLEX returned non-zero status 1,426 (Unable to write new incumbent to file "/var/job_processor/work/do-job-processor6.ilog.ibmcloud.local/tmp/java/job6710454062287638224.tmp/sol-00001.sol".
CPLEX Error 1426: Low-level file I/O error.
)"
so what's the error about and how can i solve it?
Thank you!
MarkdocplexcloudoptimizationTue, 29 Jan 2019 23:26:00 GMTmarkwzxAny possibilities to smooth CPLEX Results?
https://developer.ibm.com/answers/questions/483043/any-possibilities-to-smooth-cplex-results.html
Dear Community,
I am trying to shave a given electricity demand profile as much as possible by application of a battery - only constrained by the battery's size and maximum power output.
The shaving itself works perfectly fine, yet, in regions where there should be no battery activity, there is quite much of it. The figure the problem.
![alt text][1]
The orange curve is my decision vector, the blue one the original demand and the grey one the new demand after application of the battery (demand + decision vector). As you can see, the top part is shaped very well. However, in the lower regions (roughly between 5 and 10) the battery does not show a smooth profile, but rather jumps from one state to the other.
This behavior is not yet constrained, but it is also not explicitly motivated. Is there any setting I can change to receive more "smooth" profiles? Or any idea for penalty terms to achieve this?
I once described the general problem [here][2]. And this is my code with Matlab Toolbox functions so far:
% Cost function (minimize max peak over period => minimize auxiliary variable)
f_help = zeros(length(P_USE),1);
f = [f_help;1]; % Vector for linear objective function: Minimize p*x (negative x for discharged/sold energy)
% Constraints
add_on_1 = zeros(length(P_USE),1); % Add-on for auxiliary variable max peak
add_on_2 = zeros(length(P_USE)/2,1); % Add-on for auxiliary variable max peak
Aineq_1a = eye(length(P_USE));
Aineq_1a = [Aineq_1a, add_on_1]; % Left side inequality: Power constraint
Aineq_1b = Aineq_1a*-1; % Left side inequality: Power constraint
tril1 = tril(ones(length(P_USE)/2));
tril1 = tril1 * eta_c;
tril2 = tril(ones(length(P_USE)/2));
tril2 = tril2 * eta_d;
Aineq_2a = [tril1, tril2, add_on_2]; % Left side inequality: Energy constraint
Aineq_2b = Aineq_2a*-1; % Left side inequality: Energy constraint
eye_1 = [eye(length(P_USE)/2), eye(length(P_USE)/2)];
ones_1 = ones(length(P_USE)/2,1) * -1;
Aineq_3 = [eye_1 , ones_1]; % Left side inequality: Peak constraint
Aineq_4 = [zeros(length(P_USE)/2,length(P_USE)/2),eye(length(P_USE)/2),add_on_2]; % Left side inequality: Cannot charge/discharge above load
Aineq_4 = Aineq_4*-1;
bineq_1(1:2*length(P_USE),1) = Pmax; % Right side inequality: Power constraint
bineq_2(1:length(P_USE),1) = Smax/2; % Right side inequality: Energy constraint
bineq_3 = P_USE(1:(length(P_USE)/2)) * -1; % Right side inequality: Peak constraint
bineq_4 = P_USE(1:length(P_USE)/2); % Right side inequality: Cannot charge/discharge above load
lb1(1:length(P_USE)/2,1) = 0; % Lower bound: Sign of x (charging cannot be negative)
lb2(1:length(P_USE)/2,1) = -inf; % Lower bound: Sign of x (discharging can be negative)
ub1(1:length(P_USE)/2,1) = inf; % Upper bound: Sign of x (charging can be positive)
ub2(1:length(P_USE)/2,1) = 0; % Upper bound: Sign of x (discharging cannot be positive)
Aineq = [Aineq_1a; Aineq_1b; Aineq_2a; Aineq_2b; Aineq_3; Aineq_4]; % Linear inequality constraint: Aineq*x <= bineq.
bineq = [bineq_1; bineq_2; bineq_3; bineq_4];
Aeq = []; % Linear Equality constraint: Aeq*x = beq
beq = [];
lb = [lb1; lb2; 0]; % Lower bounds
ub = [ub1; ub2; inf]; % Upper bounds
% SOS Constraints indicating that only one of each pair within x can be
% non-zero (x1 or x8761 can be non-zero)
sostype = repmat('1', [1, length(P_USE)/2]);
v1 = 1:length(P_USE);
v2 = reshape(v1, [], 2)';
v3(1:length(P_USE)/2,1) = 0;
v4(1:length(P_USE)/2,1) = 1;
v5 = [v3 v4]';
sosind = mat2cell(v2, 2, ones(1,size(v2,2)));
soswt = mat2cell(v5, 2, ones(1,size(v5,2)));
ctype = repmat('C', [1, length(P_USE)+1]);
% Solver - IBM ILOG CPLEX
options = cplexoptimset;
options.Display = 'on';
options.Algorithm =
[x,fval] = cplexmilp(f,Aineq,bineq,Aeq,beq,sostype,sosind,soswt,lb,ub,ctype,[],options);
[1]: /answers/storage/temp/25573-bildschirmfoto-2018-12-01-um-141008.png
[2]: https://developer.ibm.com/answers/questions/476782/view.htmlcplexoptimizationmatlabSat, 01 Dec 2018 13:23:35 GMTMathias_RWTHOptimization is not starting converging (Going indefinitely)
https://developer.ibm.com/answers/questions/481928/optimization-is-not-starting-converging-going-inde.html
Optimization is not starting converging (Going indefinitely)
Hi,
I am working on minimization problem where lowest value of the objective can be 0 only (cant be negative).
CPLEX is indefinitely finding bounds and objective as 0 where it should stop. In STatistics tab, only staright red line is there after 1.5 hour (No clue why it is not converging.
When I have made my demand higher by 20% which is over its capacity that time it solves with some objective value but when I put some demand less than capacity, it gets into this loop.
Please help.
Presolve has eliminated 399971 rows and 575421 columns...
Tried aggregator 2 times.
MIP Presolve eliminated 502819 rows and 673987 columns.
MIP Presolve modified 14420 coefficients.
Aggregator did 83708 substitutions.
Reduced MIP has 184554 rows, 167779 columns, and 596850 nonzeros.
Reduced MIP has 124438 binaries, 1824 generals, 0 SOSs, and 45316 indicators.
Presolve time = 9.34 sec. (26569.82 ticks)
Probing fixed 0 vars, tightened 128 bounds.
Probing time = 9.02 sec. (2332.20 ticks)
Tried aggregator 2 times.
MIP Presolve eliminated 41332 rows and 28440 columns.
MIP Presolve modified 12892 coefficients.
Aggregator did 35550 substitutions.
Reduced MIP has 107672 rows, 103789 columns, and 443086 nonzeros.
Reduced MIP has 71113 binaries, 16044 generals, 0 SOSs, and 45316 indicators.
Presolve time = 3.87 sec. (7997.56 ticks)
Probing time = 0.13 sec. (18.47 ticks)
Clique table members: 58006.
MIP emphasis: balance optimality and feasibility.
MIP search method: dynamic search.
Parallel mode: deterministic, using up to 4 threads.
Root relaxation solution time = 7.32 sec. (2798.44 ticks)
Nodes Cuts/
Node Left Objective IInf Best Integer Best Bound ItCnt Gap
0 0 0.0000 3465 1.0000 35033
0 0 0.0000 5055 Cuts: 5277 76298
.... HENCE FORTH IT GOES ON LIKE THIS.....cplexoploptimizationilogSun, 25 Nov 2018 07:10:23 GMTAmit1024Initial solution in a PYTHON model
https://developer.ibm.com/answers/questions/481338/initial-solution-in-a-python-model.html
Dear all,
I have a maximization model implemented in PYTHON. I would like to stablish an heuristic solution as a lower bound which has been computed with an algorithm, in order to speed up the running time.
I have been reading about `cplex.MIP_starts.add`, but I do not know how I can use it.
Could someone show me a toy example in order to I understand what is the correct way to use this command?
Thanks in advance!pythoncplexoptimizationboundTue, 20 Nov 2018 18:13:41 GMTTWonderFormulation in Cplex
https://developer.ibm.com/answers/questions/480392/formulation-in-cplex.html
Hi,
Is someone familiar with Cplex and could help me to formulate the attached equation in Cplex.[link text][1]
Xij, is the effective age of component i at the start of period j.
X´ij, is the effective age of component i at the end of period j.
Alpha is the improvement factor.
T: Length of the planning horizon.
J: Number of intervals.
[1]: /answers/storage/temp/25263-model.pdfcplexoptimizationoptimizerWed, 14 Nov 2018 07:51:56 GMTNadLIf statment with bounds in Cplex
https://developer.ibm.com/answers/questions/479976/if-statment-with-bounds-in-cplex.html
Hi, I want to model a production with two machines(m), 6 equiments (w) and 5 products (p), with macro-(t) and microperiods (s) in Cplex. Which i have done so far, now i want to modell the effective age of my equipment, which i calculate as below. I want to undertake maintenance when the equipment comes to a production of w1=500, w2=450...(Maint[w]) but as i modelled it, it does not work. And the cleaning has to be undertaken between 135 and 185 which does not work as well. Additionally the cleaning as an affect of 0.05 on the effective age and the maintenance of 1. I attached my model in the pdf file.
forall(s in S,p in P, t in T, w in W) if(t == 1 && s == 1){
ea[w][t][s]>=sum(p in P, m in M)r_x[m][w][p][t][s]*0.001;
}else if(t > 1 && s < 2){
ea[w][t][s]>=(ea[w][t-1][3]+sum(p in P, m in M)r_x[m][w][p][t][s]*0.001)-b_maint[w][t-1][3]-(b_clean [w][t-1][3]*0.05);
}else if (s > 1){
ea[w][t][s]>=(ea[w][t][s-1]+sum(p in P, m in M)r_x[m][w][p][t][s] *0.001)-b_maint[w][t][s-1]-(b_clean[w][t][s-1]*0.05); }
forall(w in W, t in T, s in S)
(Maint[w]<=sum(p in P, m in M)r_x[m][w][p][t][s])<=(b_maint[w][t][s]<=1);
forall(w in W, t in T, s in S)
(135<=sum(p in P, m in M)r_x[m][w][p][t][s] && sum(p in P, m in M)r_x[m][w][p][t][s] <=185)==(b_clean[w][t][s]==1);
[1]: /answers/storage/temp/25222-model-opl-12.pdfcplexfunctionoploptimizationoptimizerMon, 12 Nov 2018 12:23:28 GMTNadLCplex function
https://developer.ibm.com/answers/questions/479945/cplex-function.html
Hi,
I have the following objection function for a production line, with m=2, p=5, w=6, t=3 and s=3:
dexpr float obj_production_cost=sum (m in M, p in P,t in T, s in S, w in W) c_prod[m][w][p] * r_x[m][w][p][s][t];
forall(t in T, p in P)
if(t<2){
INV0[p] + Backorder0[p]+sum(m in M, s in S, w in W)(r_x[m][w][p][t][s]*b_x[p][w][m])-r_INV[p][t]-r_Backorder[p][t]==dem[p][t];
}else { r_INV[p][t-1] - r_Backorder[p][t]+sum(m in M, s in S, w in W)(r_x[m][w][p][t][s]*b_x[p][w][m])-r_INV[p][t]+r_Backorder[p][t-1] ==dem[p][t];}
I want now to set t=7 but Cplex then tells me that my r_x is out of bound?cplexfunctionoploptimizationoptimizerMon, 12 Nov 2018 08:51:10 GMTNadLMinimize Max Value - CPLEX Matlab Toolbox
https://developer.ibm.com/answers/questions/476782/minimize-max-value-cplex-matlab-toolbox.html
Dear community,
how do I formulate a minmax problem with the CPLEX Matlab Toolbox?
I would like to formulate the following expression:
Min Dmax, with D being a vector (dimension 1x336).
... in the form of a cplexmilp problem as described [here][1].
Thanks and regards,
Mathias
[1]: https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.6.2/ilog.odms.cplex.help/refmatlabcplex/html/cplexmilp-m.htmlcplexoptimizationoptimizermatlabTue, 23 Oct 2018 07:49:49 GMTMathias_RWTHcplexlsqmilp - bad results, but why?!
https://developer.ibm.com/answers/questions/476319/cplexlsqmilp-bad-results-but-why.html
Dear community,
based on a previous question I applied a cplexlsqmilp solver (toolbox, Matlab API) to a problem as follows:
MIN (SUM [ (R+X)^2 ])
,with R being a given scalar vector.
This should to my understanding result in X always having the opposite sign of R to minimize the total sum. However, the solver gives back bad results. The code goes as follows (I will not post the constraints, as these are already proven to be correct in a cplexmilp probelm):
The optimization function:
C = eye(length(R)); % miqcp problem: min norm(C*x-d)^2
d = -R;
My constraints (already proven to be correct in a cplexmilp problem):
a1 = eye(length(R));
a2 = a1*-1;
tril1 = tril(ones(length(R)/2));
tril1 = tril1 * eta_c;
tril2 = tril(ones(length(R)/2));
tril2 = tril2 * eta_d;
a3 = [tril1, tril2];
a4 = a3*-1;
b1(1:2*length(R),1) = Pmax; % Power constraint
b2(1:length(R),1) = Smax/2; % Energy constraint
lb1(1:length(R)/2,1) = 0; % sign of x (charging cannot be negative)
lb2(1:length(R)/2,1) = -inf; % sign of x (discharging can be negative)
ub1(1:length(R)/2,1) = inf; % sign of x (charging can be positive)
ub2(1:length(R)/2,1) = 0; % sign of x (discharging cannot be positive)
Aineq = [a1; a2; a3; a4]; % Linear inequality constraint: Aineq*x <= bineq.
bineq = [b1; b2];
Aeq = []; % Linear Equality constraint: Aeq*x = beq
beq = [];
lb = [lb1; lb2]; % Lower and upper bounds
ub = [ub1; ub2];
A set of SOS constraints (I basically split the X vector in two halfs, the first one is either 0 or positive, the second one either 0 or negative. This has also been proven beforehand):
sostype = repmat('1', [1, length(R)/2]); % Replicate 1 time vertically, n times horizontally.
v1 = 1:length(R); % Create Vector
v2 = reshape(v1, [], 2)'; % Reshape Vector To 2-Row Matrix
sosind = mat2cell(v2, 2, ones(1,size(v2,2))); % Create Cell Array
v3(1:length(R)/2,1) = 0;
v4(1:length(R)/2,1) = 1;
v5 = [v3 v4]';
soswt = mat2cell(v5, 2, ones(1,size(v5,2)));
ctype = repmat('C', [1, length(R)]); % Replicate 1 time vertically, n times horizontally.
And my solver call:
options = cplexoptimset;
options.Display = 'on';
[x,resnorm] = cplexlsqmilp(C,d,Aineq,bineq,Aeq,beq,sostype,sosind,soswt,lb,ub,ctype,[],options);
Does anybody see the flaw in here?! For an exemplary set of R see below:
0,0713293650793651; 0,0508184523809524; 0,0384176587301587; 0,0359871031746032;
0,0406250000000000; 0,0593005952380952; 0,0930555555555556; 0,121701388888889; 0,028050595238095; -0,230606150793651; -0,372969246031746; -0,423435515873016; -0,389230158730159; -0,279453373015873; -0,0548750000000000; 0,0879742063492064; 0,104836309523810; 0,142881944444444; 0,167261904761905; 0,175570436507937; 0,155778769841270; 0,132316468253968; 0,127058531746032; 0,094692460317460; 0,071329365079365;cplexoptimizationoptimizermatlabFri, 19 Oct 2018 07:16:36 GMTMathias_RWTHFormulation of CPLEX Optimization Function
https://developer.ibm.com/answers/questions/475984/formulation-of-cplex-optimization-function.html
Dear community,
I am currently and repeatedly struggling with the formulation of an optimization function for Matlab's CPLEX API.
I am trying to formulate the following function in CPLEX syntax:
MIN ( SUM [ (P+X)^2 ])
, with P being a given scalar vector in the dimension of 1x8760 and X being the variable to be optimized (same dimension).
It seems to me that this must be simple. However, I just can't find an approach here. I must confess that I have very little experience in optimization, even less with CPLEX.
Thankful for every bit of help.
Best,
MathiascplexoptimizationoptimizermatlabWed, 17 Oct 2018 18:50:36 GMTMathias_RWTHSlow opening notes view with documents with RA fields
https://developer.ibm.com/answers/questions/475422/slow-opening-notes-view-with-documents-with-ra-fie.html
Hello, I have a question about optimalization of view loading. I have a lotus view that displays around 130 000 documents. Each document has its readers and authors field. It is a big number but when opening by admin with manager full rights - all documents are showed very quickly and also any selecting, sorting or opening category is ok. When I try to open the view with user ID that has author right and can read/edit only a couple of documents (around 20) the opening of the view takes a lot of time. Any other operation that changes the view data takes another couple of seconds. It is horror to work with this view... I suppose that LN view filters and hides the documents that the user should not view during the runtime.
Is there any idea or settings I can try to change to optimize. Definitelly I would like to avoid using private views...performancelotusnotesoptimizationviewlotusfilteringMon, 15 Oct 2018 12:41:24 GMTBruzaCPLEX encountered arrays with inconsistent lengths.
https://developer.ibm.com/answers/questions/473047/cplex-encountered-arrays-with-inconsistent-lengths.html
Dear all,
I try to find an optimum to a MILP problem (see code below). Therefore, I apply the CPLEX solver's Matlab API. I now get the error message:
Error using cplexmilp. CPLEX encountered arrays with inconsistent lengths.
To me, it seems like the reason must either be with the SOSs constraints or the lb, ub constraints, but I just couldn't figure out why. Also, it's my first time using SOSs constraints at all.
%% Optimization Framework
% General Definitions
p = Data.RAW.Marginal_Prices; % price vector
Smax = 13.5; % capacity
Pmax = 5; % maximal charging/discharging power
eta = 0.92; % battery efficiency
eta_c = sqrt(eta); % charge efficiency
eta_d = 1/sqrt(eta); % discharge efficiency
beta = 0.1; % in case penalty term is applied
% CPLEX Manipulation (split between charging and discharging)
p = [p;p];
%% Wholesale Arbitrage
% Cost function (minimize for arbitrage (negative))
f = p; % Double column vector for linear objective function
% Constraints
a1 = eye(length(p));
a2 = a1*-1;
tril1 = tril(ones(length(p)/2));
tril1 = tril1 * eta_c;
tril2 = tril(ones(length(p)/2));
tril2 = tril2 * eta_d;
a3 = [tril1, tril2];
a4 = a3*-1;
b1(1:2*length(p),1) = Pmax;
b2(1:length(p),1) = Smax/2;
lb1(1:length(p)/2,1) = 0;
lb2(1:length(p)/2,1) = -inf;
ub1(1:length(p)/2,1) = inf;
ub2(1:length(p)/2,1) = 0;
Aineq = [a1; a2; a3; a4]; % Linear inequality constraint: Aineq*x <= bineq.
bineq = [b1; b2];
Aeq = []; % Linear Equality constraint: Aeq*x = beq
beq = [];
lb = [lb1; lb2]; % Lower and upper bounds
ub = [ub1; ub2];
sostype = repmat('1', [1, length(p)/2]); % Replicate 1 time vertically, n times horizontally.
v1 = 1:length(p); % Create Vector
v2 = reshape(v1, [], 2)'; % Reshape Vector To 2-Row Matrix
sosind = mat2cell(v2, 2, ones(1,size(v2,2))); % Create Cell Array
v3(1:length(p)/2,1) = 0;
v4(1:length(p)/2,1) = 1;
v5 = [v3 v4]';
soswt = mat2cell(v5, 2, ones(1,size(v5,2)));
ctype = repmat('C', [1, length(p)]); % Replicate 1 time vertically, n times horizontally.
% Solver - IBM ILOG CPLEX
options = cplexoptimset;
options.Display = 'on';
[x,fval] = cplexmilp(f,Aineq,bineq,Aeq,beq,sostype,sosind,soswt,lb,ub,ctype,options);
Does anybody see the flaw here? The vector given by Data.RAW.Marginal_Prices looks like this:
51,52 51,52 51,52 51,52 67,30 67,30 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 74,01 67,30 67,30
Thanks a lot! MathiascplexoptimizationconstraintmatrixWed, 03 Oct 2018 10:35:41 GMTMathias_RWTHOptimization Constraint: One of every two variable pairs must be zero!
https://developer.ibm.com/answers/questions/471330/optimization-constraint-one-of-every-two-variable.html
Dear Community,
I ran into a problem I just couldn't solve:
I apply CPLEX to solve an optimization function as follows, with x being of the dimension of [2*8760 x 1]:
fun = @(x) x(:).'*p(:);
Now, I want to constrain that for every two elements of x, one must equal zero. Means, either x1 or x2 is zero; the same for the elements x3 and x4, x5 and x6 and so on...
Doing so, I can of course only use the constraint syntax as follows:
- a) Aineq*x <= bineq
- b) Aeq*x = beq
So, I would have to define either Aineq or Aeq and bineq or beq to achieve this constraint. Does anybody see any solution here? I am on the edge of losing my mind...
I am really looking forward to your thoughts on this! Thanks a lot!cplexoptimizationconstraintmatrixThu, 20 Sep 2018 15:45:57 GMTMathias_RWTHSet lower bound in a OPL model
https://developer.ibm.com/answers/questions/464688/set-lower-bound-in-a-opl-model.html
Dear all,
I have a maximization model implemented in OPL. I would like to stablish an heuristic solution as a lower bound which have been computed with an algorithm, in order to speed up the running time. How I can do it? Is there any way to set the lower bound to the objective function or is necessary to set the binary vector of the variables that appear in this objective function?
Thanks in advance!oploptimizationmainTue, 14 Aug 2018 20:43:18 GMTTWonderDoubt about benders_main.mod file. Benders modification in OPL
https://developer.ibm.com/answers/questions/456446/doubt-about-benders-mainmod-file-benders-modificat.html
Dear all,
I have seen in benders_main.mod file some ways to use Benders Decomposition. Specifically, this is the interesting part for me and about which I want to ask:
//--------------------------------------------------------
// use annotation with variables 1 by 1.
// if partitioning is bad, then an error will be raised by CPLEX...
var subCplex2 = new IloCplex();
var subOpl2 = new IloOplModel(masterDef, subCplex2);
subOpl2.addDataSource(masterElts);
subOpl2.generate();
subCplex2.bendersstrategy = 1;
subCplex2.newLongAnnotation("cpxBendersPartition");
for (var i in thisOplModel.R2){
for (var j in thisOplModel.R1){
subCplex2.setLongAnnotation("cpxBendersPartition", subOpl2.X[i][j], subOpl2.bendersPartition2[i]);
}
}
subCplex2.solve();
----------------------------------------------------------//
In my case, elements "i" and "j" are strings and tuple of strings, respectively. So, how I could implement this Benders modification? In "subOpl2.bendersPartition2[i]", I would have to write the position of element "i", not "i".
Thanks in advance!annotationoploptimizationmainquery-modificationTue, 03 Jul 2018 08:42:17 GMTTWonderAKCJC5001E: Unexpected HTTP code 0 for POST on https://api-oaas.docloud.ibmcloud.com/job_manager/rest/v1/jobs
https://developer.ibm.com/answers/questions/437106/akcjc5001e-unexpected-http-code-0-for-post-on-http.html
Greetings,
Recently, we were not able to run optimization on DoCloud, get following Unexpected HTTP code 0 for POST error, through debug log, Exception from get Response from jobResponse, any idea what could be? My last successfully ran is Feb 27, same model, same code, security or firewall change? Any help will be greatly appreciated.
Java Code:
SolveJobCallBack jobCallBack= new SolveJobCallBack(this);
futureJobResponse = executor.execute( request, jobCallBack);
response=futureJobResponse.get();
Error log:
Mar 15, 2018 9:33:42 PM com.ibm.optim.oaas.client.impl.OaasMessageCode log
SEVERE: AKCJC5001E: Unexpected HTTP code 0 for POST on https://api-oaas.docloud.ibmcloud.com/job_manager/rest/v1/jobs
Mar 15, 2018 9:33:42 PM com.ibm.optim.oaas.client.impl.OaasMessageCode log
INFO: AKCJC5006I: Retry 2 failed, exception for POST on https://api-oaas.docloud.ibmcloud.com/job_manager/rest/v1/jobs with cause Remot
e host closed connection during handshake
15 Mar 2018 21:33:46:376 [INFO] [MXServer] [CID-CRON-1504] Correlation started.
null
15 Mar 2018 21:33:46:423 [INFO] [MXServer] [CID-CRON-1504] Correlated data: BEGIN TaskName:DepreciationFinTransCronTask InstanceName:In
stDepreciationCronTask ElapsedTime:47 ms END
Mar 15, 2018 9:33:51 PM com.ibm.optim.oaas.client.impl.OaasMessageCode log
SEVERE: AKCJC5001E: Unexpected HTTP code 0 for POST on https://api-oaas.docloud.ibmcloud.com/job_manager/rest/v1/jobs
psdi.util.MXApplicationException: optimization#solvefailed
at com.ibm.tivoli.maximo.optimization.service.oaas.DOcplexCloudSolver.solve(DOcplexCloudSolver.java:345)
at com.ibm.tivoli.maximo.optimization.service.ODMEOptimizationService.runOptimization(ODMEOptimizationService.java:1045)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Thanks,
Qiupingibm-cloudrestapidocplexcloudoptimizationFri, 16 Mar 2018 02:35:08 GMTQiupingMaoHow to make sensitivity analysis?
https://developer.ibm.com/answers/questions/435026/how-to-make-sensitivity-analysis.html
In IBM Knowledge Center there is easy way to make sensitivity analysis by cmd like
----------
display sensitivity obj - or display sensitivity identifier
----------
but I don't want to use cmd, I want to use cplex studio
----------
Can you make a sensitivity analysis by simple problem?
----------
dvar float x1;
dvar float x2;
dexpr float profit = 3*x1 + 5*x2;
maximize profit;
subject to
{
ct1 : x1 <= 4;
ct2 : 2*x2 <= 12;
ct3 : 3*x1 + 2*x2 <= 18;
}
execute {
writeln(ct1.UB + " "+ct1.LB + " "+ ct1.dual + " " + ct1.slack);
writeln(ct2.UB + " "+ct2.LB + " "+ ct2.dual + " " + ct2.slack);
writeln(ct3.UB + " "+ct3.LB + " "+ ct3.dual + " " + ct3.slack);
writeln(x1.reducedCost + " "+ x2.reducedCost);
}
----------
this is my answer but I just find x1.reducedCost
but I can't find other things like The range of objective function coefficients whose optimal solution does not change or The range of the right-hand side constant in which the basis variable of the optimal solution does not change please help me :)optimizationsensitivesimpleTue, 06 Mar 2018 08:30:58 GMTDm725