Nonlinear Optimization with 2 Variables, 1 variable is always equal limit
Mostra commenti meno recenti
We are currently working on a project that requires minimizing the cost of a welding projects by optimizing the amount of welders used for the project along with the amount of days the project takes. We are currently running into an issue where the amount of welders used is going to infinity, and will always equal whatever upper limit we set. Here is the equation we are optimizing, along with the constraints and the call to fmincon
clear;
clc;
x0 = [0 0];
% Possible Inputs %
deadline = 30;
upperBounds = [15 deadline];
% Set nondefault solver options
options = optimoptions('fmincon','PlotFcn','optimplotfvalconstr');
% Solve
[solution,objectiveValue] = fmincon(@objectiveFcn,x0,[],[],[],[],...
zeros(size(x0)),upperBounds,@constraintFcn,options);
% Clear variables
clearvars options
clc;
disp(solution);
disp(objectiveValue);
function f = objectiveFcn(optimInput)
% inputs but for now temp values
workHours = 10;
paidHours = 11;
weight = 15000;
overhang = 6;
qaqc = 2;
welderCost = 523.41;
helperCost = 467.32;
laborerSkilledCost = 467.32;
stabberCost = 450.87;
spacerO16Cost = 450.87;
operatorCost = 576.98;
foremanCost = 756.76;
strawBossCost = 643.35;
clampmanCost = 450.87;
qaqcCost = 678.24;
pipelayerCost = workHours * 124.54;
LOA = 175;
welders = optimInput(1);
days = optimInput(2);
constcrew = 8; % straw,foreman,2spacers,stabber,clampman,2operators
f = days*(welders * welderCost + welders * helperCost + (welders/3) * laborerSkilledCost...
+ foremanCost + strawBossCost + stabberCost + 2*spacerO16Cost + qaqc*qaqcCost...
+ clampmanCost + 2*pipelayerCost + 2*operatorCost + (welders*2 + constcrew + (welders/3) + qaqc)*LOA);
end
function [c,ceq] = constraintFcn(optimInput)
% Note, if no inequality constraints, specify c = []
% Note, if no equality constraints, specify ceq = []
eff = 5;
welds = 1000;
welders = optimInput(1);
days = optimInput(2);
c = [];
ceq = (welders*days*eff) - welds;
end
We would optimally like the equation to find the best balance between days and welders, not just maximize the amount of welders possible. Are we going about this optimization the wrong way, is there a better method?
EDITED TO ADD FULL CODE
3 Commenti
Jadon Latta
il 20 Mag 2021
Jadon Latta
il 20 Mag 2021
Modificato: Jadon Latta
il 20 Mag 2021
Risposte (1)
Alan Weiss
il 21 Mag 2021
Your problem has costs in terms of the problem variables of the form
cost = days*welders*positive + days*positive2;
Here positive and positive2 are positive constants. The constraint you have can be written
days*welders = positive3;
Therefore, your problem setup clearly has the minimal cost at the minimal value of days:
cost = positive3*positive + days*positive2;
The problem you experience is not a fault of the solution method, but of the problem definition.
To get a different result, you must give different costs.
Alan Weiss
MATLAB mathematical toolbox documentation
Categorie
Scopri di più su Surrogate Optimization in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!