Not getting the right result for constraint.

75 views
Skip to first unread message

chaitanya tanwar

unread,
Sep 16, 2015, 6:48:56 AM9/16/15
to jsprit-mailing-list
Hi all,
 I am adding a Hard constraint, which is that if the newAct i.e. new job to be inserted is "1" then it should not be the last job services by any vehicle. 

So for now what i am doing is checking if the newAct is "1", then the nextAct should not be "end".



HardActivityConstraint womenSecurityConstraint = new HardActivityConstraint() {

@Override
public ConstraintsStatus fulfilled(JobInsertionContext iFacts,
TourActivity prevAct, TourActivity newAct, TourActivity nextAct,
double prevActDepTime) {
if(((JobActivity)newAct).getJob().getId().equals("1"))
{
if(iFacts.getRoute().isEmpty()||nextAct.getName().equals("end"))
{
return ConstraintsStatus.NOT_FULFILLED_BREAK;
}
}
return ConstraintsStatus.FULFILLED;
}



};

I have two vehicle with "vehicle" and "vehicle1" with capacity 1 and 2 respectively.
But I am getting the wrong output.

[costs=26.0]
[#vehicles=2]
+--------------------------+
| problem                  |
+---------------+----------+
| indicator     | value    |
+---------------+----------+
| noJobs        | 3        | 
| noServices    | 3        | 
| noShipments   | 0        | 
| fleetsize     | FINITE   | 
+--------------------------+
+----------------------------------------------------------+
| solution                                                 |
+---------------+------------------------------------------+
| indicator     | value                                    |
+---------------+------------------------------------------+
| costs         | 26.0                                     | 
| noVehicles    | 2                                        | 
| unassgndJobs  | 0                                        | 
+----------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------------------------+
| detailed solution                                                                                                              |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| route   | vehicle              | activity              | job             | arrTime         | endTime         | costs           |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 1       | vehicle1             | start                 | -               | undef           | 0               | 0               |
| 1       | vehicle1             | service               | 3               | 0               | 0               | 5               |
| 1       | vehicle1             | service               | 1               | 0               | 0               | 6               |
| 1       | vehicle1             | end                   | -               | 0               | undef           | 6               |
+---------+----------------------+-----------------------+-----------------+-----------------+-----------------+-----------------+
| 2       | vehicle              | start                 | -               | undef           | 0               | 0               |
| 2       | vehicle              | service               | 2               | 0               | 0               | 20              |
| 2       | vehicle              | end                   | -               | 0               | undef           | 20              |
+--------------------------------------------------------------------------------------------------------------------------------+


Can someone please check whats the problem?


Thanks and Regards,
Chaitanya Tanwar
   

Zufar Muhamadeev

unread,
Sep 17, 2015, 6:27:29 AM9/17/15
to jsprit-mailing-list
You should check other activities insertion don`t shift first service. Scenario is:
1. Inserted 1 job according to constraint
2. Inserted 3 job before 1 job. All constraint fullfiled.

chaitanya tanwar

unread,
Sep 18, 2015, 1:43:17 AM9/18/15
to jsprit-mailing-list
Thanks for replying. Constraint for 1 is not fulfilled. Job 1 is served as the last job by the vehicle. Job 1's nextAct is "end" only, which should not have happened acc to constraint.

Regards.
Reply all
Reply to author
Forward
0 new messages