Nov 27, 2020

Using Panda and Python/ Anaconda to follow the progression of COVID in different department in FRANCE

The Second version is on my Gitlab account here

Sample Charts




The first Version :

Code:

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

#Population data from : https://www.insee.fr/fr/statistiques/1893198
popEx = pd.read_csv("population_2020.csv",sep=";")
popEx


#datetime  convert based on https://gist.github.com/gjreda/7433f5f70299610d9b6b
from datetime import datetime
#convert from 2020-03-19
to_datetime = lambda d: datetime.strptime(d, '%Y-%m-%d')
#convert from 19/03/2020
to_frDate = lambda dt: datetime.strptime(dt,'%d/%m/%Y')

#données des test PCR issue de santé public
#PCR data from : https://www.data.gouv.fr/fr/datasets/donnees-relatives-aux-resultats-des-tests-virologiques-covid-19/
raw_tests = pd.read_csv("sp-pos-quot-dep-2020-11-26-19h15.csv",sep=";",dtype={"dep":str,"P":int,"T":int}, converters={'jour': to_datetime})
raw_tests["Cas Positifs"] = np.nan
raw_tests["positivity"]= (100*raw_tests["P"])/raw_tests["T"]

#hospitalisation data from : https://www.data.gouv.fr/fr/datasets/donnees-hospitalieres-relatives-a-lepidemie-de-covid-19/
raw_new_hosp=pd.read_csv("donnees-hospitalieres-nouveaux-covid19-2020-11-26-19h03.csv",sep=";",dtype={"dep":str,"incid_hosp":int,"incid_rea":int,"incid_dc":int,"incid_rad":int},converters={"jour":to_datetime})
raw_new_hosp["hosp"] =np.nan # new column used for smoothing the data 

#selected departement
deps=["06","13","38","42","69","75","83"]

for d in deps :
    
    #departement data: population and Name 
    detail_dep = popEx.loc[popEx["dep"]==d, ["Nom_dep","population"]]
    nom_dep=detail_dep.iloc[0,0]
    pop_dep = detail_dep.iloc[0,1]
    print(" Le nom du département est :" + nom_dep +" , et la population en 2020 est estimée à :" + pop_dep)
    
    
    #PCR Test DATA per Departement
    raw_tests_dep = raw_tests.loc[ (raw_tests["cl_age90"]==0) & (raw_tests["dep"]==d),["jour","P","T","Cas Positifs","positivity"] ]
    #check that filtered data is not empty
    if not raw_tests_dep.empty:
        #Smoothing over one week in order to remove weekend distortions
        raw_tests_dep["Cas Positifs"] = raw_tests_dep["P"].rolling(7).mean()
        
        plt.rcParams["figure.figsize"] = [16,9]
        raw_tests_dep.plot(x="jour",y=["Cas Positifs"], title= "Covid dans " + d +"("+nom_dep +")",grid=True)
        plt.show()
        
        plt.rcParams["figure.figsize"] = [8,6]
        raw_tests_dep.tail(45).plot(x="jour",y=["Cas Positifs"], title= "Covid dans " + d +"("+nom_dep +")",grid=True)
        plt.show()
        
        print( d )
        print( raw_tests_dep.tail(10))
    else:
        print( "PCR Tests data for :" +d + " is EMPTY")
        
    #Hospitalisation Data
    raw_hosp_dep= raw_new_hosp.loc[raw_new_hosp["dep"]==d,["jour","hosp","incid_hosp","incid_rea"]]
    if not raw_hosp_dep.empty :
        #Smoothing over one week in order to remove weekend distortions
        raw_hosp_dep["hosp"]= raw_hosp_dep["incid_hosp"].rolling(7).mean()
        
        plt.rcParams["figure.figsize"] = [16,9]
        raw_hosp_dep.plot(x="jour",y=["hosp"], title= "Admissions à l'hopital pour le COVID dans " + d +"("+nom_dep +")",grid=True)
        plt.show()
        
        plt.rcParams["figure.figsize"] = [8,6]
        raw_hosp_dep.tail(45).plot(x="jour",y=["hosp"], title= "Admissions à l'hopital pour le COVID dans " + d +"("+nom_dep +")",grid=True)
        plt.show()
        
        print( "Hospitalisation dans " + d )
        print( raw_hosp_dep.tail(10))
    else:
        print( " The Hospital admissions data for department:" +d + " is EMPTY")




