// Path: heuristicsearch/src/main/java/xyz/thepathfinder/routing/domain/RoutingSolution.java
// @PlanningSolution
// public class RoutingSolution implements Solution<HardSoftLongScore> {
// 
//     HardSoftLongScore score;
//     List<Transport> transportList;
//     List<CommodityAction> commodityActionList;
// 
//     @Override
//     public HardSoftLongScore getScore() {
//         return score;
//     }
// 
//     @Override
//     public void setScore(HardSoftLongScore score) {
//         this.score = score;
//     }
// 
//     @Override
//     public Collection<? extends RouteAction> getProblemFacts() {
//         List<RouteAction> routeActions = new ArrayList<>();
//         routeActions.addAll(transportList);
//         routeActions.addAll(commodityActionList);
//         return routeActions;
//     }
// 
//     @PlanningEntityCollectionProperty
//     @ValueRangeProvider(id = "transportRange")
//     public List<Transport> getTransportList() {
//         return transportList;
//     }
// 
//     public void setTransportList(List<Transport> transports) {
//         transportList = transports;
//     }
// 
//     @PlanningEntityCollectionProperty
//     @ValueRangeProvider(id = "commodityActionRange")
//     public List<CommodityAction> getCommodityActionList() {
//         return commodityActionList;
//     }
// 
//     public void setCommodityActionList(List<CommodityAction> commodityActions) {
//         commodityActionList = commodityActions;
//     }
// }


import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import xyz.thepathfinder.routing.domain.RoutingSolution;
package xyz.thepathfinder.routing.service;




@Path("/")
public class RoutingService {
    Logger logger = LoggerFactory.getLogger(RoutingService.class);

    public static final String SOLVER_CONFIG = "xyz/thepathfinder/routing/solverconfig.xml";

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public ProblemSolution solveProblem(ProblemDescription problemDescription) {
        logger.info("Received request to route: " + problemDescription);
        SolverFactory solverFactory = SolverFactory.createFromXmlResource(SOLVER_CONFIG);
        Solver solver = solverFactory.buildSolver();
        RoutingSolution routingSolution = problemDescription.createEmptyRoutingSolution();
        solver.solve(routingSolution);
// Path: heuristicsearch/src/main/java/xyz/thepathfinder/routing/domain/RoutingSolution.java
// @PlanningSolution
// public class RoutingSolution implements Solution<HardSoftLongScore> {
// 
//     HardSoftLongScore score;
//     List<Transport> transportList;
//     List<CommodityAction> commodityActionList;
// 
//     @Override
//     public HardSoftLongScore getScore() {
//         return score;
//     }
// 
//     @Override
//     public void setScore(HardSoftLongScore score) {
//         this.score = score;
//     }
// 
//     @Override
//     public Collection<? extends RouteAction> getProblemFacts() {
//         List<RouteAction> routeActions = new ArrayList<>();
//         routeActions.addAll(transportList);
//         routeActions.addAll(commodityActionList);
//         return routeActions;
//     }
// 
//     @PlanningEntityCollectionProperty
//     @ValueRangeProvider(id = "transportRange")
//     public List<Transport> getTransportList() {
//         return transportList;
//     }
// 
//     public void setTransportList(List<Transport> transports) {
//         transportList = transports;
//     }
// 
//     @PlanningEntityCollectionProperty
//     @ValueRangeProvider(id = "commodityActionRange")
//     public List<CommodityAction> getCommodityActionList() {
//         return commodityActionList;
//     }
// 
//     public void setCommodityActionList(List<CommodityAction> commodityActions) {
//         commodityActionList = commodityActions;
//     }
// }


// Path: heuristicsearch/src/main/java/xyz/thepathfinder/routing/service/RoutingService.java
import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import xyz.thepathfinder.routing.domain.RoutingSolution;

package xyz.thepathfinder.routing.service;




@Path("/")
public class RoutingService {
    Logger logger = LoggerFactory.getLogger(RoutingService.class);

    public static final String SOLVER_CONFIG = "xyz/thepathfinder/routing/solverconfig.xml";

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public ProblemSolution solveProblem(ProblemDescription problemDescription) {
        logger.info("Received request to route: " + problemDescription);
        SolverFactory solverFactory = SolverFactory.createFromXmlResource(SOLVER_CONFIG);
        Solver solver = solverFactory.buildSolver();
        RoutingSolution routingSolution = problemDescription.createEmptyRoutingSolution();
        solver.solve(routingSolution);
        return ProblemSolution.create((RoutingSolution) solver.getBestSolution());