Mathematical Optimization with MATLAB

Поділитися
Вставка
  • Опубліковано 16 січ 2025

КОМЕНТАРІ • 47

  • @alielectricalelectronicsan2092
    @alielectricalelectronicsan2092 4 роки тому +2

    A.o.A sir how can we solve non linear problems in matlab .
    I only now how to solve the linear
    Problems in matlab
    Can you provide me some help in this .

    • @apm
      @apm  4 роки тому

      Here are a few options to solve nonlinear problems in MATLAB: apmonitor.com/che263/index.php/Main/MatlabOptimization Unfortunately, I can't respond to the many private, individual requests that I receive. I recommend that you post specific questions to Mathworks support.

  • @Zahra19934
    @Zahra19934 Рік тому

    What about dual problem of least square problem analytically string duality exist but numercially results are not same.

  • @asan7440
    @asan7440 3 роки тому +1

    Hi , when I tried to use the code I faced this error if you can help me
    Error using urlread
    The value of 'url' is invalid. Expected input to be one of these types:
    char
    Instead its type was java.net.URL.
    Error in urlreadwrite>parseInputs (line 144)
    p.parse(args{:})
    Error in urlreadwrite (line 15)
    inputs = parseInputs(fcn,varargin);
    Error in urlread (line 47)
    [s,status] = urlreadwrite(mfilename,catchErrors,url,varargin{:});
    Error in urlread_apm (line 51)
    output = urlread(url);
    Error in apm (line 31)
    response = urlread_apm(url);
    Error in apm_solve (line 55)
    apm(server,app,'clear all');
    Error in hs71 (line 8)
    y = apm_solve('hs71');

    • @apm
      @apm  3 роки тому

      Try gekko optimization suite instead?

  • @ahmedsultan36
    @ahmedsultan36 6 років тому

    Hallo,I have a linear optimization and i will use x = fmincon(fun,x0,A,b,Aeq,beq,lb,ub)fun = F(x,y,z,g)
    x,y,z are inequality constrains such as 0 < x < 100 y and z are the same
    g is a function of x,y,z >>>> g = f(x,y,z)In other words, the optimization run as follows
    1. values for x,y,z2. Calculate g = f(x,y,z)3. calculate fun = F(x,y,z,g) and so on until it finds the the maximum which is equal to (-ve) x
    I HAVE 2 QUESTIONS.1. How can i integrate equation g (step 2) in equation fun (step 3)2. For 0

    • @apm
      @apm  6 років тому

      Please see Method #2 here: apmonitor.com/che263/index.php/Main/MatlabOptimization you can certainly call functions within functions. The solver will need the constraints and an objective function.

    • @ahmedsultan36
      @ahmedsultan36 6 років тому

      Thanks, it helped. I have another questions regarding the optimization results..I have run the model and I got 2 different results:1) A local minimum was found with only 13 iterations and 142 funccount. I have compared Matlab to another software and it should run at least for 1 hour while it took only 8 minutes. That's why, i am not sure if the result which was found is the same as the global minimum or not as my goal is to find the global minimum.2) When I change the upper bound or any input in the mathematical model which is the function that i call, i get the message of fmincon stopped because the size of the current step ..... step size 6.2 e-11
      Thanks again.

    • @apm
      @apm  6 років тому

      As you probably already know, fmincon is a local minimizer. There are global optimization solvers with the Global Optimization Toolbox that you may want to use instead. If a solver reports that the KKT conditions are satisfied then it will often say that it was successful in finding a solution. It sounds like fmincon gave up because it couldn't make progress towards that solution. You should check to see if it reports success / failure in meeting the KKT conditions for optimality.

    • @ahmedsultan36
      @ahmedsultan36 6 років тому

      Yes, for an example global optimization but it takes 40 or 50 times more than fmincon :).
      Hallo,
      I have another question.
      I want to plot each and everz simulation that MATLAB runs in the optimization, is it possible to plot the all ?
      Thanks in advance

    • @apm
      @apm  6 років тому

      The plot may get busy if you have more variables. Here is an example of plotting the trial values with simulated annealing (global optimization approach): apmonitor.com/me575/index.php/Main/SimulatedAnnealing You can plot in a loop but just use the "hold on" command.

  • @bellajesica865
    @bellajesica865 9 років тому

    hi i have i question if i want to show the tables of simplex method in GUI how i can do it ??plz help me

    • @apm
      @apm  9 років тому

      +Bella Jesica We don't use the simplex method here because the problem is nonlinear.

    • @bellajesica865
      @bellajesica865 9 років тому

      +APMonitor.com yes i know but i ask you if you have any idea about my question :)

    • @apm
      @apm  9 років тому

      It looks like the new muPad has some nice options for displaying the simplex tables: www.mathworks.com/help/symbolic/mupad_ref/linopt-transparent.html I'm not aware of another method to do this in Matlab besides constructing your own matrix and displaying it at the command terminal.

    • @bellajesica865
      @bellajesica865 9 років тому

      okey thank you very much :D

  • @henrytandohjnr1573
    @henrytandohjnr1573 8 років тому

    Please i need to find the trnsfer function of a system where i have just the data from the system, hw do i go about it?

    • @apm
      @apm  8 років тому

      +henry tandoh jnr you can use system identification methods such as the example posted here apmonitor.com/do/index.php/Main/ModelIdentification

  • @muhammadyaqoob8668
    @muhammadyaqoob8668 7 років тому

    Hi there,
    How can I change the solver? The default one is 3 and I may try 1 and 2 to select the best one for my design?

    • @apm
      @apm  7 років тому

      +Muhammad Yaqoob, Here is some documentation: apmonitor.com/wiki/index.php/Main/OptionApmSolver
      You can change solver option with:
      apm_option(server,app,'apm.solver',1);

    • @muhammadyaqoob8668
      @muhammadyaqoob8668 7 років тому

      Sir,
      Really appreciate your help. One more question.
      How can I communicate with my apm model from Matlab, for example, I may want to change parameters and run IPOPT/BPOPT again and again (can be in a 'for' loop for the given range of parameters) and plot the cost function (min) against that given range of parameters.
      Actually, I am working on the total power loss minimization for my power converter for the given range of parameters, Io (1-20 A), Vp (200-250 V), Vs (10-48 V).
      Right now, I am able to solve Pt for the one set of parameters i.e., Io=15 A, Vp=250 V, and Vs=48. My apm model is given below:
      --------------------------------------------------------------------------------------------------------------------------------------------------
      Model
      Parameters
      Vp=250
      Vs=48
      Io=15
      f=50000
      n=5.21
      Rpon=0.04
      Rson=0.004
      Rp=0.150
      Rs=0.015
      Rt=0.150
      Rc=0.010
      tonp=0.000000040
      toffp=0.000000085
      tons=0.000000045
      toffs=0.000000050
      L1=0.000614
      L2=0.0000226
      Co=0.00000006337
      pi=3.1416
      End Parameters
      Variables
      ap = 0, >=0, =0, =0,

    • @apm
      @apm  7 років тому

      You can do this by configuring your parameters as FVs such as:
      apm_info(server,app,'FV','Vp');
      In your loop, you can update the value and resolve with:
      for i = 1,10
      apm_meas(server,app,'Vp',i*10); % insert new value
      output = apm(server,app,'solve'); % solve
      y = apm_sol(s,a); % get solution
      end

    • @muhammadyaqoob8668
      @muhammadyaqoob8668 7 років тому

      Thanks sir, it helped. I have tried to look for these commands from "APMonitor Documentation" but failed. Can you refer to the source from which I can see all of these commands.
      Lastly, is it possible to introduce a discontinuous constraint in my optimization problem? For example, in the code given above, I want my objective function to be Pt= Pcr+Pcd+0 (instead of Pt= Pcr+Pcd+Psw) when Psw=0, I want it to be the part of objective function or else keep it 0.

    • @apm
      @apm  7 років тому

      Muhammad, there is a list of functions at apmonitor.com/wiki/index.php/Main/MatlabFunctions (for MATLAB) and apmonitor.com/wiki/index.php/Main/PythonFunctions (for Python). I also highly recommend the Python GEKKO package (gekko.readthedocs.io/en/latest/). If you want conditional statements, I recommend using slack variables: apmonitor.com/wiki/index.php/Main/SlackVariables or else binary or MPEC equations: apmonitor.com/me575/index.php/Main/LogicalConditions to introduce logical conditions but still maintain continuous differentiation of the equations. If you insert an "IF" statement, the equations have a point that is not continuously differentiable and the gradient-based solvers won't work.

  • @MegaDarkable
    @MegaDarkable 8 років тому

    do you have any vid that teaching about how to implement the objective function and constraint in MOOP.
    addition, how do you know it good solution or bad in this vid. i don't see you show the convex.

    • @apm
      @apm  8 років тому +1

      +Wissanu Thungrut check out the optimization course at apmonitor.com/me575 on multi objective optimization, especially the book chapter on Pareto fronts. Another way to form multi objective optimization problems is with an l1-norm objective such as apmonitor.com/do/index.php/Main/MultiObjectiveOptimization The benefit of this approach is that it is much faster and deterministic.

    • @MegaDarkable
      @MegaDarkable 8 років тому

      thank you so much.

    • @MegaDarkable
      @MegaDarkable 8 років тому

      can you give me an example of diet nutrient in multiple objective. i already thought about it.
      i think, i'm not clearly understand it.

    • @apm
      @apm  8 років тому +1

      Here is one example diet problem: apmonitor.com/wiki/index.php/Apps/FoodDiet You could have several objectives including cost, taste, and nutrition constraints. The multiple objectives may form a Pareto frontier from which you could select any number of the best options for trade-offs. See apmonitor.com/me575 for more information on multi-objective solutions.

    • @MegaDarkable
      @MegaDarkable 8 років тому

      you really help me a lot. thank in your kindness.

  • @garasiotomania7120
    @garasiotomania7120 7 років тому

    i have problem with fuzzy linear programming, can you give me a matlab tutorial to solve the fuzzy linear programming problem?

    • @apm
      @apm  7 років тому

      +Garasi OtoMania, this platform solves Linear Programming (LP) problems with gradient based solvers. I'd recommend the optimization course (apmonitor.com/me575) for more information about solver strategies. There isn't a section about fuzzy LP but there are Genetic Algorithms, Simulated Annealing, and other approaches.

  • @sidharthparhi
    @sidharthparhi 9 років тому

    how to optimize two inter-dependable functions simultaneously? Please guide me.

    • @apm
      @apm  9 років тому

      +Sidharth Sankar parhi The most common approach is to include both objective functions in the same optimization problem. You can use either a squared error approach or an l1-norm objective (apmonitor.com/do/index.php/Main/ControllerObjective). If you use an l1-norm objective then you can explicitly prioritize the relative importance of the two objectives. If your two objectives are hierarchical (one is solved in an outer problem) then you may need to create a bi-level optimization strategy. Another way to include two or more objectives is with a Pareto front and a method like a Genetic Algorithm. Gradient based methods will be much faster but will mostly converge to local optimum. One of the features of APMonitor with multiple objectives is to rank them as tiers or levels where the multiple objectives are solved successively.

  • @natezimmer4489
    @natezimmer4489 8 років тому +2

    So how do you write the solver....

    • @apm
      @apm  8 років тому

      +Nate Zimmer Here is some information on solver development. apmonitor.com/me575/index.php/Main/InteriorPointMethod

  • @marcfischer114
    @marcfischer114 6 років тому

    Hi, where's the link to the Matlab file please?

    • @apm
      @apm  6 років тому

      apmonitor.com/che263/index.php/Main/MatlabOptimization

  • @Zahra19934
    @Zahra19934 Рік тому

    Min x'*x s.t Ax=b and its dual is max 1/4( x'*A*A'*x)+x'*b and its min=-(dual) so min of primal=-min(dual) by sloving fmincon they both should be same.

  • @bodhas
    @bodhas 7 років тому

    sir
    can u help me solving a multiobjective optimization problem in power system.
    that includes economic and emission optimization
    thanks

    • @apm
      @apm  7 років тому

      +Kapil Bodha, here is an example of solving a multi-objective optimization problem in dynamic optimization: apmonitor.com/do/index.php/Main/MultiObjectiveOptimization
      You may also want to look at Pareto fronts for managing the tradeoffs: apmonitor.com/me575/index.php/Main/BookChapters (see chapter on Genetic Algorithms).

  • @LaimonasGaming
    @LaimonasGaming 7 років тому

    Why is it so slow? It takes up to a second to optimize some super simple tasks.

    • @rrc
      @rrc 7 років тому

      Laimonas Sutkus, it is using an Internet connection to solve the problems. You can download a Windows or Linux server to install it locally and avoid the overhead of transmitting over the Internet. See apmonitor.com/wiki/index.php/Main/APMonitorServer

  • @lm5050
    @lm5050 7 років тому

    not helpful

    • @apm
      @apm  7 років тому +1

      +lm5050, check out Method #2 if you need a tutorial for fmincon: apmonitor.com/che263/index.php/Main/MatlabOptimization

    • @lm5050
      @lm5050 7 років тому

      That pointed me in the right direction cheers mate