Optimally we would like to be able to set these variables as integers, which as far as I'm aware can't be done without the Global Optimization Toolbox but we aren't sure if the other aspects of what we are doing would be possible within the bounds of that toolbox. Sadly, due to the project funding it is likely we only have the ability to get permanent access to one of the 2 toolboxes, so we want to know what would be possible and how we would be best suited to make this work.
Nonlinear Optimization with 2 Variables, 1 variable is always equal limit
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Alan Weiss
on 21 May 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
0 Comments
See Also
Categories
Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!