Gurobi: Optimization: Learn from Examples

Gurobi: Optimization: Learn from Examples

View the modeling examples:


***. ***. ***
Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Genetic Algorithm, Particle Swarm

From the Internet

Genetic: Python
https://www.youtube.com/watch?v=zumC_C0C25c

Particle Swarm
https://www.youtube.com/watch?v=xPkRL_Gt6PI

Compare:
https://www.frontiersin.org/articles/10.3389/fbuil.2019.00113/full

***
other genetic algorithm tutorials:
Genetic Algorithms w/ Java – Tutorial 01 @ https://youtu.be/UcVJsV-tqlo
Genetic Algorithms w/ Scala – Tutorial 01 @ https://youtu.be/6ngju74tHbI
Genetic Algorithms w/ JAVA + JavaFX – Tutorial 02 @ https://youtu.be/0VijcOA5ZAY
TSP By Genetic Algorithms w/ JAVA @ https://youtu.be/Z3668A0zLCM
Genetic Algorithms Tutorial 04 – Class Scheduling JAVA Application @ https://youtu.be/cn1JyZvV5YA
Genetic Algorithms Tutorial 05 – Robotics JAVA Application @ https://youtu.be/mhtTOp8rWOU
Genetic Algorithms Tutorial 06 – data mining + JAVA 8 + logical operators @ https://youtu.be/Ha9xddd7xTY
Genetic Algorithms Tutorial 07 – data mining + arithmetic operators + JAVA @ https://youtu.be/azdlGExeXKc
Class Scheduling w/ Genetic Algorithm + SQLite DB + JAVA @ https://youtu.be/PQPs-vJuHC0
Genetic Algorithms w/ Python – Tutorial 01 @ https://youtu.be/zumC_C0C25c
Genetic Algorithms Class Scheduling w/ Python Tutorial @ https://youtu.be/8NrNX_jCkjw
Genetic Algorithm + SQLite DB + Python + Class Scheduling @ https://youtu.be/6SDQdx5VLO8

Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Learn: How to formulate an Optimization Problem

Formulating an Optimization Problem

http://macc.mcmaster.ca/maccfiles/chachuatnotes/01-Formulation_handout.pdf

Search Results

Web results

Math 407A: Linear Optimization – University of Washington

: how to formulate

https://sites.math.washington.edu/~burke/crs/407/lectures/L3-LP_Modeling.pdf

Optimization with Examples

https://sites.math.washington.edu/~burke/crs/407/notes/section1.pdf

https://sites.math.washington.edu/~burke/crs/407/notes/section1.pdf
https://sites.math.washington.edu/~burke/crs/407/notes/section2.pdf
https://sites.math.washington.edu/~burke/crs/407/models/

Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Recession and business cycle

Recession and business cycle: "My opinion: we are in recession mode right now. It can be short or it can extend a bit longer depending on how long the pandemic lasts or how quickly the business can recover" https://www.investopedia.com/insights/recession-what-does-it-mean-investors/

Unemployment and recession: https://www.investopedia.com/ask/answers/032515/why-does-unemployment-tend-rise-during-recession.asp

***. ***. ***. ***
Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Python: Read Amex (American Express) Canada: Mastercard PDF Statement Transaction Data into CSV file

Python: Read Amex (American Express) Canada: PDF Statement Transaction Data into CSV file

By Sayed Ahmed

In general, you will get CSV files from your Amex card; However, sometimes you need to download in every 3 or 6 months. Otherwise, you might only get/request pdf files for transactions (depends on the card).

Sure, you can use tools such as Adobe Acrobat (Paid) to convert PDF statements to csv/xls files. This is a simple approach that you might be able to use when you do not have access to any such tools.

Steps:

Download the statements.

Copy the text (only the transactions) into a text file

The use the code provided here or similar to read the text file and create a CSV file

Note:

You can use PDF export software to open pdf file and copy/paste. Acrobat did not give me a good format.

Copy and paste using PDF Export (to open pdf), resulted 5 lines for each transaction. if any transaction (credit adjustment) comes to be 4 lines or 6 lines (foreign transaction), make them 5 lines.

Related:

 
# code will generate both individual csv output files; also a merged file that combines all data into one csv file
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import os;
import glob;
import pandas as pd;
os.chdir(‘./’);
# In[2]:
extension = ‘csv’;
all_filenames = [i for i in glob.glob(‘*.{}’.format(extension))];
# In[3]:
sorted(list(all_filenames))
# In[4]:
os.getcwd();
# In[5]:
# test : Check the data for each csv files to be combined.
# do the data align well with each other
row_total_count = 0
for i in range(0, len(all_filenames)):
j = i + 1
for f in all_filenames[i:j]:
file = f
print(file)
df_s = pd.read_csv(f)
print(df_s.shape, f)
#print(f)
row_total_count += df_s.shape[0]
print(df_s.head(1))
#row_total_count
#df_s.head()
# In[6]:
# keep track of total rows in all files so that you can compare the shape with the final combined data file
row_total_count = 0
for f in all_filenames:
file = f
print(file)
df_s = pd.read_csv(f, header=None)
print(df_s.shape, f)
#print(f)
row_total_count += df_s.shape[0]
#print(df_s.head())
row_total_count
#df_s.head()
# In[7]:
#combine all files in the list, axis =0 i.e. one after another
combined_csv = pd.concat([pd.read_csv(f, header=None) for f in all_filenames], axis=0)
# combined_csv.sort_values(“Model Code”, inplace = True)
# dropping ALL duplicte values
#combined_csv.drop_duplicates(subset =”Model Code”, keep = False, inplace = True)
#export to csv
combined_csv.to_csv( “amex_gold_card_data_combined”, index=False, encoding=’utf-8-sig’)
# In[8]:
combined_csv.shape
# In[9]:
row_total_count == combined_csv.shape[0]
# In[11]:
df = pd.read_csv(‘amex_gold_card_data_combined’)
df.head(3)
# In[12]:
df.shape
# In[ ]:
# In[ ]:

Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***

Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)

MSc. in Comp. Sc. (U of Manitoba, Canada)

MSc. in Data Science and Analytics (Ryerson University, Canada)

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com

Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):

https://www.facebook.com/banglasalearningschool

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Matlab: Optimization Project Examples

You might want to start with Example Projects or Check examples after some theories. Just digging theories more and more might confuse you (or make things look harder) esp. if your goal is to be eventually able to write code for an optimization project. It might help you to understand stuff faster. Sure, dig theories to get clear understanding. For researchers who want to improve (invent) the background technology – clear understanding of theories are a must.

Step 1: Mathematical Modeling with Optimization, Part 1

https://www.mathworks.com/videos/mathematical-modeling-with-optimization-part-1-101559.html

Step 2: Equation to MATLAB. Chart to find what can be a possible solution

https://www.mathworks.com/videos/mathematical-modeling-with-optimization-part-2-68974.html

Mathematical Modeling with Optimization, Part 3: Problem-Based Mixed-Integer Linear Programming

https://www.mathworks.com/videos/mathematical-modeling-with-optimization-part-3-problem-based-mixed-integer-linear-programming-1504298693853.html

Problem-Based Nonlinear Programming

https://www.mathworks.com/videos/part-4-problem-based-nonlinear-programming-1549458887351.html

Unconstrained Optimization Example

https://www.mathworks.com/help/optim/examples/tutorial-for-the-optimization-toolbox.html

Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Python: Generate Expense Report from RBC MasterCard Transaction Data

Python: Generate Expense Report from RBC MasterCard Transaction Data

For the context read the following two first

Python: Read RBC Canada: Mastercard PDF Statement Transaction Data into CSV file

By Sayed Ahmed


medium.com


Python: Merge Multiple csv files into one to facilitate reporting on transaction data over time

By Sayed Ahmed


medium.com

After, you have created the merged i.e. combined csv file, you might want to create reports for your purpose. For example, you can calculate how much was spent on Amazon.ca. The code example will show similar how much was spent on Amazon.ca.

Just by changing the variab;e

spend_calculation_for = ‘AMAZON.CA’;

you will be able to calculate how much was spent on other places such as BestBuy, Ebay or similar. The code is case sensitive; Hence, you need to provide the value exactly for the above mentioned variable.

Statements such as dollar, no_dol_sign_dollar, you might want to use print for them. This code was written in Jupyter Notebook and then was exported to .py file.

