How to use CVX in matlab code?

Hello!
I am new to cvx, I have no idea how to use it.
I hope you could help me.
I want to optimize the UAV trajectory, I have several variables that I have to calculate before getting the optimal trajectory which are related to the location of the UAV.
I wonder if I should run my program in matlab first with a fixed point of the UAV location, then apply CVX to find the optimal points?
Thanks in advance,

Answers (1)

Torsten
Torsten on 13 Nov 2022
Use intlinprog.
No need to linearize anything - your equations are linear in the unknowns.

12 Comments

Hi @Torsten ,
this is just an example but in my real case i wil maximize my objective function under a variable(n) and it will be represent in other constraints, the above is just a part. I just mentioned this to get some ideas how to transform a binary value into linear form?
Show us your real case. In the above, nothing needs to be linearized.
Torsten
Torsten on 14 Nov 2022
Edited: Torsten on 14 Nov 2022
What are given data in your model ? What is to be determined ?
Constraints (1) and (2) look strange. The first constraint must be wrong since only one u_ij is present without further reference to i or j. In the second constraint, the u_ij should be inside the sum, shouldn't they ?
Safia
Safia on 14 Nov 2022
Edited: Safia on 14 Nov 2022
Z(t), Q,alpha,Ec,E_f,Eb, R ̃_m^((lb) )(t),L : all are known data.
I have also other variables that should be calculated before applying cvx optimizer.
My question is : if u_i,j is a binary value , the problem can't be solved right?
in the first and second constraint ,i multiplied by u_i,j to satisfy the correspondent elements of u_i,j
it means if u_i,j =1 verify condition
else otherwise
Use intlinprog. As far as I can see, the problem can be solved by a normal linear mixed-integer optimizer.
But I changed non convex constraint to convex in order to use CVX .. But Cvx can't solve MILP problem
Torsten
Torsten on 14 Nov 2022
Edited: Torsten on 14 Nov 2022
Why is "intlinprog" not an option for you ? Don't you have a license for the optimization toolbox ?
@Torsten yes i do. I already install cvx in matlab
the type of my problem is solved by cvx. But because i don't have any idea how to use it , i'm asking when exactly i call cvx, after doing my all program with given data or how exactly?
Torsten
Torsten on 14 Nov 2022
Edited: Torsten on 14 Nov 2022
I have no experience with cvx - so I cannot tell you.
I answered because I don't see why you would need a solver different from "intlinprog". And until now, you couldn't show me a part of the model where "intlinprog" would not be sufficient for a solution.
So if you insist on cvx as solver - for whatever reasons - you should open a new question.
Or try a YouTube Video:
@Torsten Thank you very much for you effort,
apologize for asking so many questions , i want t know if i will use "intlinprog" ,how can i write my program :
i want to optimize X in order to get maximum sum of u_ij
but X is a variable that appears in equation of R , so i should calculate R at first but in this case with which X should i calculate R. Hope that you understand the question
Torsten
Torsten on 14 Nov 2022
Edited: Torsten on 14 Nov 2022
I don't see from your model how X influences R. If X is also a solution vector and influences R(t), you will have to use "ga" instead of "intlinprog" since your problem becomes nonlinear.
So define X(1),...,X(T) as solution variables - then you have values in the course of the optimization to calculate R(1),...,R(T) in the "nonlcon" function of "ga".
Safia
Safia on 14 Nov 2022
Edited: Safia on 14 Nov 2022
@Torsten you will understand more by this example : in my case X(t)=qu(t).
at first
because Rn is non convex so :
after this the constraint becomes :

Sign in to comment.

Tags

Asked:

on 13 Nov 2022

Edited:

on 14 Nov 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!