Two forms of knowledge are considered: declarative and procedural. The former is easy to extend but it is equipped with expensive deduction mechanisms, while the latter is efficiently executable but it can hardly anticipate all the special cases. In the first part of this chapter (Sections 2 and 3), we first define a syntactic representation of Soft Constraint Satisfaction Problems (SCSPs), which allows us to express dynamic programming (DP) strategies. For the e-mobility case study of ASCENS, we use Soft Constraint Logic Programming (SCLP) to program (in CIAO Prolog) and solve local optimization problems of single electric vehicles. Then we treat the global optimization problem of finding optimal parking spots for all the cars. We provide: (i) a Java orchestrator for the coordination of local SCLP optimizations; and (ii) a DP algorithm, which corresponds to a local to global propagation and back. In the second part of this chapter (Section 4) we assume that different subjects are entitled to decide. The case study concerns a
model where various prosumers (producers-consumers) negotiate (in real time, according to the DEZENT approach) the cost of the exchanged energy. Then each consumer tries to plan an optimal consumption profile (computed via DP) where (s)he uses less energy when it is expensive and more energy when it is cheap, conversely for a producer. Finally, the notion of an
is introduced, whose aim is to sell flexibility to the market.