473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

coding in CPLEX (from a mathematical model)

1
Hi,

i have some doubts related to a CPLEX code that i'm trying to write. The code itself (model) seems to be well written, but when it comes to fill the data i have an error. ***NOTE: there are no constraints in the model because i'm trying to make a trial of the model just to see that it works.***

Here is the code:

using CP;

// NETWORK+PARAMETERS

int trucks=...;
range truck= 1..trucks;

int capacity [truck]=...;

tuple nodeinfo {
string name;
int starttime;
int endtime;
float demand;
}

{nodeinfo} departurenode=...;

{nodeinfo} arrivalnode=...;

{nodeinfo} startingnode=...;

tuple arc {
nodeinfo departurenode;
nodeinfo arrivalnode;
nodeinfo startingnode;
int traveltime;
}

{arc} arcs=...;

float cost [arcs][truck];

// VARIABLES

dvar boolean x [arcs,truck];

dvar int+ arrivaltime [arrivalnode,truck];

// OBJECTIVE FUNCTION

dexpr float totalcost =
sum (i in arcs, j in truck) x [i,j] * cost [i,j];

minimize totalcost;

// CONSTRAINTS

subject to {}

execute {
writeln(arcs);
};

Here is the data:

trucks= 2;

departurenode= [[A,0,10000,0],[B,0,10000,0],[C,0,10000,10],[D,0,10000,10]];

arrivalnode= [[A,0,10000,0],[B,0,10000,0],[C,0,10000,10],[D,0,10000,10]];

startingnode=[[A,0,10000,0],[B,0,10000,0],[C,0,10000,10],[D,0,10000,10]];

arcs= [[<A,0,10000,0>,<A,0,10000,0>,<C,0,10000,10>,5], [<A,0,10000,0>,<A,0,10000,0>,<D,0,10000,10>,5],
[<B,0,10000,0>,<B,0,10000,0>,<C,0,10000,10>,5], [<B,0,10000,0>,<B,0,10000,0>,<D,0,10000,10>,5],
[<C,0,10000,0>,<C,0,10000,0>,<A,0,10000,10>,5], [<C,0,10000,0>,<C,0,10000,0>,<B,0,10000,10>,5],
[<D,0,10000,0>,<D,0,10000,0>,<A,0,10000,10>,5], [<D,0,10000,0>,<D,0,10000,0>,<B,0,10000,10>,5]]

***NOTE: in each gap of the arc before the travel time (last gap value=5) must be the data from departurenode, arrival node and startingnode but it's not shown and i don't know why ***


cost= [<1,1>,<1,1>,<1,1>,<1,1>,<1,1>,<1,1>,<1,1>,<1,1>]

Another doubt: regarding the constraints of the model i don't know how to write them into CPLEX.

1) starttime <= arrivaltime <= endtime //(for each arrivalnode)

2) x * (arrivaltime (node i) + traveltime) <= arrivaltime (node j)

3) Initialize the variable arrivaltime for each truck to 0. (at the beginning of the simulation)

4)The demand for each arrival node has to be equal to the sum of (the arcs chosen * capacity of the truck)

Thank you so much.
Jul 9 '18 #1
0 1346

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: pysim | last post by:
Hi, I have a couple of general requests for pointers to python examples and design advice. I'm looking for examples of MVC-based GUI controls done in python (model-view-controller). Also,...
27
by: Stuart Gerchick | last post by:
C++ Coding Standards : 101 Rules, Guidelines, and Best Practices by Herb Sutter, Andrei Alexandrescu is now a month or so away from release. What is people's opinion on this...is it going to be a...
8
by: Eric Phetteplace | last post by:
Hello, I am moving over from using msxml2.domdocument to system.xml and system.xml.xsl. I'd like to present this to my group today, so your help is appreciated. I want to transform an XML...
1
by: Damon Allison | last post by:
Hello, My program is being sent a large XML file, anywhere between 500k - 1MB. Of the entire file, I need to allow a user to view/edit approximately 5% of it. To make matters a bit more...
7
by: Ralph Lund | last post by:
Hi. I am starting a new project with C#. I am searching for "good" coding conventions. I know that there are some coding conventions from microsoft, (but they are very extensive and not clear)....
6
by: Robert W. | last post by:
I'm building my first major C# program and am try to use best practices everywhere. So I've implemented the "Document/View Model" whereby: - There's a Windows Form, which we'll call "formView" -...
2
by: Rod | last post by:
I want to manipulate a spreadsheet from within dotnet (using VB). I cant figure out how to get started. i.e. what is the equivalent to the VBA code On Error Resume Next Set objExcel =...
12
by: Doug | last post by:
Hi, I learned a little about the model view presenter pattern at a conference this last week and am experimenting with it. It's working pretty well but I have a question. I am trying to use...
2
by: Steve | last post by:
Hi guys, I was wondering what tools people are using to generate code from UML models in .NET? I know that there is a class designer in VS which is great (since it is effectively another view...
3
Fary4u
by: Fary4u | last post by:
Hi i'm just accessing value from the database & it's text filed when i'm display into browser it's displaying 1 extra value which is like this Stored in Database: Save: £ Displaying in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.