Skip to content

Instantly share code, notes, and snippets.

@MariaLavrovskaya
Created September 27, 2021 13:33
Show Gist options
  • Save MariaLavrovskaya/14dde244b6ea1de93706732656fe72e2 to your computer and use it in GitHub Desktop.
Save MariaLavrovskaya/14dde244b6ea1de93706732656fe72e2 to your computer and use it in GitHub Desktop.
f = @(x) x.^2; %objective
f1 = @(x) 1-x; %inequality constraint
L = @(x,lambda) f(x) + lambda.*f1(x); %lagrangian
g = @(lambda) -1/4*lambda.^2 + lambda; %dual function
%%
[X,Lambda] = meshgrid((-1:0.01:1), (-0.5:0.01:1.5));
alpha = 3; %scale x
beta = 4; %scale lambda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment