Resilience to Malicious Activity in Distributed Optimization for Cyberphysical Systems