I have a connected network where I want to visit a set of destinations which may require visiting intermediate nodes as well because there may be no direct edge between source and destination nodes. I want to visit all destinations including intermediate nodes (not all nodes, only those nodes which help in completing the tour in minimum time). As soon as the last destination is visited, it should give the minimum time to visit the destination, i.e., the source node will not be visited at the end. Each edge in the network is bidirectionally visitable. For example, a network in the following diagram, the source could be $O$ and destinations could be $A$ and $C$:
I have the following mathematical formulation for this purpose.
The objective function is to minimize the total travelling distance from source to all destination nodes which is defined as follows:
$$\min \sum_{(i, j)\in N} T_{ij} x_{ij}$$
The constraints include:
$\sum\limits_{i,j\in\rm Edges} x_{ij} = 1$ where $i$ is a source node;
$\sum\limits_{i,j\in\rm Edges} x_{ij} = 0$ where $j$ is a source node;
$$\sum\limits_{j\in\rm Destinations}\sum\limits_{i,j \in\rm Edges} = \sum\limits_{j\in\rm Destinations}\sum\limits_{j, i\rm \in Edges} - 1$$ for all edges going into the destination nodes, it should be one greater than the last destination;
$\sum\limits_{i,j\in\rm Edges} x_{ij} = \sum\limits_{j,l\in\rm Edges} x_{jl}$ for each intermediate nodes excluding source and destination nodes. It ensures path starts at origin and that each subsequent edge in the path is a continuation from the previous edge.
When I run these constraints in Docplex, it shows an infeasible solution. If I exclude the second $\sum\limits_{i,j\in\rm Edges} x_{ij} = 0$ constraint, it provides the solution as:
O-A
A-O
C-O
The actual solution should be:
O-A
A-B
B-C