Operations Research formulation in MATLAB

Solve below Operation Research Program & submit MATLAB code also.

댓글 수: 2

Steven Lord
Steven Lord 2020년 9월 16일
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
Manthan Hawal
Manthan Hawal 2020년 9월 17일
I tired solving but I am getting this issues and I am having difficulty as I am new to matlab.

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

답변 (2개)

Steven Lord
Steven Lord 2020년 9월 17일

0 개 추천

Looking at the code you posted as a comment I have a couple of observations and suggestions.
The Queen's MATLAB was only an April Fools joke. [It fooled people for longer than I expected it to, though!] The name-value pair to set the Color property of a line when calling plot is 'Color', 'r' (or 'Color', 'g' or 'Color', [1 0.75 0.5] etc.)
plot(1:10, 1:10, 'Color', 'r')
If you look at the documentation page for the plot function there are several pieces of information that may help you. There's a "Name-Value Pair Arguments" section that lists some of the common options like 'Color'. There's also a link in the See Also section at the end of the page to "Line Properties" which shows even more properties you can specify as name-value pair arguments when you call plot (or that you can specify after the line is created.)
At a quick glance, you also have a typo on the line where you define f. You have a comma where you should have a period.
One more note, the decimal separator in MATLAB is period not comma. There is a preference for setting the decimal separator when copying data from MATLAB to the system clipboard, but it has no effect on how data is stored or displayed inside MATLAB. Your meshgrid call confused me until I realized you meant 0,2 to be the double precision number closest to two-tenths. The comma between the 5 and 0 is filling one of its normal roles in MATLAB, separating input arguments being passed to a function.
IGNACIO
IGNACIO 2024년 9월 1일
% Create optimization variables
x = optimvar("x","LowerBound",0);
y = optimvar("y","LowerBound",0);
% Set initial starting point for the solver
initialPoint.x = zeros(size(x));
initialPoint.y = zeros(size(y));
% Create problem
Prueba1 = optimproblem;
% Define problem objective
Prueba1.Objective = (x-3)^2+(y-3)^2;
% Define problem constraints
Prueba1.Constraints = x+y <= 4;
% Display problem information
show(Prueba1);
OptimizationProblem : Solve for: x, y minimize : ((x - 3).^2 + (y - 3).^2) subject to : x + y <= 4 variable bounds: 0 <= x 0 <= y
% Solve problem
[solution,objectiveValue,reasonSolverStopped] = solve(Prueba1,initialPoint,...
"Solver","fmincon");
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
% Display results
solution
solution = struct with fields:
x: 2.0000 y: 2.0000
reasonSolverStopped
reasonSolverStopped =
OptimalSolution
objectiveValue
objectiveValue = 2.0000
% Clear variables
clearvars x y initialPoint reasonSolverStopped objectiveValue

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

질문:

2020년 9월 16일

답변:

2024년 9월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by