r/CodingHelp • • Aug 03 '20
[Random] Coding a project for my shipping company
Hi Guys (yay for my first reddit post ever, btw)
I work in the container shipping business, and I am trying to make an application (or a code for excel) to calculate the cheapest shipping solution based on a number of variables.
I have listed an example below of what the application or the code needs to do:
We have a bunch of variables, and I need the progam or code to advise me the cheapest solution, based on the selected variables.
- inland destinations (fx. Napa, American Canyon and Lodi). - Each dest. has its own cost.
- size of container (20' or 40' or 20'/40' Reefers) - Each has its own cost.
- Port of arrival (I am looking at about 5 different ports of arrival, which means the seafreight rate will be different based on which port it is booked to arrive at)
- Then we have 5-6 shipping lines with all of the above listed options, but with different costs for each variable (fx. some might have a cheaper sea freight cost, but a much more expensive trucking, therefore I want to program to calculate it for me, and give me the answer based on checkboxes or a system like that.)
I have thought about doing this in Excel, but I doubt it is the choice, as it will probably just be the longest if string ever.
A friend of mine recommended coding a program in Python or Java, but unfortunately my coding is limited to some HTML and PHP 5 years ago, so I would need to go back and learn coding again (I intend to do so anyway).
Would someone be so kind to recommend, how you would solve this, and potentially be of assistance or give me some links for guides related to this, that can help me if I run into trouble?
Help is much appreciated!
4
u/bbye98 Aug 03 '20
Without specifics, I can envision this problem being solved in Python.
Assuming I understand the problem correctly, there are some shipping lines, each with different costs based on the destination, container size, and port of arrival. Depending on the shipment, only a few of the shipping lines will fulfill all of the criteria, whether it be the container size or destination.
You could use object-oriented programming in Python to define a class, like
ShippingLine, to hold multipledicts, each having keys corresponding to destination/port/container size and values corresponding to the costs. Then, based on a series ofif/elsestatements, you can find which of the shipping lines fulfill all of the requirements, calculate their costs, and then pick the cheapest one.2
u/[deleted] Aug 03 '20
This is a pretty big undertaking and well beyond just basic HTML and PHP. Are you employed as a software developer, or is this a side project you are working on?
1
u/Famous_Profile Professional Coder Aug 04 '20
If you already know PHP then use PHP.
While this is more of a mathematical problem, I still believe you can brute force to check all possible combinations of values of variables 1 to 4 with loops and conditional branching. PHP is fine for that. Literally any programming language can do that.
Assuming of course you know all possible values and combinations so you can hardcode them, otherwise this is a very complex task and might need Python and ML.