May 13, 2018

Mixed Integer Linear Programming , on Python using Google Optimisation Tools


  1. Install Python 64 bits ( https://www.python.org/downloads/), append the Path windows environmental value by adding the location of python.
    you can also install an IDE like Visual Studio Community, previous known as Visual Studio Express.
    You need the VS Community if you want to compile C++, or C# codes with Google OR tools
  2. Install Google Optimisation Tools using python PIP: (https://developers.google.com/optimization/introduction/installing/binary#installing-on-windows)
    • python -m pip install --user --upgrade ortools
    • But before check that you have the proper version ( python 64 bit and version >3.6 and PIP is higher than 9.01
      • python --version
      • python -c "import platform; print(platform.architecture()[0])"
      • python -m pip --version
  3. Run your first MIP 
    • Or Run the sample Linear Problem:
    from __future__ import print_function
    from ortools.linear_solver import pywraplp

    def main():
      solver = pywraplp.Solver('SolveSimpleSystem',
                               pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
      x = solver.NumVar(0, 1, 'x')
      y = solver.NumVar(0, 2, 'y')
      objective = solver.Objective()
      objective.SetCoefficient(x, 1)
      objective.SetCoefficient(y, 1)
      objective.SetMaximization()
      solver.Solve()
      print('Solution:')
      print('x = ', x.solution_value())
      print('y = ', y.solution_value())

    if __name__ == '__main__':
      main()

Dec 12, 2017

Dad 's glogcuse results

I am playing with google sheets, I a starting to think that Excel have really become a thing from the past.

Any way below are Dad's interactive glucose test in an interactive chart

Apr 22, 2016

Hotel Bravo - The robot


Hotel Bravo One :
Mop Robot base with
arduino chip as motion controller and navigation module
 and Linked to Raspberry Pi ( I call it RasPI) for the communiction and intelligence framwork

For the first try

The first base that I bought is :
http://www.amazon.fr/gp/product/B00A5T3D8W?psc=1&redirect=true&ref_=oh_aui_detailpage_o01_s00

but may be I should buy
http://www.amazon.fr/Provac-RV-2-Aspirateur-Robot/dp/B005EPNUBW/ref=aag_m_pw_dp?ie=UTF8&m=A29AAHUA1K1PCK


On the Intelligence and Communication Level
There is
The RasPI


Wifi Dongle for RasPI
SAMTECH Wireless 802.11b/g/n 150Mbps USB Adapter WiFi LAN Dongle Network
A nano Blutetooth dongle for the raspi
Univers GSM Super NanoTooth Mini Clé USB Bluetooth pour Nokia/HTC/Samsung/Motorola/Sony Ericsson Noir

I bought a combo wifi+ bluetoo doogle ( a bit too big , may be 2 seperate nano dungle are better)
2 in 1 USB2.0 USB 2.0 to Bluetooth v3.0 3.0 + WiFi 150Mbps 150M Wireless LAN Network Ethernet Card Adapter Converter Dongle
Also for the communication a sim reader to be tested on Raspi
SODIAL(R) Lecteur USB de carte Sim du t¨¦l¨¦phone portable Pour SMS vers PC

Hadware Level aka Motion controlor;

either a Nano Arduino

I bought a cheap verion of Nano Arduino for testing
2 de JMT Nouvelle version améliorée Pro Mini Atmega328P 5V / blocs de 16MHz For Electronic Media interactif

And Of couse in order to program the Nano Arduino a chip loader ( to tansfer your file / image / binary) from the pc to the chip
XINTE FT232RL Downloader USB au câble Serial Télécharger câble USBTO232 USB vers USB MODULE TTL Module FT232

For the Arduino distance mesuremeant ultrasound , to test if they have interferance issue
3 de 4-Pin Module à ultrasons HC-SR04 Capteur de mesure de distance pour Arduino


Also on the hardware level , temp and Humidity detection( however it seems that the motion can alter those result to be tested
DHT22/AM2302 Capteur Numérique Température Humidité DC 3.5V-6V

I also in case I want to bypass the communication level , I bought bluetooth  chip for Arduino. I should provide  a wireless access to the motion conrol level
2 de JMT Bluetooth sans fil en forme de série module esclave HC-06 pour Arduino

Apr 15, 2016

C'est bizarre comment certain article chère sont placés a la place produit moins chères et en oubliant de remplacer l'étiquettage



Cas :Leader Price A gardanne - Je crois que ce magasin peut être considéré comme la reference de la mal gestion. S'il faut apprendre la mal gestion il faut que venir pendre des leçons la-bas, des choses a ne pas faire. ( Il chasse les clients un quart d'heure en avance pour qu'ils puissent quitter les lieux a l'heure de fermeture, l’étiquetage c'est optionnel pour eux, il ya de moins en moins de clients mais les file d'attente devant les caisses sont interminables)


C'est systémique il faut se méfier des prix affiché chez eux, s'ils existent déjà.

Le cas de crème de vinaigre balsamique chez Leader Price a gardanne est ( Le prix affiché est de 0€96 mais c'est pour un ancien produit, il fallait lire la description en petite lettre minuscule) mais le  prix payés est de plus que 3 euros et si vous regarder il n'ya aucune etiquette pour un produit a 3 euros.
Meme presque après un mois, toujours c’était le même prix de l'ancien article similaire..



Cas GIFI - Plan de campagne

Et caisse pliante chez Gifi. (prix affiché 3 euros mais ils facturent 4 euros pour les colorés meme si il n'y a pas de prix affiché pour les colorés, il faut deviner que ce n'est pas le meme code barre et peut etre deviner que c'est 4 euros)





Je n'ai pas prix de photo de derriere parce que ce jour , mais quand je suis venu avec la dame qui travaille la bas il n avait rien. ( Et bien sur elle ne voulait rien remboursé, ou accepter que c'est une tromperie de leur part)

Rappel des lois qui concernant étiquetage

Les prix doivent etre affiché, soit un lecteur existe. Mais rien n'est indiqué pour l'etiqutage portant à l'erreur
http://www.cliquedroit.com/l-obligation-de-vendre-au-prix-affich-c20-f76.html


association de consomateurs

https://fr.wikipedia.org/wiki/Organisation_g%C3%A9n%C3%A9rale_des_consommateurs

liste asso

http://www.economie.gouv.fr/dgccrf/Associations-de-consommateurs-des-Bouches-du-Rhone


Sanctions
 la direction de la concu peuvent sanctionner avec des amendes administratives publiés.
http://www.economie.gouv.fr/dgccrf/sanctions-protection-economique-des-consommateurs

Tromperie ( 300k + 2 ans de prison)
http://www.economie.gouv.fr/dgccrf/Publications/Vie-pratique/Fiches-pratiques/Tromperie

Mar 12, 2015

Remote controlled servo

To do link to the components 
 2 atmega or arduino ....
2 RF24 for sending And receiving Data packets
A servo
And a potentiometer 


I experimented with different version, the version with a separated files one for the transceiver and one for the receiver is the one that is working properly.


The uno used as transmitter 

Tho pro mini used as a receiver , powered by a Usb backup

Mar 31, 2012

you are killing your grandchildren

comments on the bbc video on nice
" Old Ladie wanted an extramly expensive treatement in order to gain 6 months with her grandchildren , saying that she paid taxes all her life
TBD


----------U S case ---------------

Worst case sytem and less effective and the most expensive.

the us is nb one in responsiveness:

-- or resphnsive of usual care that is not used coz it's too expensive , hence most of the people

The goverment for dummies ( the police on a intersection)

game theory , ( nash / selfish ) vs optimal vs worst

perto or something similar example.

- nash = liberal , socialism = introsive gove , communism = optimal , dictatorship = only to one part of the

Diamonds in a pile of shit vs shit warped with a fancy golden paper

Neverthe lesss tThere is different types of bullshit:

pure shit in a systematic way ( ISO of of the protein milk factories)

part of the data without of anallysis ( data without analysis.., whats the usua care, what is the intervention.., money wasted for nothing)

bla bla bla for nothing ( how to lie with statistics

---
my self : put the diamonds link them with shit


Mar 22, 2012

Copy a pdf table into excel

In the last couple of weeks, I was searching for some evidence in the literature related to resource usage in telemonitoring. And part of this job consisted on copy pasting table from PDF(I recommend using Foxit reader instead of Adobe reader ) to word. And believe me it’s not that as easy as you might think. In some cases, MS word can do most the work by converting the text into a table ( option 1), but in some cases the formatting of the original data is so distorted that even word cannot sort it. That why, I have written the following VBA code (option 2) to be added to excel (It could be useful in certain circumstances, and easily tweaked according to the original data).


Option 1 : use word convert text to table option :


Option 2
: Add this vba script replacing the space by comma ( from the end of the line)

Function TestingRev(inputStr As String) As String

Dim nbCol As Integer
nbCol = 4

Dim revInputStr As String
revInputStr = StrReverse(inputStr)

Dim ret As String

ret = Replace(revInputStr, " ", ";", 1, nbCol - 1)

TestingRev = StrReverse(ret)

End Function

- Copy paste the result in notepad and save it as *.csv file
- Open the csv file in excel and save it as

Feb 25, 2012

Il faut vraiment changer les elections presidentielles

video des election des souris:










Dans son article " Les fautes faite par les politiciens (Mistakes Politicians Make)" , Professeur en politique a l’université de Princeton, défend l' hypothèse que la cause principale pour laquelle les politicians commaient et continuerons a commettre les meme erreurs les uns comme les autres c'est la pression pour les réélections. Même si dans son articles ils n'abordent pas le problème des lobby d'argent qui sont essentielle pour touts les candidats. Je partage son avis que tous les politicitiens se sent obliges de prendre des mesure populistes et le court terme pour assurer leur reecltion.
J'ai toujours admiré le fonctionnent du régime chinois (le fonctionnement et non pas le régime) ou tout les présidents sont des cadres / ingénieurs pragmatiques qui sont élues pour des objectifs et non pas pour des slogans et il savent qu'a la fin de leur mandats ils seront évaluer selon ces objectives; par exemple ils se soucis que a la croissance qu'a des problèmes électoraux et n’hésite pas a prendre des mesures non populaires si ces mesures leur permette accomplir leur objectifs. Imaginer la réaction, si un président occidentale déclare un jour qu il étudie la possibilité d'appliquer la politique du fils unique dans son pays, juste le fait d'annoncer une telle idée serait équivalant a un suicide politique pour lui et son parti aussi.

J'aimerais conclure par un petit passage sur le crise grecque qui ma marqué:
Depuis le premier plan de « sauvetage », la dette grecque est pourtant passée de 263 milliards en 2008 à 355 milliards en 2011. Le PIB s’est effondré de 233 milliards à 218 milliards. Le chômage a explosé de 8% à 18%. La récession est massive, et avec un taux d’intérêt officiel à 32%, il va de soi que la Grèce ne peut absolument plus se financer sur les marchés financiers. L’Euro tue la Grèce, mais la Grèce doit coûte que coûte demeurer dans l’Euro !


puis ce que je crains que la même situation peut se reproduire dans d'autre pays notamment le notre si on continue a elire nos presidents, senateurs et deputes de la meme facont

Feb 3, 2012

Dynamic programing and the knapsack problem.

As I always forget the structure of a dynamic algorithm, this note is a reminder of the key idea behind the dynamic knapsack programming.

The knapsack problem is when we consider a large set of object having different size and value, knowing that the knapsack have a fixed size (S) the objective is to pack the subset that give the highest value ( to simplify the problem , lets say it Thief that have to choose which valuables to put in his bag)

Let vi be the value of the object i and si the size of the object i.

1- The first key idea is that the items are sorted by efficiency with is the price of an item divided by its size , in a decreasing order (most efficient to the worst efficient).

P1/s1 >= p2/s2 >= p3/s3 .......

2- The second key idea is related to space of solution, where the set of object to be considered is incremented gradually, following the order of the efficiency of objects. So N1={obj1} , N2={obj1 , obj2} .....

3- And the main idea to solve the sub knapsack problem of the size Z <= S and considering the sub space of solution Ni we need 2 values:

· The max benefit that we can get from the knapsack Z considering the for the subset Ni-1

· The max benefit that we can get from the knapsack (Z-si) considering the for the subset Ni-1

Therefore, if the max benefit from the knapsack Z-si added to the value pi is higher than knapsack Z for the solution space compose from the subset Ni-1, then the solution would be to add the item i to the set of object selection in the knapsack Z-si. If not the solution for the intermediate knapsack Z / Ni would be the solution knapsack Z / Ni-1.


......

Jan 16, 2012

Comments on TED videos

I usually check ted videos but as I have a weak memory with name it's not easy give the link to somebody else , so I decided that for each talk that I consider important to add a link with a small discription:

Wirless devices , patch to monitor , vitals signs , sleep, BR, .... He is part of the Wireless medical institue.


Jun 13, 2011

Configure Visual studio C++ 2008 express edition with IBM Ilog Cplex and Concert libraries

I posted a couple of days ago , a Makefile for C++ project using IBM-ILOG cplex solver and the Concert library. So I thought I should do the same thing for the windows guy. First you ll need a Visual studio, i recommend VS 2008 C++ express edition, why speeding your money on a non worthy C++ editor, ( I ll try to configure netbeans on windows to bypass the VS )
First you need to create an empty C++ application

1 - Then you go to your project Menu and choose properties.




2 - In the configuration manager, change the configuration from debug mode to Release ( If you are going to use concert ; you have to program without debugging as it uses macros incompatible with the debug flags that the compilor add to your code), that the price that you have to pay with concert it's a double eddged sword. You write less code, but if you have an error you have to start guessing and trust me you could loose a lot of your time guessing and trying to figure out what went wrong.





3- You need to change compiler flags ( aka C/C++ in the configuration settings)

In order to use any C++ library you need the library itself .lib and the Header files (*.h or *.hpp). The lib 's header files indicate the compiler to the content of the lib file( a sort of Table of content). So when you compile your code, the compiler only check if the function you are calling figures in the header files and that you are using the proper argument to make the call. After the compilation of your cpp files into object files , the assembler / linker will link your compiled code (*.o) with acttuel function in the lib and produce the executable.

In our case we need to tell the compiler the path to the header files for cplex and concert libs .So you will need to add the path in the Additional Include Directories. you can use the small button on the path line to choose via explorer the directories. ( there is two include folders that you need: the cplex include folder and another include folder in the concert folder )




4-Disable the debug information format ( It could be that it's not required any more)




5 -Add IL_STD to the preprocessor definition ; it's the equivilant of -D in gcc , you can a define IL_STD at begining of your main file; i didn't check the files in the cplex include directory to see exactly what is the effect of this option . And also It could be that its not used any more




6-I don't remmeber why, but I usually choose MT as a Runtime library and in the next section I choose the library in the in stat mta ( I could be wrong , may be you can check if there is any impact on the speed of the execution )




7 - After the compilation you need to assamble your code. The linker wil assemble all the .o files into an executable and will need the libraries that you are calling to make the final excutable. You need to add to the Additional Dependencies in Input section of the linker , the exact location of you cplex library and concert + winsoc32 lib

In my case I had to add the following line :
wsock32.lib
C:\ILOG\CPLEX_Studio_AcademicResearch122\cplex\lib\x86_windows_vs2008\stat_mta\cplex122.lib
C:\ILOG\CPLEX_Studio_AcademicResearch122\cplex\lib\x86_windows_vs2008\stat_mta\ilocplex.lib
C:\ILOG\CPLEX_Studio_AcademicResearch122\concert\lib\x86_windows_vs2008\stat_mta\concert.lib



Tip Use ( use the windows explorer aka my computer ) , browse to the folder in question then right click on folder hiearchy satuts bar and copy the path


Jun 12, 2011

Use the send mail to send the results from the server

I was trying to find a way to send the results of the calculation done on a server to my email
I found this code this code on this post from ambikeh: http://www.unix.com/302072420-post2.html for more info on the send command http://linux.about.com/od/commands/l/blcmdl8_sendmai.htm

But i need to say that i didn t have time to test it

( cat << ! FROM : $FROM To : $TO Subject : ${SUB} Cc : ${CC} ! cat << ! HOPE THIS WORKS Test123 This sample E-mail message with the Unix sendmail utility. ! #uuencode ${1} ${1} ! ) | /usr/lib/sendmail -vt

Jun 11, 2011

bash script to check if a file or a folder exist

This is a cool , I always wanted to know how to check if a file exist or not ( could submited by monk on this link http://nixcraft.com/shell-scripting/93-script-how-check-if-file-exists.html )

files="/dev/MAKEDEV /etc/makedev.d /usr/sbin/mksock"
# $i will hold single file at a time in following loop
for i in $files
do
if [ ! -f $i -o ! -d $i ]; then
exit 1
fi
done


As I was writing shell code I ll add also some links to a bash scripting manual and another for reguraler exprssions , I have a think head but i have a tendency to complety forget who the regex work , you have to admit that cobol people gave us the worst heritage ever
For the shell scripting you can you can start from here : http://www.freeos.com/guides/lsst/
For the reg ex ( mainly sed and grep ) check this link : http://www.bsd.org/regexintro.html, for sed http://www.grymoire.com/Unix/Sed.html

Map and synchronize a local directory and distant shared directory

Map a drive

To Map a distant shared folder or even a local one using Dos command prompt

Open a command prompt and lauch this command

For a local directory



subst Q: "C:\Documents and Settings\hb\"



For a shared directory on a different machine



subst z: "\\Shared Server\hb\My Documents"


Synchronize two folder

To do sync to folder , we will you a great command, that microsoft incorporated as an external command and it's the "xcopy" , I am pretty sure that microsoft bought the company that developped this tool ; as they did with the excel .
For more info on xcopy or the list of external command visit this site that i recommand to visit from time to time http://www.computerhope.com

now back to how to sync the folder ; you create a batch file let's call it sync.bat
and add those two line and xcopy will do every thing for you


xcopy "c:\localfolder" "q:\remotefolder" /S /Y /D
xcopy "q:\remotefolder""c:\localfolder" /S /Y /D



Run the batch file and tadah its a miracle ; the data of the two folder will be merged and they and folder will become an image for one another.

Scheduele automatic sync

Instead of manually running the sync.bat , we can ask the scheduler to execute it every day by using the at command for more information on the at command and some tweaks check this site : http://ss64.com/nt/at.html


at 00:10 /every:M,T,S sync.bat


but due to some user previleges problem as the local system runinng the scheduele don't have the rights to access a remote directory
use the graphical interface to add a task on the win scheduler

Jun 10, 2011

A clean MakeFile for a C++ project using ILOG Cplex + Concert Library

Most of people that want to create IBM - ILOG Cplex project using C++ on linux, they take a file in the example directory of Cplex and copy paste it in the same example directory and then add a new entry in the Makefile as they are adding a new example.


But if you what to create a clean project an a separate directory you have to create your own Make File here is an example Make file that I did , it will automatically scan the (Source file directory )

Here is the architecture of the normal C++ in my sense ( it would be better to have header files in a separate directory, but I started the project using Visual studio on windows)


Project Directory
|__ MakeFile
|__Exe
|__src (dir)
| |__cpp(dir)
| |__ CPP Files + H Files
|__obj(dir)
|__data(dir)
|__ *.dat ; *.xml ;*.mps Files ( The instances of the problem that you want to test)



Of course you can add separate include directory but I put my Header files with the sources (sorry again for that it’s partially the VS fault ) but in the Makefile its already build to have a separate header Files .


You need to change the EXDIR and point it to where you want build the executables and run them.

If you are using 64 bit machine or itanium you can change the SYSTEM for x86_sles10_4.1, you can find this value in the make file in the cplex example direcory.

And also you need to change the ILOGSTUDIODIR to where you have installed ILOG.

NB: Dont forget to change the envirnment variable and add the path for the ILM.

You should update your ./bash_rc file and and something similare to : (watch out for the architecture 32 or 64 and change the library path accordinly
export ILOG_HOME=/home/balbaki/ILOG/CPLEX_Studio_AcademicResearch122

export LD_LIBRARY_PATH=$ILOG_HOME/cplex/bin/x86-64_sles10_4.1/:$LD_LIBRARY_PATH

export ILOG_LICENSE_FILE=/home/balbaki/ILOG/ILM/access.ilm


This make file was build for the IBM -ILOG Cplex v 12.2 but i think it should work on the previous versions as well

#===========================MakeFile==============================
# For Cplex + Concert Projects
# by Hassan Baalbaki www.hassanbaalbaki.com
#================================================================


SYSTEM = x86_sles10_4.1
LIBFORMAT = static_pic

EXDIR = /home/hb/dev/GlobalPlanner/MIP

#------------------------------------------------------------
#
# When you adapt this makefile to compile your CPLEX programs
# please copy this makefile and set CPLEXDIR and CONCERTDIR to
# the directories where CPLEX and CONCERT are installed.
#
#------------------------------------------------------------
ILOGSTUDIODIR =/home/hb/ILOG/CPLEX_Studio_AcademicResearch122
CPLEXDIR = $(ILOGSTUDIODIR)/cplex
CONCERTDIR = $(ILOGSTUDIODIR)/concert




# ---------------------------------------------------------------------
# Compiler selection
# ---------------------------------------------------------------------

CCC = g++
CC = gcc
JAVAC = javac

# ---------------------------------------------------------------------
# Compiler options
# ---------------------------------------------------------------------

CCOPT = -m32 -O -fPIC -fexceptions -DNDEBUG -DIL_STD


# ---------------------------------------------------------------------
# Link options and libraries
# ---------------------------------------------------------------------

CPLEXBINDIR = $(CPLEXDIR)/bin/$(BINDIST)
CPLEXLIBDIR = $(CPLEXDIR)/lib/$(SYSTEM)/$(LIBFORMAT)
CONCERTLIBDIR = $(CONCERTDIR)/lib/$(SYSTEM)/$(LIBFORMAT)

CCLNFLAGS = -L$(CPLEXLIBDIR) -lilocplex -lcplex -L$(CONCERTLIBDIR) -lconcert -m32 -lm -pthread



all:${DIRS}
make all_cpp

execute: all
make execute_cpp


CONCERTINCDIR = $(CONCERTDIR)/include
CPLEXINCDIR = $(CPLEXDIR)/include

#EXINC = $(EXDIR)/include
EXINC = $(EXDIR)/src/cpp
EXDATA = $(EXDIR)/data
EXSRCCPP = $(EXDIR)/src/cpp


CFLAGS = $(COPT) -I$(CPLEXINCDIR)
CCFLAGS = $(CCOPT) -I$(CPLEXINCDIR) -I$(CONCERTINCDIR)


#------------------------------------------------------------
#
#Build and Execute directory
#
#------------------------------------------------------------



INC_PATH = $(EXSRCCPP)
SRC_PATH = $(EXSRCCPP)
OBJ_PATH = ${EXDIR}/obj



SOURCES = ${wildcard ${SRC_PATH}/*.cpp}
OBJECTS = ${patsubst ${SRC_PATH}/%.cpp, ${OBJ_PATH}/%.o, ${SOURCES}}


INCLUDES = -I${INC_PATH}

DIRS = ${OBJ_PATH}


#------------------------------------------------------------
# make all : to compile all.
# make execute : to compile and execute some instances
#------------------------------------------------------------



CPP_EX = globalplanner




all_cpp: $(CPP_EX)


execute_cpp: $(CPP_EX)
./globalplanner $(EXDATA)/small.dat 3




# ------------------------------------------------------------

clean :
/bin/rm -rf *.o *~ $(OBJ_PATH)/*.o
/bin/rm -rf ${SRC_PATH}/*~
/bin/rm -rf $(CPP_EX)
/bin/rm -rf *.mps *.ord *.sos *.lp *.sav *.net *.msg *.log *.clp

# ------------------------------------------------------------
#
# The Cpp and *.o Files
#


all: ${DIRS} globalplanner

${OBJ_PATH}:
mkdir -p $@


${OBJ_PATH}/%.o : ${SRC_PATH}/%.cpp
$(CCC) ${INCLUDES} -c $(CCFLAGS) $< -o $@

globalplanner: ${OBJECTS}
$(CCC) $(CCFLAGS) $^ -o globalplanner $(CCLNFLAGS)


# Local Variables:
# mode: makefile
# End:


#======================== END OF MakeFile =========================

The easiest way to run an executable that take as entry files that are on another directory



This tutorial is for shell - unfamiliar people; it unable them to run; on the command prompt a program that take as an input a file that is on different directory. (If you know how to use cd .. ) this tutorial isn't for you. But it could accelerate the process if you don't want to type a long command each type if you have multiple sub directory between the executable and data file.




Let’s say we have this architecture for a program called hello and it takes as input the data1.dat that is in a sub directory



C:\>
|__hello (dir)
|__hello.exe
|__data(dir)
|__data1.dat

First you create in you data folder a shortcut to the executable:
1- Go to data Folder and right click
2- Choose to new -> Shortcut

3- Browse to the location of your executable (hello world)


4- Finish the process
5- Right click on the newly create link and go to properties
6- Empty the field Run In. (it is c:\hello\) delete it.

Create a cmd shortcut
One last thing create also cmd shortcut in the data directory if you don't want to type cd each time

1- Go to data Folder and right click
2- Choose to new -> Shortcut


3- Type cmd in the path and then click on next then finish




4- Also you should Right click the link and empy the field Run




To run the program :

Click on the (cmd) link that you created and the command prompt should pop up , Type the name of the link to you executable then the name of your data input file .
In this case it should be
C:\hello\data> hello.exe.lnk data1.dat
NB : I know that in this case we can also time ..\hello.exe data1.dat but this example was written to help the people that are unfamiliar with shell and the data is in sub -sub-sub directory

May 25, 2011

How to install Netbeans IDE , with c++ compilors for the SOC-RAD project

Installation On windows

Before installing the IDE - ( Net beans ) , and the project itself , you should

  1. Install a c++ compiler and debugger and make
  2. Check if java JRE is installed on your machine and installed it otherwise.
  3. Install Netbeans from www.netbeans.org

Or 2’- Install the bundle netbeans + jdk from oracle site : http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html

4-Download the source files and create a project.


Part I : Install the gcc and gdb and make:

First I recommend MinGW instead of Cgwin .

**To check if it’s installed

  1. type cmd in the Run command
  2. In the Command prompt opened type the following command “g++- v “ if you don’t get an error that means it’s installed you don’t need to install the c++ compiler
  3. In the Command prompt opened type the following command “make –v” if you don’t get an error that means it’s installed you don’t need to install the MSYS.

If you want to install it the hard way / manually follow this link : http://www.mingw.org/wiki/InstallationHOWTOforMinGW

If not do the simple way and use the installer :

http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/

1. Download the latest version

2. Choose the default settings till you arrive the check list

3. You should check from the chck list C++ compiler ( g++ ) and ) and the developer kit that includes MSYS ( make)

4. Update : the Path

4.1. Right-click on "My Computer" and select "Properties".

4.2. Click Advanced -> Environment Variables. (Avancé -> variables d’environnement)

4.3. In the box entitled "System Variables" scroll down to the line that says "PATH" and double-click the entry.

4.4. You will be presented with a dialog box with two text boxes, the bottom text box allows you to edit the PATH variable. It is very important that you do not delete the existing values in the PATH string, this will cause all sorts of problems for you!

4.5. Scroll to the end of the string and at the end add ;C:\MinGW\bin;C:\MinGW\MSYS\1.0\bin; (if you kept to the recommended default installation directory). Don't forget the semicolon; this separates the entries in the PATH.

4.6. press OK -> OK -> OK and you are done.

5. After the installation open and new cmd and check if g++ and make are installed ( see above the ** section)

Part 2 : JDK / JRE (Check the option part 2’)

First JRE , stands for java run time environment , and if you are using the new terminology of oraclem it’s called “ java 6 “

To check if it’s installed

  1. type cmd in the Run command
  2. In the Command prompt opened type java- version

You should get the version of your java runtime,

if not go to ( http://www.java.com/en/download/help/index.xml or http://www.java.com/en/download/manual.jsp#win :) and install it ( I recommend also to install the JDK / SDK ( stands for java development kit : ) , if you are planning to develop java programs , you ll only loose some disk storage space.-

Part 3: Install Netbeans

Download the netbeans from the following link

http://netbeans.org/downloads/index.html

Of course choose either the full version or the C++ version.

Part 2’ : Install the the bundles JDK+netbeans :

Oracle now, on their site they offer a bundle of jdk + netbeans ( but in this version usually you should install the C++ plugings )

  1. Go to the following link and download the bundle at : http://www.oracle.com/technetwork/java/javase/downloads/jdk-netbeans-jsp-142931.html
  2. Once installed , got the tools menu and then go to plugins
  3. If C/C++ does not figure in the installed tab , go the available plugins tab and check the C/C++ plugins and then install .

Part 4: Create and install the project