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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Module for implementing Simulated Annealing algorithm for single objective optimization. | |
author := "Daniel Barker" | |
""" | |
import random |
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
# Pseudocode for Simulated Annealing Algorithm | |
while t_new > stopping temp: | |
for number of runs at each temp: | |
x_new, y_new = random neighboring value of x_old, y_old | |
calculate the cost c_new of this neighboring solution | |
if c_new – c_old >= 0: | |
This is a better solution, so move to it | |
else: | |
Calculate the probability of moving to the new worse solution |
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
from __future__ import print_function | |
from apiclient.discovery import build | |
from httplib2 import Http | |
from oauth2client import file, client, tools | |
import pandas as pd | |
import numpy as np | |
import dash | |
from dash.dependencies import Input, Output, State, Event | |
import dash_core_components as dcc | |
import dash_html_components as html |
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 os | |
import dash | |
import dash_core_components as dcc | |
import dash_html_components as html | |
app = dash.Dash(__name__) | |
server = app.server | |
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
from __future__ import print_function | |
from apiclient.discovery import build | |
from httplib2 import Http | |
from oauth2client import file, client, tools | |
import pandas as pd | |
SPREADSHEET_ID = # <Your spreadsheet ID> | |
RANGE_NAME = # <Your worksheet name> |
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 Supporting Libraries | |
import pandas as pd | |
# Import Dash Visualization Libraries | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import dash_table_experiments as dt | |
import dash | |
from dash.dependencies import Input, Output, State | |
import plotly |
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
# Create our app layout | |
app = dash.Dash(__name__) | |
server = app.server | |
app.layout = html.Div([ | |
html.H2('My Dash App'), | |
dt.DataTable( | |
id='my-datatable', | |
rows=df_ag.to_dict('records'), | |
editable=False, | |
row_selectable=True, |
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
""" Sample App Code with Datatable """ | |
# Import Supporting Libraries | |
import pandas as pd | |
# Import Dash Visualization Libraries | |
import dash_core_components as dcc | |
import dash_html_components as html | |
import dash_table_experiments as dt | |
import dash.dependencies |
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
@app.callback(Output('datatable-subplots', 'figure'), | |
[Input('my-datatable', 'rows'), | |
Input('my-datatable', 'selected_row_indices')]) | |
def update_figure(rows, selected_row_indices): | |
dff = pd.DataFrame(rows) | |
fig = plotly.tools.make_subplots( | |
rows=3, cols=1, | |
subplot_titles=('Beef', 'Pork', 'Poultry'), | |
shared_xaxes=True) | |
marker = {'color': ['#0074D9']*len(dff)} |