Transforming Optimization Code from Problem-Based to Solver-Based Approach in MATLAB

조회 수: 4 (최근 30일)
Maria
Maria 2024년 8월 16일
댓글: Maria 2024년 8월 16일
Hello,
I have successfully implemented an ILP problem using MATLAB's problem-based optimization approach. However, I am now looking to switch to the solver-based approach to take advantage of its flexibility and efficiency.
In the problem-based approach, I defined binary decision variables, constraints, and an objective function using optimvar, optimconstr, and optimexpr. The code works well, but I need guidance on how to transform this code into a solver-based format using intlinprog.
Here’s a summary of what I have:
Decision Variables:
A 3D binary matrix A(N, numNodes, num_vehicles) for task assignment.
A binary vector chi(num_vehicles) for satisfaction.
Other binary variables like z, t_wait_aux, etc.
Constraints:
Assignment constraints, dependency constraints, and time-based constraints.
I linearized expressions using auxiliary variables and max constraints.
Objective Function:
The objective is to maximize the satisfaction rate, expressed as a linear function of chi.
Could you provide guidance or directions how to systematically convert my existing problem-based variables and constraints into the matrix form required by intlinprog
Here is the code
the problem is attached.
Thank you for your continued help!
run('MyProblem.m')
Unrecognized function or variable 'Compute_uplink_time_linear'.

Error in MyProblem (line 38)
uplink_time = Compute_uplink_time_linear(A,all_subtasks,Data_rate);

Error in run (line 112)
evalin('caller', strcat(scriptStem, ';'));
  댓글 수: 6
Maria
Maria 2024년 8월 16일
Hello @Steven Lord sorry for my late reply, I hadn't seen your comment.
prob2struct is just a suggestion to switch to solver mode. I didn't get an error but the result was weird and didn't fit the purpose. I used the problem based on the structure attached above in myProblem but I don't know if it is possible to convert the expressions into ILP statements, so I solved my problem as follows
% Solve the ILP problem
[x, fval, exitflag, output] = intlinprog(prob);

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2024년 8월 16일
  댓글 수: 3
Matt J
Matt J 2024년 8월 16일
편집: Matt J 2024년 8월 16일
@Maria That's not what @Torsten said. He said that he doesn't recommend moving to solver-based form at all because it is hard to make changes once the problem is in that form.
If solve() works on the problem-based formulation then prob2struct has to work. All that solve() really does internally is convert to solver-based form for you (probably using prob2struct) and then run a traditional solver.
Maria
Maria 2024년 8월 16일
@Matt J Yes, I understand. I also wanted to say that it doesn't work because it didn't give the result I wanted because the problem has different variables.
My problem for the solver based is related to the objective function because same result was display for different constraints.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Problem-Based Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by