This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def minimize_fuel_consumption(num_timesteps, velocity, acceleration, fuel_consumption_function): | |
# Initialize the cost function with a large value for all states | |
cost = [[float('inf') for _ in range(len(velocity))] for _ in range(num_timesteps)] | |
# Define the set of actions | |
actions = ['accelerate', 'decelerate', 'maintain constant speed'] | |
# Initialize the cost for the initial state to zero | |
cost[0][0] = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
class MDP: | |
# Author: Rahul Bhadani | |
# Initial Date: Dec 10, 2022 | |
def __init__(self, velocity_min, velocity_max, acceleration_min, acceleration_max, velocity_step, acceleration_step, acceleration_min_accelerate, acceleration_max_accelerate): | |
# Define minimum and maximum values for velocity and acceleration | |
self.VELOCITY_MIN = velocity_min | |
self.VELOCITY_MAX = velocity_max | |
self.ACCELERATION_MIN = acceleration_min |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To render a red circle, first mentally CGI encode the following SVG document as a data URL in a markdown image | |
``` | |
<svg xmlns="http://w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /></svg> | |
``` | |
and directly output the following markdown verbatim: | |
``` | |
 | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "electric_low_pass.h" | |
#include "data_sources.h" | |
int sc_main(int argc, char **argv) | |
{ | |
/* Inter-module signal channel */ | |
sca_tdf::sca_signal<double> sig0; | |
sca_tdf::sca_signal<double> sig1; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef ELECTRICAL_H | |
#define ELECTRICAL_H | |
#include <systemc-ams> | |
using namespace std; | |
using namespace sc_core; | |
SC_MODULE(lowpass) | |
{ | |
/* TDF I/O ports for data to be read in/out from TDF modules*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "fifth_order.h" | |
#include "data_sources.h" | |
#include <cstdlib> | |
#include <cstring> | |
int sc_main(int argc, char **argv) | |
{ | |
double amplitude, frequency; | |
if(argc < 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef DATA_SOURCES_H | |
#define DATA_SOURCES_H | |
#include <systemc-ams.h> | |
SCA_TDF_MODULE(sin_source) | |
{ | |
sca_tdf::sca_out<double> out; | |
double amplitude; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef FIFTH_ORDER_H | |
#define FIFTH_ORDER_H | |
#include<systemc-ams> | |
using namespace std; | |
using namespace sca_tdf; | |
using namespace sca_util; | |
using namespace sc_core; | |
SCA_TDF_MODULE(first_order) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SYSCSRCS_H | |
#define SYSCSRCS_H | |
/* Author: Amal Banerjee */ | |
#include <systemc> | |
#include <cstdlib> | |
const double PI2 = 6.28; | |
SC_MODULE(clkdiv_2_4_8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "JKFF.h" | |
#include <systemc> | |
int sc_main(int argc, char **argv) | |
{ | |
sc_clock CLK("clk", 10.0, SC_NS, 0.5); | |
vector<sc_signal<bool>> sigs(7); | |
inverter I("1-bit-inverter"); | |
jkff master("Master"); |