problem based approach- script running but does not gives a solution

hello everyone i am working on a problem where i choosed problem based approach to solve it. I am very new to MATLAB so i do not know what i am doing wrong but here is my question:
the script is running but it does not gives me any solution it just says 'Solving problem using ga' (i want to solve with ga). I dont think it iterates. I have set stopping criterias that is not the problem. I have been looking to find answers to my problem but could not find any. Anyhow, if you have any ideas why i am facing this situation and suggestions to solve it i would be appreaciated.
Thank you in advance!

10 Kommentare

Show us the script.
Torsten
Torsten am 10 Apr. 2022
Bearbeitet: Torsten am 10 Apr. 2022
I suggest first using a conventional form for solving your problem (not ga).
After you get correct solutions, it's still time to switch to ga.
This way, you can save long waiting times in the development and debugging phase.
Azime Beyza Ari
Azime Beyza Ari am 10 Apr. 2022
Bearbeitet: Azime Beyza Ari am 10 Apr. 2022
i tried solving it with intlinprog but it gives error saying i should use ga instead.
I did not changed anyting just cahnged the solver and the options.
Currently it iterates with ga, but still takes too much time. I knew that iteration takes too much time for these kinds of problems but that is why i choosed ga in the first place. Since it is a meta-heurastics method it should have been much faster.
According to the equations you enclosed earlier, your problem should be solvable using "intlinprog".
My guess is that something went wrong in the problem formulation in the problem-based approach or that you have hidden some details of your model for us (e.g. nonlinearities) that force MATLAB to use "ga".
No there is no nonlinear equations or inequalities. There is only one objective, and two constraints so far and they all are linear. When i write my objective function it forces me to use ga. Did not understand why.
I just opened a new file and did copy and past. Did not changed anything.
The file i previously worked (solver based one) on did 100 iterations in 10 mins. But now each iteration takes approx. 1-2 mins.
Then you should look at the changes you made to the old file and think about why MATLAB now thinks it's necessary to use "ga" for your problem.
Thank you for your time and interest! I will look into it with that point of view.
Thank you!
Be mindfull of the (-1) in your function,
z= (-1)*sum(x.*rij.*ai,'all');
Because you have set ObjectiveSense="maximize", the (-1) makes it so that you are effectively minimizing z= sum(x.*rij.*ai,'all').

Melden Sie sich an, um zu kommentieren.

Antworten (1)

There is only one objective, and two constraints so far and they all are linear. When i write my objective function it forces me to use ga. Did not understand why.
It forces you to use ga() because you have specified your objective function using fcn2optimexpr(). When you specify it as below, the solver can tell right away that it is an integer linear program, and solves it very quickly with initlinprog,
load Problem
x=problem.Variables.x;
y=problem.Variables.y;
problem.Objective=sum((x.*rij)*ai);
sol=solve(problem);
Solving problem using intlinprog. LP: Optimal objective value is -1402.268722. Cut Generation: Applied 1 implication cut, and 1 strong CG cut. Lower bound is -1402.000000. Heuristics: Found 1 solution using total rounding, and 1 solution using ZI round. Upper bound is -1089.000000. Relative gap is 28.72%. Heuristics: Found 1 solution using ZI round. Upper bound is -1304.000000. Relative gap is 7.51%. Heuristics: Found 1 solution using 2-opt. Upper bound is -1315.000000. Relative gap is 6.61%. Cut Generation: Applied 11 Gomory cuts, 18 implication cuts, and 3 strong CG cuts. Lower bound is -1383.000000. Relative gap is 5.17%. Branch and Bound: nodes total num int integer relative explored time (s) solution fval gap (%) 10000 1.87 4 -1.315000e+03 1.595745e+00 17766 3.11 4 -1.315000e+03 0.000000e+00 Optimal solution found. Intlinprog stopped because the objective value is within a gap tolerance of the optimal value, options.AbsoluteGapTolerance = 0 (the default value). The intcon variables are integer within tolerance, options.IntegerTolerance = 1e-05 (the default value).
sol.x=round(sol.x);
sol.y=round(sol.y);

Produkte

Version

R2022a

Gefragt:

am 10 Apr. 2022

Kommentiert:

am 10 Apr. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by