IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

MATLAB Discussion :

[fmincon] probleme au niveau d'une fonction à minimiser [Débutant]


Sujet :

MATLAB

  1. #1
    Membre à l'essai
    Homme Profil pro
    physique
    Inscrit en
    Octobre 2016
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : physique
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2016
    Messages : 13
    Points : 10
    Points
    10
    Par défaut [fmincon] probleme au niveau d'une fonction à minimiser
    salut tout le monde
    j'ai un petit problème au niveau d'une fonction que j'aurai utilisée dans fmincon:
    j'aime bien séparer la fonction à minimiser du programme principal mais je trouve un problème car ma fonction contient deux matrices qui sont calculées dans le programme principal
    voila mon programme et merci d'avance cordialement
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
     
    W1=[2.8378 2.6442 2.4427 4.2023 3.2031 2.4735 4.1054 2.5122 3.6153 0.2697 3.3655 2.4966]
    G=[ 0.2329    0.4007    0.6090    0.8203    0.9707    0.9852    0.8158    0.4921 0.1515    0.0000    0.1811    0.6147   
        0.7146    0.9606    0.9525    0.5895    0.1136    0.0582    0.6011    0.9998 0.1515    0.0000    0.1811    0.6147
        0.9964    0.7822    0.1937    0.0649    0.7567    0.8722    0.0565    0.5237 0.5142    0.0001    0.5931    0.9474
        0.8158    0.1515    0.1811    0.9679    0.4029    0.2193    0.9592    0.0010 0.8683    0.0003    0.9377    0.1800
        0.3410    0.0794    0.9453    0.3355    0.4260    0.6726    0.3634    0.4606 0.9992    0.0006    0.9653    0.1995
        0.0143    0.6814    0.6248    0.2429    0.7363    0.4457    0.2133    0.9978 0.8275    0.0009    0.6560    0.9579
        0.1400    0.9927    0.0003    0.9940    0.1290    0.4327    0.9987    0.5552 0.4574    0.0012    0.2337    0.5904
        0.6011    0.5142    0.5931    0.1242    0.9623    0.6848    0.1567    0.0040 0.1131    0.0017    0.0042    0.0006 ]
     
    fun =@(x)(abs(x(1)*G(1,1) - W1(1) + x(2)*G(2,1) + x(3)*G(3,1) + x(4)*G(4,1)+ x(5)*G(5,1) + x(6)*G(6,1)+ x(7)*G(7,1) + x(8)*G(8,1))+...
               abs(x(1)*G(1,2) - W1(2) + x(2)*G(2,2) + x(3)*G(3,2) + x(4)*G(4,2) + x(5)*G(5,2)+ x(6)*G(6,2)+ x(7)*G(7,2) + x(8)*G(8,2))+...
               abs(x(1)*G(1,3) - W1(3) + x(2)*G(2,3) + x(3)*G(3,3) + x(4)*G(4,3) + x(5)*G(5,3)+ x(6)*G(6,3)+ x(7)*G(7,3) + x(8)*G(8,3))+...
               abs(x(1)*G(1,4) - W1(4) + x(2)*G(2,4) + x(3)*G(3,4) + x(4)*G(4,4) + x(5)*G(5,4)+ x(6)*G(6,4)+ x(7)*G(7,4) + x(8)*G(8,4))+...
               abs(x(1)*G(1,5) - W1(5) + x(2)*G(2,5) + x(3)*G(3,5) + x(4)*G(4,5) + x(5)*G(5,5)+ x(6)*G(6,5)+ x(7)*G(7,5) + x(8)*G(8,5))+...
               abs(x(1)*G(1,6) - W1(6) + x(2)*G(2,6) + x(3)*G(3,6) + x(4)*G(4,6) + x(5)*G(5,6)+ x(6)*G(6,6)+ x(7)*G(7,6) + x(8)*G(8,6))+...
               abs(x(1)*G(1,7) - W1(7) + x(2)*G(2,7) + x(3)*G(3,7) + x(4)*G(4,7) + x(5)*G(5,7)+ x(6)*G(6,7)+ x(7)*G(7,7) + x(8)*G(8,7))+...
               abs(x(1)*G(1,8) - W1(8) + x(2)*G(2,8) + x(3)*G(3,8) + x(4)*G(4,8) + x(5)*G(5,8)+ x(6)*G(6,8)+ x(7)*G(7,8) + x(8)*G(8,8))+...
               abs(x(1)*G(1,9) - W1(9) + x(2)*G(2,9) + x(3)*G(3,9) + x(4)*G(4,9) + x(5)*G(5,9)+ x(6)*G(6,9)+ x(7)*G(7,1) + x(8)*G(8,9))+...
              abs(x(1)*G(1,10) - W1(10) + x(2)*G(2,10) + x(3)*G(3,10) + x(4)*G(4,10) + x(5)*G(5,10)+ x(6)*G(6,10)+ x(7)*G(7,10) + x(8)*G(8,10))+...
              abs(x(1)*G(1,11) - W1(11) + x(2)*G(2,11) + x(3)*G(3,11) + x(4)*G(4,11) + x(5)*G(5,11)+ x(6)*G(6,11)+ x(7)*G(7,11) + x(8)*G(8,11))+...
              abs(x(1)*G(1,12) - W1(12) + x(2)*G(2,12) + x(3)*G(3,12) + x(4)*G(4,12) + x(5)*G(5,12)+ x(6)*G(6,12)+ x(7)*G(7,12) + x(8)*G(8,12)));
     
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    x0 = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]; %%% point de départ
    lb = [0,0,0,0,0,0,0,0]; %%%% min 
    ub = [4,4,4,4,4,4,4,4]; %%% Max 
     
    [x fval]= fmincon(fun,x0,[],[],[],[],lb,ub)

  2. #2
    Modérateur
    Avatar de le fab
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mars 2005
    Messages
    1 882
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2005
    Messages : 1 882
    Points : 3 432
    Points
    3 432
    Par défaut
    salut

    en gros tu définis de manière séparé ta fonction comme suit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    function y = mafonction(x,G,W1)
    y = (abs(x(1)*G(1,1) - W1(1) + x(2)*G(2,1) + x(3)*G(3,1) + x(4)*G(4,1)+ x(5)*G(5,1) + x(6)*G(6,1)+ x(7)*G(7,1) + x(8)*G(8,1))+...
               abs(x(1)*G(1,2) - W1(2) + x(2)*G(2,2) + x(3)*G(3,2) + x(4)*G(4,2) + x(5)*G(5,2)+ x(6)*G(6,2)+ x(7)*G(7,2) + x(8)*G(8,2))+...
               abs(x(1)*G(1,3) - W1(3) + x(2)*G(2,3) + x(3)*G(3,3) + x(4)*G(4,3) + x(5)*G(5,3)+ x(6)*G(6,3)+ x(7)*G(7,3) + x(8)*G(8,3))+...
               abs(x(1)*G(1,4) - W1(4) + x(2)*G(2,4) + x(3)*G(3,4) + x(4)*G(4,4) + x(5)*G(5,4)+ x(6)*G(6,4)+ x(7)*G(7,4) + x(8)*G(8,4))+...
               abs(x(1)*G(1,5) - W1(5) + x(2)*G(2,5) + x(3)*G(3,5) + x(4)*G(4,5) + x(5)*G(5,5)+ x(6)*G(6,5)+ x(7)*G(7,5) + x(8)*G(8,5))+...
               abs(x(1)*G(1,6) - W1(6) + x(2)*G(2,6) + x(3)*G(3,6) + x(4)*G(4,6) + x(5)*G(5,6)+ x(6)*G(6,6)+ x(7)*G(7,6) + x(8)*G(8,6))+...
               abs(x(1)*G(1,7) - W1(7) + x(2)*G(2,7) + x(3)*G(3,7) + x(4)*G(4,7) + x(5)*G(5,7)+ x(6)*G(6,7)+ x(7)*G(7,7) + x(8)*G(8,7))+...
               abs(x(1)*G(1,8) - W1(8) + x(2)*G(2,8) + x(3)*G(3,8) + x(4)*G(4,8) + x(5)*G(5,8)+ x(6)*G(6,8)+ x(7)*G(7,8) + x(8)*G(8,8))+...
               abs(x(1)*G(1,9) - W1(9) + x(2)*G(2,9) + x(3)*G(3,9) + x(4)*G(4,9) + x(5)*G(5,9)+ x(6)*G(6,9)+ x(7)*G(7,1) + x(8)*G(8,9))+...
              abs(x(1)*G(1,10) - W1(10) + x(2)*G(2,10) + x(3)*G(3,10) + x(4)*G(4,10) + x(5)*G(5,10)+ x(6)*G(6,10)+ x(7)*G(7,10) + x(8)*G(8,10))+...
              abs(x(1)*G(1,11) - W1(11) + x(2)*G(2,11) + x(3)*G(3,11) + x(4)*G(4,11) + x(5)*G(5,11)+ x(6)*G(6,11)+ x(7)*G(7,11) + x(8)*G(8,11))+...
              abs(x(1)*G(1,12) - W1(12) + x(2)*G(2,12) + x(3)*G(3,12) + x(4)*G(4,12) + x(5)*G(5,12)+ x(6)*G(6,12)+ x(7)*G(7,12) + x(8)*G(8,12)));
    puis tu lance l'optimisation comme suit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    [x fval]= fmincon(@(x) mafonction(x,G,W1),x0,[],[],[],[],lb,ub)
    Fabien

  3. #3
    Membre à l'essai
    Homme Profil pro
    physique
    Inscrit en
    Octobre 2016
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Activité : physique
    Secteur : Enseignement

    Informations forums :
    Inscription : Octobre 2016
    Messages : 13
    Points : 10
    Points
    10
    Par défaut probleme au niveau d'une fonction à minimiser
    il s'amarch bien Mr fabien merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme de traduction d'une fonction Delphi en BCB
    Par blondelle dans le forum C++Builder
    Réponses: 7
    Dernier message: 13/03/2007, 23h03
  2. Réponses: 3
    Dernier message: 14/12/2006, 10h09
  3. Réponses: 1
    Dernier message: 16/06/2006, 16h12
  4. Grand Probleme d'appele d'une fonction
    Par Soufyane dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 17/02/2006, 15h57
  5. Probleme de pointeur sur une fonction
    Par nicky78 dans le forum C
    Réponses: 2
    Dernier message: 23/05/2004, 20h26

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo