Effacer les filtres
Effacer les filtres

Error : Failure in initial user-supplied nonlinear constraint function evaluation.

118 vues (au cours des 30 derniers jours)
Maria
Maria le 12 Août 2024 à 18:42
Commenté : Maria le 14 Août 2024 à 13:01
Hello everyone!
I'm encountering an issue with my MATLAB code and could use some assistance. Specifically, I'm getting the following error message:
[sol, fval, exitflag, output] = solve(prob);
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation.
It seems to be related to the evaluation of the nonlinear constraint function. I've attached the relevant part of my code below. I'm particularly confused because I linearised all my constraint terms, so I wasn't expecting any non-linearity.
Could you please help me identify the issue and suggest any potential fixes?
Thank you!
best Regards!
MyProblem()
Unrecognized function or variable 'N'.

Error in MyProblem (line 2)
A = optimvar('A', N, numNodes, Devices, 'Type', 'integer', 'LowerBound', 0, 'UpperBound', 1);
  12 commentaires
Maria
Maria le 13 Août 2024 à 0:07
Does the issue come from this expression!!
Torsten
Torsten le 13 Août 2024 à 8:50
Modifié(e) : Torsten le 13 Août 2024 à 9:12
No. You just didn't set how t_wait_aux is defined.
Further, it's not necessarily true that setting
m >= x(1),m >= x(2),...,m >= x(n)
will give m = max(x) in an optimization. All values for "m" that are bigger than max(x) also satisfy the constraints.
It must be the case that "m" influences the objective function such that the lower its value the lower the value of the objective function (if your aim is to minimize). If this is the case, "m" will be chosen as max(x) by the optimizer.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 13 Août 2024 à 5:46
assigned_node = find(A(sb, :, v), 1);
covering_uav = find(zeta_m_n(v, :), 1);
if assigned_node == covering_uav
That code has a problem: assigned_node can come out empty. That leads to problems with the statement
arg2_covering_to_assigned(k) = arg2(covering_uav, assigned_node, k)
as arg2() comes out empty when assigned_node is empty, but an empty result cannot be assigned to a definite output location.
When I add in some tracing lines, I get
no assigned node at v = 1, sb = 4, node = 1
no assigned node at v = 1, sb = 4, node = 2
no assigned node at v = 1, sb = 4, node = 3
no assigned node at v = 1, sb = 4, node = 4
no assigned node at v = 2, sb = 1, node = 1
no assigned node at v = 2, sb = 1, node = 2
no assigned node at v = 2, sb = 1, node = 3
no assigned node at v = 2, sb = 1, node = 4
repeated over and over again.
  20 commentaires
Torsten
Torsten le 14 Août 2024 à 12:36
If you define
Vehicle_Data = zeros(N, numNodes, Devices); % Ensure Vehicle_Data is defined
you automatically get uplink_time = 0, thus T_off = 0 and finally the constraints
subject to uplinkConstraint:
0 <= 0.3039
0 <= 0.31376
0 <= 0.40509
Maria
Maria le 14 Août 2024 à 13:01
Yes i adjusted above.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by