Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fmincon fixed costs

Subject: fmincon fixed costs

From: Nivi

Date: 9 May, 2013 20:55:09

Message: 1 of 6

I am using Matlab R2012a and I am trying to incorporate fixed costs in establishing links in a supply chain. My objective function is very similar to the one discussed in this thread http://www.mathworks.in/matlabcentral/newsreader/view_thread/314409
I shall attach my testing objective function to this mail. If you have some insight into this matter, please help me out.

Thank You

function y = simple_objective(x,C,c,nodes)
    y=0;
    k=1;
    for i = 1:nodes,
        for j = 1:nodes,
            if c(i,j) > -1
                if(c(i,j)> 0)
                    y = y+ x(k)*C(i,j) + x(k)*x(k);
                end
                k = k+1;
            end
        end
    end
    % New links in full merger : 3 4 5 6 12 14 15 17
    % fixed costs on these : 50 25 40 30 25 10 30 20
    fc = zeros(1,18);
    fc(3)=50;
    fc(4)=25;
    fc(5)=40;
    fc(6)=30;
    fc(12)=25;
    fc(14)=10;
    fc(15)=30;
    fc(17)=20;
    fc2 = zeros(1,18);
    for i = 1:18,
        if x(i)> 0.0001
            if fc2(i)==0
                y = y+fc(i)*5;
                fc2(i)=1;
            end
        end
    end
end

Subject: fmincon fixed costs

From: Alan_Weiss

Date: 10 May, 2013 12:01:47

Message: 2 of 6

On 5/9/2013 4:55 PM, Nivi wrote:
> I am using Matlab R2012a and I am trying to incorporate fixed costs in
> establishing links in a supply chain. My objective function is very
> similar to the one discussed in this thread
> http://www.mathworks.in/matlabcentral/newsreader/view_thread/314409
> I shall attach my testing objective function to this mail. If you have
> some insight into this matter, please help me out.
>
> Thank You
>
> function y = simple_objective(x,C,c,nodes)
> y=0;
> k=1;
> for i = 1:nodes,
> for j = 1:nodes,
> if c(i,j) > -1
> if(c(i,j)> 0)
> y = y+ x(k)*C(i,j) + x(k)*x(k);
> end
> k = k+1;
> end
> end
> end
> % New links in full merger : 3 4 5 6 12 14 15 17
> % fixed costs on these : 50 25 40 30 25 10 30 20
> fc = zeros(1,18);
> fc(3)=50;
> fc(4)=25;
> fc(5)=40;
> fc(6)=30;
> fc(12)=25;
> fc(14)=10;
> fc(15)=30;
> fc(17)=20;
> fc2 = zeros(1,18);
> for i = 1:18,
> if x(i)> 0.0001
> if fc2(i)==0
> y = y+fc(i)*5;
> fc2(i)=1;
> end
> end end
> end

I do not understand the question. What is it you want us to do? Is there
an error that MATLAB throws? Or is it something else?

Alan Weiss
MATLAB mathematical toolbox documentation

Subject: fmincon fixed costs

From: Nivi

Date: 10 May, 2013 12:27:10

Message: 3 of 6

Alan_Weiss <aweiss@mathworks.com> wrote in message <kminjb$1ul$1@newscl01ah.mathworks.com>...
> On 5/9/2013 4:55 PM, Nivi wrote:
> > I am using Matlab R2012a and I am trying to incorporate fixed costs in
> > establishing links in a sup

The last part is what i want clarified.... The fixed cost must come into picture only if there is a flow on the respective new link.
I run the code and it doesn't converge... 20 long minute i waited and it wouldn't give me a solution


If Fmincon can't help, is there any other alternative ?

Subject: fmincon fixed costs

From: Torsten

Date: 10 May, 2013 12:50:11

Message: 4 of 6

"Nivi" wrote in message <kmip2u$6hg$1@newscl01ah.mathworks.com>...
> Alan_Weiss <aweiss@mathworks.com> wrote in message <kminjb$1ul$1@newscl01ah.mathworks.com>...
> > On 5/9/2013 4:55 PM, Nivi wrote:
> > > I am using Matlab R2012a and I am trying to incorporate fixed costs in
> > > establishing links in a sup
>
> The last part is what i want clarified.... The fixed cost must come into picture only if there is a flow on the respective new link.
> I run the code and it doesn't converge... 20 long minute i waited and it wouldn't give me a solution
>
>
> If Fmincon can't help, is there any other alternative ?

Write out your problem in mathematical notation (not as MATLAB code).
Maybe then somebody can give advice about suitable MATLAB routines for a solution.

Best wishes
Torsten.

Subject: fmincon fixed costs

From: Nivi

Date: 10 May, 2013 14:06:07

Message: 5 of 6

so there's a supply chain.... products moving along certain pathways from manufacturers to the retailers. when two companies undergo a merger or an acquisition, the supply chain merges.... now i use fmincon to optimize the flow, find the most economical path the products should take, but during mergers new links are created, say from manufacturer of firm A to warehouse of firm B, now there are costs associated with establishing these new links, what i call fixed costs, and variable costs which is a function of the flow along that path/link. i've modelled variable costs and optimized my results, but i am unable to incorporate the fixed costs which must be 0 if there is no flow on the new link and non-zero if there is ANY flow on that link because sometimes there could be an optimal solution if one link is not established AT ALL and the flow which is supposed to be on that link is balanced
on another

Subject: fmincon fixed costs

From: Torsten

Date: 10 May, 2013 14:39:07

Message: 6 of 6

"Nivi" wrote in message <kmiusf$pbp$1@newscl01ah.mathworks.com>...
> so there's a supply chain.... products moving along certain pathways from manufacturers to the retailers. when two companies undergo a merger or an acquisition, the supply chain merges.... now i use fmincon to optimize the flow, find the most economical path the products should take, but during mergers new links are created, say from manufacturer of firm A to warehouse of firm B, now there are costs associated with establishing these new links, what i call fixed costs, and variable costs which is a function of the flow along that path/link. i've modelled variable costs and optimized my results, but i am unable to incorporate the fixed costs which must be 0 if there is no flow on the new link and non-zero if there is ANY flow on that link because sometimes there could be an optimal solution if one link is not established AT ALL and the flow which is supposed to be on that link is
balanced
> on another

I think whether a link is estabished or not must be accounted for by a binary variable
(0 or 1).
Thus your problem becomes a MINLP problem that you should not handle using fmincon. There are also no other MATLAB solvers available for this kind of problem.

Best wishes
Torsten.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us