Skip to content

Instantly share code, notes, and snippets.

View ajaykumarsampath's full-sized avatar

Ajay Kumar ajaykumarsampath

  • Berlin
View GitHub Profile
@ajaykumarsampath
ajaykumarsampath / calculating_flops.m
Last active June 29, 2017 08:19
comparing the total number of flops required with various implementations 1)LBFGS-FBE 2) CG-FBE 3)APG
%% In this scipt we calcualte the maximum and
% average flop counts required with different
% algorithms
clear all;
close all;
clc;
%% Reevaluating the Average gradient and Hessian counts
% LBFGS
AverGrad(1,:)=[84.0426 68.7755 129.750 80.4286...
%% plot figures
result_data=cell(3,2);
gurobi_ip=cell(3,1);
%prediction hoizon
result_data{1,1}=[8 10 30 45;0.1954 0.2042 0.6179 0.8864;0.0419 0.0590 0.1318 0.2052]';
result_data{1,2}=[8 10 30 45;1.1501 1.572 3.6162 5.2541;0.1887 0.221 0.4452 0.7612]';
gurobi_ip{1,1}=[8 10;1.9436 2.7031;2.2394 3.1234]';
figure(1)
/*
* Effinet_data_generation.cuh
* Created on: Jul 26, 2015
* Author: ajay
*/
/*
* This header file has the implementation of the functions that allocate the memory in the
* GPUs.
*/
clear all
syms a b w l r k Q x;
f1=a^2+4*(w*l+r*k-r*k*x)*(b-a)/((1-x)*Q/x);
f=symfun(0.5*(a+...
(a^2+4*(w*l+r*k-r*k*x)*(b-a)...
/((1-x)*Q/x))^0.5),[a b w l r k Q x]);
g=diff(f,x);
%{
result
%%
% This function generates a system with different terminal functions and constraints but
% with same size. The constraint are preconditioned accodingly.
% We solve the method using different methods. First formulated using
% 1) Gurobi-IP 2) Gurobi-AS directly
clear all;
close all;
clear model;
clc;
@ajaykumarsampath
ajaykumarsampath / system_masses.m
Last active August 29, 2015 14:12
Generated the discrete-time system of spring-mass-damper system. Each mass has an input and the masses are connected to wall on both sides.
function [ S ] = system_masses(N, options )
%masses_model function is used to find the dynamic equations of N masses
%system. The no of masses is specified by N and options specify the constraints
%on the system.
% The syntax of the function is
% S=masses_model(N,options)
default_options = struct('M', 1*ones(N,1), 'b', 0.1*ones(N+1,1),...
'k',1*ones(N+1,1),'xmin',-5*ones(2*N,1), 'xmax', 5*ones(2*N,1), 'umin', ...
-5*ones(N,1),'umax',5*ones(N,1), 'Ts', 0.1);
%% MPC
clear all
clear classes
clc
% User-defined parameters:
load('dwn_big.mat');
f0=0.1;
k=3000;
function [ Tree details] = Tree_formation( W,ops)
%This function generates the scenario tree.
%The no of scenatios are reduced by forward selection.
%The input is scenario of random variables
%syntax: [Tree]=Tree_formation(W,ops)
%Input: W: The stochastic varible.
% W=[scenarios,no of varibles,future steps]
% The stocastic variable is considered independent
% ops: This contains the option to the tree
@ajaykumarsampath
ajaykumarsampath / main_file.m
Last active August 29, 2015 14:07
spring-mass damper
clear all;
close all;
clc;
Nm=10; % Number of masses
T_sampling=0.25;
sys_no_precond=system_generation(Nm,struct('Ts',T_sampling,'xmin', ...
-5*ones(2*Nm,1), 'xmax', 5*ones(2*Nm,1), 'umin', -1*ones(Nm,1),'umax',...
1*ones(Nm,1)));