#!/usr/bin/env python
# coding: utf-8# In[1]:import os;
import glob;
import pandas as pd;
data_folder = ‘./’;
os.chdir(data_folder);# In[2]:Spend_calculation_for = ‘AMAZON.CA’;# In[3]:df = pd.read_csv(‘to_process_rbc_mastercard_data_combined.csv’)
df.head(3)# In[4]:transactions = df[ df[‘2’].str.contains(Spend_calculation_for) ]# In[5]:dollar = transactions[0:50][‘3’]
dollar = sorted(dollar)
dollar# In[6]:no_dol_sign_dollar = [x.strip(“$”) for x in dollar]
no_dol_sign_dollar# In[7]:no_dol_sign_dollar = [float(x.replace(“-$”, ‘-’)) for x in no_dol_sign_dollar]
no_dol_sign_dollar# In[8]:import math
total_spent = sum(no_dol_sign_dollar)
#sum = sum + [ float(x[1:]) for x in aliexpress_dollar ]
total_spent# In[9]:# just spent without refund
pos_no_dol_sign_dollar = [ x if x > 0 else 0 for x in no_dol_sign_dollar]
pos_no_dol_sign_dollar[0:10]# In[10]:spent = sum(pos_no_dol_sign_dollar)
spent# In[11]:# just spent without refund
neg_no_dol_sign_dollar = [ x if x < 0 else 0 for x in no_dol_sign_dollar]
#if (len(neg_no_dol_sign_aliexpress_dollar)) > 0:
# neg_no_dol_sign_aliexpress_dollar[-1], neg_no_dol_sign_aliexpress_dollar[-2], neg_no_dol_sign_aliexpress_dollar[-3]
neg_no_dol_sign_dollar# In[12]:got_refund = sum(neg_no_dol_sign_dollar);
got_refund# In[14]:total_spent = spent — abs(got_refund);
total_spent# In[ ]:


***
Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

Python: Merge Multiple csv files into one to facilitate reporting on transaction data over time

Python: Merge Multiple csv files into one to facilitate reporting on transaction data over time

Python: Merge Multiple csv files into one to facilitate reporting on transaction data over time

Python: Merge Multiple csv files into one to facilitate reporting on transaction data over time

By Sayed Ahmed

Merge multiple transaction files into one. This is an extension to the article:

Python: Read RBC Canada: Mastercard PDF Statement Transaction Data into CSV file
By Sayed Ahmedmedium.com

The Code for Merging

#!/usr/bin/env python
# coding: utf-8
# In[1]:
import os
import glob
import pandas as pd
data_folder = ‘./’
os.chdir(data_folder)
# In[2]:
extension = ‘csv’
all_filenames = [i for i in glob.glob(‘*.{}’.format(extension))]
# In[ ]:
sorted(list(all_filenames))
# In[3]:
# test : Check the data for each csv files to be combined.
# do the data align well with each other
row_total_count = 0
for i in range(0, len(all_filenames)):
j = i + 1
for f in all_filenames[i:j]:
file = f
print(file)
df_s = pd.read_csv(f)
print(df_s.shape, f)
#print(f)
row_total_count += df_s.shape[0]
print(df_s.head())
#row_total_count
#df_s.head()
# In[10]:
# keep track of total rows in all files so that you can compare the shape with the final combined data file
row_total_count = 0
for f in all_filenames:
file = f
print(file)
df_s = pd.read_csv(f, header=None)
print(df_s.shape, f)
#print(f)
row_total_count += df_s.shape[0]
#print(df_s.head())
row_total_count
#df_s.head()
# In[15]:
#combine all files in the list, axis =0 i.e. one after another
combined_csv = pd.concat([pd.read_csv(f, header=None) for f in all_filenames], axis=0)
# combined_csv.sort_values(“Model Code”, inplace = True)
# dropping ALL duplicate values
#combined_csv.drop_duplicates(subset =”Model Code”, keep = False, inplace = True)
#export to csv
combined_csv.to_csv( “rbc_mastercard_data_combined”, index=False, encoding=’utf-8-sig’)
# In[16]:
combined_csv.shape
# In[17]:
row_total_count == combined_csv.shape[0]
# In[19]:
df = pd.read_csv(‘rbc_mastercard_data_combined’)
df.head(100)
# In[ ]:
df.shape

Final Output

1*j5ET61-3P-l-GTj2pMhePg.png

Posted On:

https://medium.com/@SayedAhmedCanada/python-merge-multiple-csv-files-into-one-to-facilitate-reporting-on-transaction-data-over-time-2e4524355d43

Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***

Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)

MSc. in Comp. Sc. (U of Manitoba, Canada)

MSc. in Data Science and Analytics (Ryerson University, Canada)

Linkedin:

Blog: ,

Training Courses:

Facebook Groups/Forums to discuss (Q & A):

https://www.facebook.com/banglasalearningschool

https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/

GUROBI Optimization: Project Examples

GUROBI Optimization: Functional Code Examples: https://www.gurobi.com/resource/functional-code-examples/

Gurobi Interactive Examples: http://examples.gurobi.com/

*** ***. ***
Note: Older short-notes from this site are posted on Medium: https://medium.com/@SayedAhmedCanada

*** . *** *** . *** . *** . ***
Sayed Ahmed

BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
Training Courses: http://Training.SitesTree.com

Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial

Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/